Re: multi-language parsing by using yacc

"steve (s.s.) simmons" <simmons@bnr.ca>
Thu, 17 Aug 1995 13:05:15 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: "steve (s.s.) simmons" <simmons@bnr.ca>
Keywords: yacc, comment
Organization: Bell-Northern Research Ltd.
References: 95-08-097
Date: Thu, 17 Aug 1995 13:05:15 GMT

> 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. A simple example
is


PRINT an_expression
SAVE a_filename


A filename identifier is usually allowed to have periods and "/"
in the name. A variable's name usually can't have "/" in it.
You could have been able to choose the right scanner by completely
parse the command first.


The person in our group was able to get it to work with YACC; however,
many of his solutions were made more complicated by the approach. Like
the components of the filename were completely parsed, and then concatenated
together to form a file name.


Thank you.


Steve Simmons
[I agree - yacc is fine for grammars that are close to context free, but a
huge pain for seriously context dependent ones. I've even parsed Fortran using
yacc, but it wasn't pretty. -John]
--


Post a followup to this message

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