Tip - Added lexers for Easytrieve and Job Control Language (JCL)

Published  | Submitted by Julie Vito
Added lexers for Easytrieve and Job Control Language (JCL)

This is a cleaned up resubmit of pull request #169. As suggested, the WebFOCUS lexer will be resubmitted in a separate request. The languages included here are: 1. Job Control Language ([JCL](http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IEA2B570/CCONTENTS)) is a scripting language used on mainframe platforms to instruct the system on how to run a batch job or start a subsystem. It is somewhat comparable to MS DOS batch and Unix shell scripts. 2. [Easytrieve](http://en.wikipedia.org/wiki/Easytrieve) is a programming language for extracting, filtering and converting sequential data. Furthermore it can layout data for reports. It is mainly used on mainframe platforms and can access several of the mainframe's native file formats. It is somewhat comparable to awk. I applied the lessons learnt from pull request #169 and also cleaned up the parser stack by using `'#pop`'. The Easytrieve lexer should be pretty sound now. The JCL lexer also keeps the stack cleaner than before but there are still some places where I'm not sure how to apply `'#pop'` properly. The main issue is the `'option'` rule while can be called from different nesting depths and always has to return to the `'root'` rule. Currently there are the following variants for calling `'option'`: ``` root statement statement_command option <-- stack depth: 4 root jes2_statement option <-- stack depth: 3 ``` So sometimes `'option'` would need 2 `'#pop'`s to return to `'root'`, othertimes 3. Because `'option'` is finished when encountering a linefeed, it cannot just return to the previous states. So pushing multiple `'#pop'`s before calling `'option'` does not solve this. I also added a quite convenient function `util.sorted_keywords_pattern()` which converts an array of keywords to a regular expression pattern. Apart from escaping the keywords it also ensures that keywords with common prefixes are sorted properly (e.g. `'something'` comes before `'some'`). As an added bonus, adding a keyword to a long lists is now much easier. No more resplitting regex-strings with many `|` separators - simply rewrap the list in any capable text editor. I updated my recently submitted Rexx lexer to use this function.

About Author

More by Julie Vito

About This Tip

Posted: 9 years, 5 month(s) ago

156 Reads
0 Votes