I suggest that you want to use getargs, and not try to parse things like
this with ANTLR as the specification is too vague. The lexer is not
context driven, so placing a rule like that in lexer will match everything
that is whitespace to the detriment of any other rule at all.


Jim


> -----Original Message-----
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Patrick Nick
> Sent: Wednesday, October 19, 2011 8:52 AM
> To: antlr-interest@antlr.org
> Subject: [antlr-interest] Matching an arbitrary string until the next
> whitespace occurrence
>
> Hi all,
>
> I just started using antlr and was able to construct a nice grammar
> that fulfills my application's needs. There is one thing which I
> haven't been able to get to work though.
> My grammar is parsing program arguments which the user supplied when
> starting the program, and some of that input will need to be forwarded
> to another program. This implies that I have almost no control over
> those strings and need to be able to parse them only knowing that they
> are delimited by whitespace. So what I need (I think) is a lexer rule
> to match an arbitrary string which doesn't contain whitespace.
>
> Here is what I tried, with the intention that it should match anything
> that doesn't contain one of the four characters.
>
> STRING :    (~(' '|'\t'|'\r'|'\n'))+ ;
>
> However, that does not seem to be working, it doesn't recognize numbers
> for example, and I don't understand why.
> Any hints?
>
> Regards
> Patrick
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to