Float input example question

37 views
Skip to first unread message

Byron Faber

unread,
Jan 7, 2013, 8:06:08 PM1/7/13
to antlr-di...@googlegroups.com
I've been trying to use this example for parsing float inputs:

The example refers to input.LT(-1).. What's the correct syntax to pull this off for a C-runtime target? It seems its only a legal construct for the parser, not the lexer?

Thanks..

Jim Idle

unread,
Jan 7, 2013, 8:17:33 PM1/7/13
to antlr-di...@googlegroups.com
For the C target it is just the macro LT

Cheers,

Jim
--
 
 

byron...@gmail.com

unread,
Jan 7, 2013, 8:45:50 PM1/7/13
to antlr-di...@googlegroups.com
On Monday, January 7, 2013 5:17:33 PM UTC-8, Jim Idle wrote:
> For the C target it is just the macro LT

That's what I tried, but the code in question ends up in the lexer file, which doesn't know the LT macro.

I didn't try following the macro-expansion and coding the equivalent, but I take it that might work instead?

Byron

Jim Idle

unread,
Jan 8, 2013, 11:57:40 AM1/8/13
to antlr-di...@googlegroups.com
Well you can't use LT in the lexer. You can use LA in the lexer. LT
looks at the token stream, LA looks at the character input stream. Do
you see LT being used in lexer rules?

Jim
> --
>
>

Byron Faber

unread,
Jan 8, 2013, 12:25:15 PM1/8/13
to antlr-di...@googlegroups.com
I copied the float example (that I posted earlier) into my grammar file and the result ends up in the lexer.

e.g.  I copied the example here into my file and the result ends up in the lexer.   (which is why i was confused...)


Is it just a typo in that example?
Byron

Jim Idle

unread,
Jan 8, 2013, 12:57:14 PM1/8/13
to antlr-di...@googlegroups.com
Well that is a pure lexer only grammar so you will need to start it with:

lexer grammar xxxx;

Or if you want it in a combined grammar then those sections will start with lexer:: such as lexer::members

Jim
--
 
 

Byron Faber

unread,
Jan 8, 2013, 4:39:59 PM1/8/13
to antlr-di...@googlegroups.com
Thanks for the comments and pointers.  I see the example originally came from javafx pieces and tracked down the larger implementation context which pointed me in the right direction...

Byron
Reply all
Reply to author
Forward
0 new messages