[antlr-interest] Re: keywords appended to identifiers, suggestion s?

gdave dave.green at valley.net
Thu Jun 12 12:58:12 PDT 2003


--- In antlr-interest at yahoogroups.com, "Jim O'Connor" 
<Jim.OConnor at m...> wrote:
> Hi Dave,
>   There is one solution.  There may be others.  A lexer is a 
CharScanner.
> CharScanner has a method testLiteralsTable().
> 
> class L extends Lexer;
> 
......  rest of solution snipped......

I should have written in my first note that I was hoping to find a 
grammar based solution.  To get something running, I wrote a proxy 
TokenStream which I placed between the Lexer and the Parser which 
would notice trailing KEYWORDS appended to NAME tokens and split them 
into two tokens before sending them along.

This works, but leaves me maintaining a list of Keywords in a class 
separate from the rest of my grammar which feels awkward.  I was 
hoping that I was just missing some utility of the EBNF and predicate 
syntax that would let me lookahead to notice trailing KEYWORDS.

Actually I have tried experiments with Semantic predicates and 
although the "infinite" lookahead ability allows me to see a KEYWORD 
in the future, I have not found a production to place with the 
predicate that halts before consuming the KEYWORD characters.

anyone have any grammar ideas?
Dave


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list