Parse EBNF: Difference between revisions

From Rosetta Code
Content added Content deleted
(antlr notation)
No edit summary
Line 2: Line 2:
Create a simple parser for EBNF grammars.
Create a simple parser for EBNF grammars.
[http://karmin.ch/ebnf/index Here] is an ebnf grammar in itself and a parser for it in php.
[http://karmin.ch/ebnf/index Here] is an ebnf grammar in itself and a parser for it in php.
* Use antlr notation for the ebnf grammars.
* You can use regular expressions for lexing.
* You can use regular expressions for lexing.
* Generate the calculator in [[Arithmetic evaluation]] using an EBNF description of the calculator.
* Generate the calculator in [[Arithmetic evaluation]] using an EBNF description of the calculator.

Revision as of 05:24, 12 June 2010

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 are simple parser rules for a calculator taken from the antlr tutorial

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

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

factor	: NUMBER ;