[antlr-interest] Re: Nested Matching Parenthesis
cgodfrey86
cgodfrey at epnet.com
Wed May 28 09:47:03 PDT 2003
Thanks for the 2nd set of eyes. I had it like that at one point and
changed it.
--- In antlr-interest at yahoogroups.com, Matt Benson <gudnabrsam at y...>
wrote:
> Not that I know anything but I think the approach you
> were taking is the "ANTLR way to do it." I think your
> expr rule would be recursive, though:
>
> > expr : PATTERN
> > | OPEN_PAREN expr CLOSE_PAREN
> > ;
>
> But again, what do I know?
>
> -Matt
>
> --- cgodfrey86 <cgodfrey at e...> wrote:
> > Hello,
> >
> > I'm trying to write a parser grammar that will check
> > for matching
> > parenthesis. There can be any number of parenthesis,
> > but they must
> > match
> >
> > So,
> > (test) or
> > ((test)) or
> > (((test))) are all valid expressions
> >
> > (test or
> > ((test
> > etc are all invalid
> >
> > So, I have a rule like this
> >
> > expr : PATTERN
> > | OPEN_PAREN PATTERN CLOSE_PAREN
> > ;
> >
> > Would it make sense to write rules which count the
> > number of
> > consecutive open parens and close parens and check
> > for matches? or is
> > there an easier way to approach this that I am
> > missing?
> >
> > start_parens : (OPEN_PAREN)+;
> > end_parens : (CLOSE_PARENS)+;
> >
> > Thanks In Advance
> >
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> >
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
> http://calendar.yahoo.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list