Related articles |
---|
Q: what parser generator can do this? mgijsen@lucent.com (Martin Gijsen) (1999-11-25) |
Re: Q: what parser generator can do this? qjackson@wave.home.com (Quinn Tyler Jackson) (1999-11-28) |
Re: Q: what parser generator can do this? gneuner@dyn.com (1999-11-28) |
From: | "Quinn Tyler Jackson" <qjackson@wave.home.com> |
Newsgroups: | comp.compilers |
Date: | 28 Nov 1999 01:30:25 -0500 |
Organization: | Compilers Central |
References: | 99-11-158 |
Keywords: | parse |
Martin Gijsen said:
> So can anyone out there
> recommend a parser generator that can do all of the following:
>
> - multiple entry points (multiple parsers, shared code)
> - supports parameters to rules and local variables (like LLgen)
> - error mechanism that enables context specific error messages
> (such as: "bar" expected after "foo")
> - generates C or C++ code (Unix environment)
PAISLEI seems to meet all the above requirements.
It can generate multiple grammars that are re-entrant. (You could
call a PAISLEI grammar for language B from the production code of
parser A, to parse a sub-language, or <SCRIPT> section in HTML, for
instance.)
You can also extract substrings into "casts" that are easily
accessible from production code, using a macro, so that:
['('$
[^
[*?
['variable'^
[')'$
Would match (foobar), and in your C++ code, you can reference the
lexeme "foobar" like this:
__PSL_CAST("variable")
This is not quite "variables and parameters..." but it works.
You can generate specific error messages, like this:
['('$
['a';'b';c' / "A, B, or C expected!" / $
[')'$
The above would generate the message "A, B, or C expected!" if it
encountered (d), for instance.
Finally, PAISLEI patterns can be written as traditional regular
expressions if you are more comfortable with those, like this:
<RE([a-zA-Z_][a-zA-Z0-9_]+)>
Although PAISLEI itself runs only on Win32 systems, the classes it
generates have proven to be portable to the *nix C++ compilers. You
can test and generate your grammar on a Win32 system, compile it on a
*nix system.
Version 2.0 is currently in beta at http://www.qtj.net/~lpm/beta/
(If that link doesn't work due to DNS problems, try:
http://24.113.4.170/~lpm/beta )
Cheers,
--
Quinn Tyler Jackson
http://www.qtj.net/~quinn/
Return to the
comp.compilers page.
Search the
comp.compilers archives again.