|yacc: Getting type of token on error. firstname.lastname@example.org (1998-12-13)|
|Re: yacc: Getting type of token on error. email@example.com (Quinn Tyler Jackson) (1998-12-18)|
|Re: yacc: Getting type of token on error. firstname.lastname@example.org (Vladimir Makarov) (1998-12-18)|
|From:||"Quinn Tyler Jackson" <email@example.com>|
|Date:||18 Dec 1998 12:09:26 -0500|
Steve Mading <firstname.lastname@example.org> wrote in message news:email@example.com...
>For example, I'd like to be able to make an error message
>of the form: "Line 999: Expecting a foo, bar, or baz, but found a biz instead."
>error that isn't really an error if I matched a "foo", but it's an
>error if I matched anything else. So I need to be able to tell the
>type of the token matched and do some manual ugliness to fix things up
>and go on.
It's probably not exactly what you're looking for, but I added a type
of error reporting into LPM that can generate errors at the grammar
level that may be able to be worked around to satisfy requirements
similar to yours.
In LPM-driven grammars generated by PAISLEI, using pattern
inheritance, it is possible to trigger more intelligent errors in
semantics than with traditional tools.
As an example, LPM-driven grammars can catch semantic errors in C++
such as "undeclared class" and "destructors must be in the form a::~a"
at the grammar specification level. There are also undocumented
features in LPM that will allow it to catch errors such as "the class
Foobar does not have a declared member function Bar", but the features
of LPM that allow this are still under active research, so there are
holes that will need to be filled after adequate research on this has
Examples of C++ semantic errors that would be caught by a PAISLEI
generated grammar are:
// The following would generate an "Undeclared class" error
// the following would generate an "dtors must be in the form a::~a" error
If you have access to a Win32 system, you might want to download PAISLEI and run the
"member_function.lpm" grammar example in the Example folders. This example grammar
demonstrates a 17 production grammar that parses many simple C++ constructs, while
catching the two errors mentioned above. Information on PAISLEI can be found at:
I am in the process of putting together a formal paper introducing all of this, abstract
to be found at:
Quinn Tyler Jackson
Return to the
Search the comp.compilers archives again.