Parse EBNF

From Rosetta Code
Revision as of 05:19, 12 June 2010 by rosettacode>Tinku99 (simple parser generator example ?)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Parse EBNF is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Create a simple parser for EBNF grammars. Here is an ebnf grammar in itself and a parser for it in php.

  • You can use regular expressions for lexing.
  • Generate the calculator in Arithmetic evaluation using an EBNF description of the calculator.

Here is the parser rules taken from the antlr tutorial

expr	: term ( ( PLUS | MINUS )  term )* ;

term	: factor ( ( MULT | DIV ) factor )* ;

factor	: NUMBER ;