Related articles |
---|
dynamic yacc-tables? canver@cyborg.informatik.uni-ulm.de (1991-08-12) |
Re: dynamic yacc-tables? pardo@gar.cs.washington.edu (1991-08-13) |
Re: dynamic yacc-tables? rekers@cwi.nl (1991-08-13) |
Re: dynamic yacc-tables? joshua@veritas.com (1991-08-13) |
Re: dynamic yacc-tables? salomon@ccu.umanitoba.ca (1991-08-13) |
Re: dynamic yacc-tables? kjell@cs.ucsc.edu (Kjell Post) (1991-08-14) |
Re: dynamic yacc-tables? markh@csd4.csd.uwm.edu (1991-08-16) |
Newsgroups: | comp.lang.c,comp.compilers |
From: | joshua@veritas.com (Joshua Levy) |
Keywords: | parse, yacc |
Organization: | VERITAS Software |
References: | 91-08-043 |
Date: | Tue, 13 Aug 1991 17:26:18 GMT |
In article 91-08-043 canver@cyborg.informatik.uni-ulm.de (Ercument Canver) writes:
>I got the following problem: I need to extend the parse tables generated
>by yacc dynamically during parsing a text. ...
>
>Background: I'm posting this request because I have to write a parser suitable
>for declaring mixfix operators and overloading.
>
>I'd also appreciate pointers to parser generaters dealing with this kinda
>problem (not necessarily yacc-like).
You may want to attack the problem with lex instead of yacc. Read:
PARSING DISTFIX OPERATORS by Edgar H. Sibley in Commmunications of the ACM
February 1986, Vol 29, num 2, page 118.
Abstract:
The advantages of user-defined distfix operators -- a syntactic
convenience that enhances the readability of programs -- can be
obtained as an extension of almost any programming language without
requiring dynamic changes to the parser.
Conclusions:
We have described a simple technique whereby a fixed BNF grammar can
describe languages including user-defined infix, postfix, and distfix
operators. The technique requires only that the parts of disfix
operators be lexically distinguishable. ...
The idea has been successfully implemented [with YACC] with minimal
effort.
Note that "lexically distinguishable" means that lex can look up the
answer in a table, which can grow dynamically. I'm not sure how Sibley's
ideas interact with overloading.
Joshua Levy (joshua@veritas.com)
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.