implicit token definition in parser rule

1,218 views
Skip to first unread message

Van Le Nguyen

unread,
Aug 3, 2015, 12:34:20 PM8/3/15
to antlr-discussion
Hi all,
I type grammar CSV on page 143 of "The Definitive ANTLR 4 Reference" book use the ANTLRWork2.1 
. But the warning isue "implicit token definition in parser rule" at: row : field (',' field)* '\r'? '\n' ;
Could you help me!
Thanks you very much.

Kevin Cummings

unread,
Aug 3, 2015, 5:39:25 PM8/3/15
to antlr-di...@googlegroups.com
On 08/03/15 12:34, Van Le Nguyen wrote:
> Hi all,
> I type grammar CSV on page 143 of "The Definitive ANTLR 4 Reference"
> book use the ANTLRWork2.1
> . But the warning isue "implicit token definition in parser rule" at:
> /row : field (',' field)* '\r'? '\n' ;/
> Could you help me!
> Thanks you very much.

Add token definitions for the literals:

COMMA: ',';
CR: '\r';
NL: '\n';

Then in your parser:

row : field (COMMA field)* CR? NL ;

You are now using explicit token definitions.

> --
> You received this message because you are subscribed to the Google
> Groups "antlr-discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to antlr-discussi...@googlegroups.com
> <mailto:antlr-discussi...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

--
Kevin J. Cummings
kjc...@verizon.net
cumm...@kjchome.homeip.net
cumm...@kjc386.framingham.ma.us
Registered Linux User #1232 (http://www.linuxcounter.net/)

Van Le Nguyen

unread,
Aug 6, 2015, 5:37:08 AM8/6/15
to antlr-discussion


On Tuesday, August 4, 2015 at 4:39:25 AM UTC+7, Kevin Cummings wrote:
On 08/03/15 12:34, Van Le Nguyen wrote:
> Hi all,
> I type grammar CSV on page 143 of "The Definitive ANTLR 4 Reference"
> book use the ANTLRWork2.1
> . But the warning isue "implicit token definition in parser rule" at:
> /row : field (',' field)* '\r'? '\n' ;/
> Could you help me!
> Thanks you very much.

Add token definitions for the literals:

COMMA:        ',';
CR:        '\r';
NL:        '\n';

Then in your parser:

row : field (COMMA field)* CR? NL ;

You are now using explicit token definitions.

> --
> You received this message because you are subscribed to the Google
> Groups "antlr-discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to antlr-discussi...@googlegroups.com
> <mailto:antlr-discussion+unsub...@googlegroups.com>.

Thanks you very much 
Reply all
Reply to author
Forward
0 new messages