Re: SUMMARY: BNF definition (EBNF acceptance)

"Terence Parr" <parrt@s1.arc.umn.edu>
Fri, 20 May 1994 15:08:41 GMT

          From comp.compilers

Related articles
SUMMARY: BNF definition rdwi@se.bel.alcatel.be (Ronny De Winter) (1994-05-18)
Re: SUMMARY: BNF definition (EBNF acceptance) nathan@stc.com (Nathan K. Inada) (1994-05-18)
Re: SUMMARY: BNF definition (EBNF acceptance) parrt@s1.arc.umn.edu (Terence Parr) (1994-05-20)
Re: SUMMARY: BNF definition (EBNF acceptance) adrian@platon.cs.rhbnc.ac.uk (1994-05-22)
Re: SUMMARY: BNF definition (EBNF acceptance) max@Kolmogorov.gac.edu (1994-05-23)
| List of all articles for this month |
Newsgroups: comp.compilers
From: "Terence Parr" <parrt@s1.arc.umn.edu>
Keywords: syntax, parse
Organization: Compilers Central
References: 94-05-067 94-05-071
Date: Fri, 20 May 1994 15:08:41 GMT



  > Although they can significantly improve the readability of the
  > grammar, they complicate the matter when it comes to parser or
  > code generation, so EBNF is generally unpopular in compilers
  > theory.


"Nathan K. Inada" <nathan@stc.com> writes:
> is this true? ...
>
> is EBNF unpopular to the compiler theorist but not compiler
> practitioner, maybe?


EBNF is great if you generate recursive-descent parsers, but wouldn't
affect conventional LL or LALR automaton-based parsers because they simply
convert EBNF to BNF and do the usual FSM boogie. Russell Quong, Hank
Dietz (both at Purdue) and I once considered how you could build an
LR-based FSM that took advantage of EBNF constructs, but didn't end up
anywhere with it.


Anyhoo, EBNF makes a difference for recursive-descent as the following
illustrates:


a : A a | ;


generates


a()
{
if ( LA(1)==A ) {
MATCH(A);
a();
}
}


which uses evil tail-recursion. The equivalent EBNF construct is easier
to read/debug and can be used to generate better code (PCCTS does this).


a : (A)* ;


results in


a()
{
while ( LA(1)==A ) {
MATCH(A);
}
}


Regards,
Terence of ``Dr. T's Traveling Parsing Revival''
--


Post a followup to this message

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