Re: yacc: Getting type of token on error.

"Quinn Tyler Jackson" <qjackson@wave.home.com>
18 Dec 1998 12:09:26 -0500

          From comp.compilers

Related articles
yacc: Getting type of token on error. madings@execpc.com (1998-12-13)
Re: yacc: Getting type of token on error. qjackson@wave.home.com (Quinn Tyler Jackson) (1998-12-18)
Re: yacc: Getting type of token on error. vmakarov@cygnus.com (Vladimir Makarov) (1998-12-18)
| List of all articles for this month |
From: "Quinn Tyler Jackson" <qjackson@wave.home.com>
Newsgroups: comp.compilers
Date: 18 Dec 1998 12:09:26 -0500
Organization: Compilers Central
References: 98-12-028
Keywords: yacc, errors

Steve Mading <madings@execpc.com> 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
        {
                Foobar(void);
                ~Foobar(void);
        };


        // The following would generate an "Undeclared class" error
        yada::yada(void)
        {
        }


        // the following would generate an "dtors must be in the form a::~a" error
        Foobar::~Frob(void)
        {
        }


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:


        http://www.qtj.net/~lpm/


I am in the process of putting together a formal paper introducing all of this, abstract
to be found at:


        http://www.qtj.net/~quinn/computer_science/paislei_abstract.html


Cheers,


--
Quinn Tyler Jackson


email: qjackson@wave.home.com
url: http://www.qtj.net/~quinn/
ftp: qtj.net


Post a followup to this message

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