extending a grammar

maatwerk@euronet.nl (M.M. van der Laan)
12 Mar 1996 21:48:16 -0500

          From comp.compilers

Related articles
extending a grammar maatwerk@euronet.nl (1996-03-12)
Re: extending a grammar foggia@amalfi.dis.unina.it (1996-03-21)
Re: extending a grammar platon!adrian@uunet.uu.net (1996-03-25)
Re: extending a grammar mw@ipx2.rz.uni-mannheim.de (1996-03-27)
Re: extending a grammar franka@europa.com (1996-03-27)
RE: extending a grammar VIC@edge.paragraph.com (Zhukov Victor) (1996-03-27)
| List of all articles for this month |

From: maatwerk@euronet.nl (M.M. van der Laan)
Newsgroups: comp.compilers
Date: 12 Mar 1996 21:48:16 -0500
Organization: Euronet Internet
Keywords: parse, design

Programming languages are never be flexible enough to cover all
programming tasks. Off course, libraries of functions cover most
problems, but sometimes one just needs a better grammar.

A solution might be to be able to expand the grammar by means of some
EBNF notation, written in the language itself. The compiler could
translate this EBNF and add it to it's own parser tables.

For instance, to allow inline SQL the syntax could be extended

        grammar ; a reserved word to start EBNF
                statement = sql_select ; add select statement to grammar
                sql_select = 'SELECT' etc...
                (rest of code not shown)

The EBNF can contain function calls (as in a normal parser
specification) to the internal parser, which has to be part of the
language, off course.

Has anyone done this / thought of this / seen this before? Any remarks?

Mauk van der Laan
[Extensible languages like this were quite popular in the early 1970s,
letting you define new syntax which mapped into macros or the like.
They were awful to use, because no two programs used the same syntax,
and there were always lots of little packages of syntactic sugar. OOP
is kind of the flip side of the same idea, keeping the syntax the same
but adding new semantics. -John]


Post a followup to this message

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