Re: yacc: Getting type of token on error.

"Quinn Tyler Jackson" <>
18 Dec 1998 12:09:26 -0500

          From comp.compilers

Related articles
yacc: Getting type of token on error. (1998-12-13)
Re: yacc: Getting type of token on error. (Quinn Tyler Jackson) (1998-12-18)
Re: yacc: Getting type of token on error. (Vladimir Makarov) (1998-12-18)
| List of all articles for this month |

From: "Quinn Tyler Jackson" <>
Newsgroups: comp.compilers
Date: 18 Dec 1998 12:09:26 -0500
Organization: Compilers Central
References: 98-12-028
Keywords: yacc, errors

Steve Mading <> wrote in message news:98-12-028@comp.compilers...

>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
been done.

Examples of C++ semantic errors that would be caught by a PAISLEI
generated grammar are:

        class Foobar

        // 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


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.