[antlr-interest] greedy/non-greedy problem.
Bharath
bharath at starthis.com
Tue May 18 08:35:06 PDT 2004
Hi Mark,
Thanks a bunch, it worked :). The language I'm parsing is structured text,
which is similar to PASCAL. It's an old language and it's used in
programmable logic controllers to operate machinery on plant floors. It's
very different from standard programming languages and there are crazy
constraints to enforce safety as it controls machines.
Maybe we should have a system where points are awarded to people who answer
questions, as a token of appreciation. What rewards can be reaped with the
points you get can be decided via group consensus. The direct benefit could
be, antlers won't post on the list to just get answers, they would also be
giving answers.
Bharath.
-----Original Message-----
From: Mark Lentczner [mailto:markl at glyphic.com]
Sent: Tuesday, May 18, 2004 10:15 AM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] greedy/non-greedy problem.
On May 18, 2004, at 7:35 AM, Bharath wrote:
> myParserRule: IDENT DOT IDENT DOT (IDENT DOT)* IDENT;
The problem is that while normally a DOT must be followed by IDENT, the
second DOT doesn't have this issue (odd grammar, if you ask me, but
what do I know about what you're parsing...)
Try this:
myParserRule: IDENT DOT IDENT DOT (IDENT (DOT IDENT)*)? ;
Without knowing the rest of the grammar I can't say if this will solve
the issue. But, generally speaking, moving optional sections to the
end of a rule is better than having them in the middle.
- Mark
Mark Lentczner
markl at wheatfarm.org
http://www.wheatfarm.org/
Yahoo! Groups Links
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