picoe / Eto.Parse

Recursive descent LL(k) parser for .NET with Fluent API, BNF, EBNF and Gold Grammars
MIT License
148 stars 30 forks source link

Gold Grammar Sample not working #21

Open mywyb2 opened 9 years ago

mywyb2 commented 9 years ago

I tried the sample from http://goldparser.org/doc/grammars/, but this gives me a KeyNotFoundException:

            var grammar = new GoldGrammar().Build(@"
Id = {Letter}{AlphaNumeric}*

<Statement> ::= if Id then <Statement>
              | if Id then <Then Stm> else <Statement>
              | Id ':=' Id

<Then Stm>  ::= if Id then <Then Stm> else <Then Stm>
              | Id ':=' Id
");
cwensley commented 9 years ago

That looks like an incomplete grammar. You are required to include the "Start Symbol" property. E.g.

"Start Symbol" = <Statement>

See http://goldparser.org/doc/grammars/define-properties.htm for a list of gold grammar properties

mywyb2 commented 9 years ago

Thanks, I didn't know that. However, after adding the required line, I still get the same KeyNotFoundException. I also tried the "Simple" grammar from http://www.goldparser.org/grammars/index.htm - again the same error.