I'd like to parse REXX source so that I can analyse the structure of the program from Java.
I need to do things like normalise equivalent logic structures in the source that are syntactically different, find duplicate variable declarations, etc. and I already have a Java background.
Any easier ways to do this than writing a load of code?
Defining a Function PARSE ARG − These are keywords in Rexx which are used to mention that parameters are being passed onto the function. arguement1, arguement2… arguementN − These are the arguments passed to the function. Return value − This is the value returned by the function.
If you have BNF Rexx grammar, then javacc can help you build an AST (Abstract Syntax Tree) representation of that Rexx code.
More accurately, javacc will build the Java classes which will :
There would still be "load of code", but you would not to be the one doing the writing of the classes for that Rexx code parser. Only its generation.
REXX is not an easy language to parse with common tools, especially those that expect a BNF grammar. Unlike most languages designed by people exposed to C, REXX doesn't have any reserved words, making the task somewhat complicated. Every term that looks like a reserved word is actually only resolved in its specific context (e.g., "PULL" is only reserved as the first word of a PULL
instruction or the second word of a PARSE PULL
instruction - you can also have a variable called PULL ("PULL = 1 + 2
")). Plus there are some very surprising effects of comments. But the ANSI REXX standard has the full syntax and all the rules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With