This project has moved and is read-only. For the latest updates, please go here.

Basic grammar for parsing a simple expression like r15

Aug 3, 2013 at 7:13 AM
Edited Aug 3, 2013 at 7:14 AM
I have a simple grammar to demonstrate the problem I am having and am sure am missing something obvious but the grammar explorer keeps on throwing invalid character 'r'. Anything obvious I am doing wrong ?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Irony.Parsing;
using Irony;

namespace TestIrony
    [Language("TestIrony", "1.0", "Test grammar")]
    class TestGrammar : Grammar
        public TestGrammar()
            var program = new NonTerminal("Program");

            var instruction = new NonTerminal("Instruction");
            var R = new NonTerminal("r");
            var num = new NumberLiteral("Num");
            num.DefaultIntTypes = new TypeCode[] { TypeCode.Int32 };

            R.Rule = "r";
            instruction.Rule = R + num;
            program.Rule = instruction;
            this.Root = program;
Aug 3, 2013 at 8:23 AM
what's the sample input that fails? and what kind of expressions do you expect to parse?
Aug 3, 2013 at 8:33 AM
As I said in the title. This fails to work for the simple expression

I am mostly targeting some kind of assembly. Not any well known kinds but something internal to our company. Needless to say this project is extremely helpful.
Aug 3, 2013 at 8:36 AM
change to:
var R = ToTerm("r");
R.AllowAlphaAfterKeyword = true;

(or smth like this, there's flag on KeyTerm that allows it to be followed by alphanumeric wthout space)