Hello ANTLR users I'm wondering if it's possible to do two translation passes using ANTLR for writing a parser for a language in which both keyworded function calls/definitions as canonical function calls are possible. Appart from the syntax, both calls are semantically equal to eachother.
example: is: 1 + 2 equal: 3; is:equal:(1+2, 3); The reason why I want to translate the keyworded function calls into canonical is to separate language-specific code to convert keyworded calls to their canonical representation from the grammar, to make porting to a different backend easier. Also, introducing the keyworded style to my grammar introduces some ambiguities that are inherrent to unbounded keyword expressions. What I'd like to know is wether the folowing is a good idea or does it sound like I'm not seeing a more obvious approach? The idea to achieve this is having 2 parser passes: 1) Translate keyworded occurences from the original input to their canonical representations (using the rule: always try to form the longest possible keyword chain) prog : (KEYWORD) => keyword prog* | ~KEYWORD prog* ; keyword : (kws+=singlekeyword)+ ; single_keyword : key=KEYWORD arg=(~KEYWORD*) ; KEYWORD : ( 'A'..'Z' | 'a'..'z' ) ':' ; do some magic to rewrite foo: x bar: y into foo:bar:(x,y); 2) Run the regular language grammar over the modified input from the first pass. Kind Regards Ben Corne. List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
