Hi guys,

I am working on parser for JAL, 'Just Another Language' for Microchips
PIC microcontrollers.

Within JAL you can define a variable like:

   var byte data

where 'data' is a valid identifier, matched by

   IDENTIFIER : LETTER (LETTER|'0'..'9')* ;

   fragment LETTER : 'A'..'Z' | 'a'..'z' | '_' ;


Now I want to add support for pragma statement, used for the setup of
the microcontroller. An example (one of quite a few) of this is:

   pragma  data    0x20-0x6F,0xA0-0xEF

With:

pragma
    : 'pragma'^ (
        ( 'target' pragma_target )
        | ( 'data' constant '-' constant (',' constant '-' constant)* )         
    )
    ;

This works okay, but does break the parsing of identifiers like 'data'.

How can antlr (in general) handle keywords within a specific context,
while retaining the possibility to use these keywords as identifiers
in the general context?

Any advice is appreciated!

Joep

PS Amongst others, the full grammar (current state, not completed) is
at http://code.google.com/p/jallib/source/browse/#svn/trunk/grammar

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.

Reply via email to