[antlr-interest] Advice with backtracking/ambiguity

Ken Williams ken.williams at thomsonreuters.com
Thu Jun 3 11:35:07 PDT 2010




On 6/2/10 5:38 PM, "John B. Brodie" <jbb at acm.org> wrote:

> On Wed, 2010-06-02 at 17:03 -0500, Ken Williams wrote:
>> Yeah, probably I should be using parser rules.  I was trying to keep things
>> "simple" by making everything a linear stream of tokens from the point of
>> view of the Java caller, while still having high-level constructs like DATE.
> 
> just be aware that when you make date a parser rule WS will be silently
> accepted between the DIGITS and SLASHes comprising the date
> non-terminal. 

Yeah, good point.  In this case that's fine.  It would be nice, though, if
there were a per-rule parser directive to control which channel(s) to pay
attention to, something like this:

date    
options {channel=ALL;}
:    DIGITS SLASH DIGITS SLASH DIGITS ;


Not sure whether that's feasible or not though.

-- 
Ken Williams
Sr. Research Scientist
Thomson Reuters
Phone: 651-848-7712
ken.williams at thomsonreuters.com




More information about the antlr-interest mailing list