[antlr-interest] Re: Space in values (need more info)

micheal_jor open.zone at virgin.net
Wed Nov 24 05:04:04 PST 2004



--- In antlr-interest at yahoogroups.com, "DELZANT Bruno \(BMB\)"
<Bruno.Delzant at p...> wrote:
> Thanks for the help, but ... I don't see what you mean :-/ I have read
> the part on string in the user guide, but I don't see what's the help of
> this.

Ter meant that you should include a separate rule that matches quoted
strings in your lexer. You can use the STRING_LITERAL rule in the
java.g sample grammar as a starting point to create your own.

> I'll try perhaps with a simpler example of what I want to achieve:
> Need to parse the following input:
> 
> PRIORITY = "3"
> REQ_USER_ID = "PTS JDA"
> REQ_PROC_ID = "process"
> 
> As you can see, there is a space in second quoted string.
> With the following grammar, I am getting stuck on that space.
> How can I improve the grammar to detect space in this quoted string and
> get back the value ?

If you have a STRING rule (and deleted the QUOTE rule) the lexer would
return the following tokens for each of the input lines above:

   ALPHA_NUM_STRING EQUAL STRING

The string token would have the whole of the quoted string (e.g. "PTS
JDA") as it's lexeme (available via the getText() method.

Cheers!

Micheal
ANTLR/C#





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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





More information about the antlr-interest mailing list