[antlr-interest] Infinite lookahead/syntactic predicates

Terence Parr parrt at cs.usfca.edu
Thu Jun 23 15:29:55 PDT 2005


On Jun 23, 2005, at 3:25 PM, Anders Jacobsson wrote:

> Hi!
>
> I'm really sorry if I'm asking about something obvious or something
> that is clearly stated in the documentation but I would really
> appreciate in one or two hints that can guide me in my first attempts
> of using ANTLR.
>
> Anyway, I need to process things like the following:
>
> '12345'D
> '13AEF'H
> '1A4'T
> '1010101'B
> '17853'
>
> The first one should be matched to be a decimal constant, the second
> one a hexadecimal constant, the third one a TBCD constant, the fourth
> one a binary constant and the last to be a constant of unknown type.

Can you do something simple like

CONST : '\'' ('0'..'9')+ '\'' ('D'|'H'|'T'|'B'| ) ;

Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com



More information about the antlr-interest mailing list