This project is read-only.

A simple EBNF (Extended Backus-Naur Form) parser that produces an in-memory representation of a grammar defined in text.
It is also possible to define a grammar in code (similar to Irony).

User-defined EBNF grammar

The grammar defined as text in the file "Test.g":

    option = "1" | "2" ;
   root = "foo", option ;

Read the file:

   var grammar = Grammar.ReadFrom(
   File.OpenRead("Grammars/test.g"), new ParserOptions() { Root = "root" });

Representation of what the EBNF parser sees (real output):

    root' = root, "EOF" ;
   root = "foo", option ;
   option = "1" | "2"

Define grammar in code

TestGrammar.cs:

    [GrammarInfo("Test", "Robert Sundström", "A basic test grammar.")]
    public class TestGrammar : Grammar
    {
       public TestGrammar()
        {
            var root = new NonTerminal("root");
            var option = new NonTerminal("option");
            
            option.Rule = Term("1") | "2";
            root.Rule = Term("foo") | option;
            
            Root = root;
        }
    }

Where's the parser generator?

It's not ready yet. :(

Do you want to help? Don't hesitate to fork, code, commit and send as pull request!

Last edited Aug 1, 2014 at 10:52 PM by RobertSundstrom, version 21