|Is this a some kind of regular grammar? email@example.com (Daniel Shane) (2002-06-28)|
|Is this a some kind of regular grammar? firstname.lastname@example.org (Chris F Clark) (2002-07-02)|
|Re: Is this a some kind of regular grammar? email@example.com (Michael Dyck) (2002-07-02)|
|Re: Is this a some kind of regular grammar? firstname.lastname@example.org (Robert Thorpe) (2002-07-04)|
|From:||"Robert Thorpe" <email@example.com>|
|Date:||4 Jul 2002 23:18:05 -0400|
|Posted-Date:||04 Jul 2002 23:18:05 EDT|
> I have a question about a hypothetical grammar construction. The
> usual way of parsing involves the usage of a lexer combined with
> some type of parser that understands a grammar. One of the most
> common grammar type for the parser is LALR(1) because of its
> speed. There are also implementation of LL(k) but with high k's this
> can result in long processing time.
Only in some cases.
> One of my problems is that sometimes it is impossible for me to
> distinguish a token at the lexer stage, because multiple regular
> expression can match the same token depending on the context. What
> I need is an integrated solution which combines the lexer and the
> parser at the same time.
What you could do is just add stuff to the lexer to do the
recognition. For instance only have one regular expression match the
pattern and have some action code distingush between the two cases.
AFAIK C parsers sometimes have code in the lexer that distingushes
between typecasts and expressions in a similar way. This is a hack
but probably easier than resorting to exotic parsing methods for the
whole thing. If you designed the grammar redesign it to make your
Return to the
Search the comp.compilers archives again.