I am trying to parse a very naive indentation-sensitive language with only two constructs (
hello the statement, and
fun a block definition).
In order to do that, I have composed the following grammar with Irony:
public class NaiveIndent : Grammar
: base(true) // CaseSensitive
var myexp = ToTerm("hello");
var fun = ToTerm("fun");
var statementList = new NonTerminal("statementList");
var statement = new NonTerminal("statement");
var block = new NonTerminal("block");
statementList.Rule = MakePlusRule(statementList, NewLineStar, statement);
statement.Rule = (myexp | block) + NewLine;
block.Rule = fun + NewLine + Indent + statementList + Dedent;
Root = statementList;
LanguageFlags = LanguageFlags.NewLineBeforeEOF;
Yet parsing the sample fails with the error
(4,3) Syntax error, expected: INDENT
Could anyone pinpoint what I am doing wrong?
Have you checked his Python sample?