Re: Using functional notation to extend BNF

"Roar" <roar.foshaug@systor.st>
9 Jan 2007 13:30:35 -0500

          From comp.compilers

Related articles
Using functional notation to extend BNF zzq@hvc.rr.com (Bill Fenlason) (2007-01-08)
Re: Using functional notation to extend BNF danwang74@gmail.com (Daniel C. Wang) (2007-01-09)
Re: Using functional notation to extend BNF roar.foshaug@systor.st (Roar) (2007-01-09)
Re: Using functional notation to extend BNF RLake@Oxfam.org.uk (2007-01-15)
| List of all articles for this month |

From: "Roar" <roar.foshaug@systor.st>
Newsgroups: comp.compilers
Date: 9 Jan 2007 13:30:35 -0500
Organization: Compilers Central
References: 07-01-025
Keywords: parse, functional
Posted-Date: 09 Jan 2007 13:30:35 EST

> commaList(1) ::= 1 | commaList(1) "," 1 ;
> separatedList(1,2) ::= 1 | separatedList(1,2) 2 1 ;


Now, I guess most people are using parser generators, and have to
follow BNF of EBNF notation for those to work.


When one implements all from scratch, one is free to invent anything.


I see you work with separated lists here, using recursive rules. How
about instead stating that lists may have an optional separator
element, so that if it matches more than once, it must match separator
elements inbetween?


With separator elements being tokens or non-terminals alike.


Most lists in computer languages seem to be separated by simple things
like comma, and it seems odd to introduce all those recursive
constructs to match such a common yet simple language part.


As I see it, BNF is just a thought-organizing tool, a way of expressing
and later implementing a way of recognizing program code. The less
recursion, the better, since recursion is harder to understand reading
it, and harder to implement. Having to first use a lot of
left-recursive rules, then applying the standard formulae for
dispelling it, creating additional (cryptic) productions, is not very
readable.


I have formulated a mostly complete, though not verified, grammar for a
java-like language, completely free of left recursion, using the above
mentioned construct, of letting the grammar have the capability of
matching not just sequences of something, but separated sequences.


Maybe I'm missing something here? :-)


Post a followup to this message

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