Re: multi-language parsing by using yacc

erik@kroete2.freinet.de (Erik Corry)
Mon, 21 Aug 1995 00:43:21 GMT

          From comp.compilers

Related articles
multi-language parsing by using yacc pliang@msmail4.HAC.COM (Peter Liang) (1995-08-13)
Re: multi-language parsing by using yacc simmons@bnr.ca (steve (s.s.) simmons) (1995-08-17)
Re: multi-language parsing by using yacc erik@kroete2.freinet.de (1995-08-21)
Re: multi-language parsing by using yacc ctv@cs.vu.nl (Cees Visser) (1995-08-21)
Re: multi-language parsing by using yacc bobduff@world.std.com (1995-08-21)
multi-language parsing by using yacc 75066.3204@CompuServe.COM (Carl Barron) (1995-08-22)
| List of all articles for this month |

Newsgroups: comp.compilers
From: erik@kroete2.freinet.de (Erik Corry)
Keywords: yacc
Organization: Home (Freiburg)
References: 95-08-097 95-08-121
Date: Mon, 21 Aug 1995 00:43:21 GMT

steve (s.s.) simmons (simmons@bnr.ca) wrote:
: > Does anyone have experience using yacc to specifiy several grammars
: > in one parser application for parsing different languages (files)?
: >
: > In other words, can I create multi-instances of parsers by using yacc?
: >
: > Does yacc++ help?


: Actually, we had this fight 5 years ago when we were building command
: language for our debugger at Convex.


: Theoretically, it is a bad idea to use yacc for this. YACC works
: with a LALR(1) grammar. This is bottom up parsing technique. You should
: use a top down LL parsing. Why??? The reason is simple. Both the parsing
: and scanning of items further in the command line are context dependent
: upon those items parsed earlier in the command line.


Interestingly enough, Bjarne Stroustrup says the he regretted using yacc
for the Cfront compiler. He allowed himself to be persuaded that it was
uncool to go to the trouble of writing your own parser, but concluded that
yacc caused more problems than it was worth.


My experience is that it is difficult to report good error messages from
a Yacc parser, though admittedly gcc does very well.


On the original question, piping yacc's output though


sed s/yy/zz/g


will sort out the symbols, at least to a first approximation. It's
not nice, but that's what we have make for.
--
Erik Corry ehcorry@inet.uni-c.dk
[It's true, parsing C++ with yacc is quite hard because the syntax is quite
context dependent and in a few cases ambiguous. Some people think this says
at least as much about the design of C++ as about yacc. -John]


--


Post a followup to this message

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