[antlr-interest] Re: yet another java 1.5 grammar
thrutchy
eric_mahurin at yahoo.com
Thu Aug 26 21:09:12 PDT 2004
Monty,
Can you elaborate - an example where it works and where it doesn't? I
don't understand how a syn pred can keep you in a loop. They should
only qualify/invalidate the syntax (and break you out of the loop).
I've been using syn preds like this for cases where a fixed lookahead
doesn't cut it:
( (x)=>x )* y
Or you can make the syn pred just enough of x to differentiate it from y.
- Eric
p.s. I've mentioned this before, but it would be nice in ANTLR 3 if we
had a shorthand for doing this type of backtracking. If it was done
with an inherent backtracking mechanism, you also wouldn't need to
parse x twice as above when there is a match. But, any actions in
between couldn't have any side effects. Personally, I think it should
be a requirement that syn preds (and backtracking sub-rules) have no
actions with side effects so that the code didn't have to do that
"input_guessing" thing.
--- In antlr-interest at yahoogroups.com, Monty Zukowski <monty at c...> wrote:
> Syn preds in loops work in some cases and not in others. You can't
> have a syntactic predicate cause you to break out of a loop, you can
> only have it keep you in the loop.
>
> Monty
>
> ANTLR & Java Consultant -- http://www.codetransform.com
> ANSI C/GCC transformation toolkit --
> http://www.codetransform.com/gcc.html
> Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html
>
> On Aug 25, 2004, at 2:21 PM, thrutchy wrote:
>
> > --- In antlr-interest at yahoogroups.com, "lgcraymer" <lgc at m...> wrote:
> >> --- In antlr-interest at yahoogroups.com, Terence Parr <parrt at c...>
> >> wrote:
> >>>
> >>> On Aug 25, 2004, at 11:02 AM, Michael Stahl wrote:
> >> ...
> >>>> do you have any comment on the syntactic predicate in loops
> >>>> issue i have with antlr? (see original posting)
> >>>
> >>> I'm completely underwater at the moment breathing through a small
> > straw
> >>> ;) I'm gearing up for school; advising students and prepping my
> > first
> >>> classes. Ugh. I expect to surface next week sometime. :)
> >>
> >> Ter may be completely under water at the moment, but the "synpreds in
> >> loops" issue has been raised as an ANTLR 3 design concern and one
that
> >> will probably be addressed. Right now, you can use synpreds in
> >> recursive definitions, but not in loops. That rules out an important
> >> class of refactorings: it is important that logically equivalent
> >> constructs actually have the same behavior!
> >>
> >> --Loring
> >
> >
> > As far as I can tell, syntactic predicates with loops do work - you
> > just have to ignore the warning. I use a wrapper to antlr that
> > filters out these (one of my previous posts has it).
> >
> > Eric
> >
> >
> >
> >
> >
> > 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