[antlr-interest] how to get the value of an identifier

Thierry USO thierry.uso at wanadoo.fr
Sat Sep 26 06:51:46 PDT 2009


Hello,

I am trying to write a grammar for the procedural language of a dead L4G (Rally). The goal is to translate some L4G procedures into a modern programming language, using the lexer/parser generated by antlr.

I am confronted with the following problem:

--- Extract of the grammar ---

heading
: PROCEDURE (SPACE)* procedure_name (SPACE)* parameter_declaration ';'
;

procedure_name
: IDENTIFIER
;

IDENTIFIER
: LETTER (LETTER|_|DIGIT)+
;

-----

How can I get the value of procedure_name and print it (screen or file) ? Adding {System.out.print($IDENTIFIER.text);} in the procedure_name rule does not work.

Thanks for your help.





More information about the antlr-interest mailing list