|Lazy/tolerant parsers email@example.com (2004-07-13)|
|Re: Lazy/tolerant parsers firstname.lastname@example.org (Dmitry A. Kazakov) (2004-07-14)|
|Re: Lazy/tolerant parsers email@example.com (2004-07-15)|
|Re: Lazy/tolerant parsers firstname.lastname@example.org (Dmitry A. Kazakov) (2004-07-17)|
|From:||"Dmitry A. Kazakov" <email@example.com>|
|Date:||14 Jul 2004 12:09:31 -0400|
|Posted-Date:||14 Jul 2004 12:09:31 EDT|
On 13 Jul 2004 22:30:21 -0400, Akhilesh Mritunjai wrote:
> I tried searching in archives, but could not find helpful results.
> I have a (Ada like) grammar for which I need to create a parser which
> should be usable for code as user types (syntax highlighting, code
> assist etc). So the parser should correctly deal with -
> - partial sententences
> - Incomplete/missing closures
> Which method would you recommend to write such a parser ?
You can take a look at
it has a parser to deal with expressions. (There is an example of full
Ada 95 expression parser and tree generator). The parser stops at
something it cannot recognize. At this point one can determine its
state. I.e. how many unclosed brackets, missing right operands etc you
have. One can use some kind of pattern matching to jump over an
indigestible part (not a name or literal, but just rubbish) and
continue. Recognized tokens contain location info, which can be used
for highlighting. Well, statements like if-then-else can be treated as
brackets, I suppose.
Dmitry A. Kazakov
Return to the
Search the comp.compilers archives again.