I noticed after your reply to the first one that I over simplified it too much and it was not what I wanted. My issue is with the parser. The scanner is getting the correct values (in my case not the first one).
I am making something that will evaluate expressions. An expression can either be math, boolean, or string. All can use variables (names).
var name = new RegexBasedTerminal("name", [a-zA-Z][a-zA-Z0-9_]+)
var number = new RegexBasedTerminal("number", "-?[0-9]+");
var mathExpr = new NonTerminal("mathExpr");
var mathTerm = new NoNTerminal("mathTerm");
var mathFactor = new NonTermianl("mathFactor");
mathExpr.Rule = mathTerm | mathExpr + "+" + mathTerm | mathExpr + "-" + mathTerm
mathTerm.Rule = mathFactor | mathTerm + "*" + mathFacror | mathTerm + "/" + mathFacror | mathTerm + "%" + mathFacror
mathFactor.Rule = number | name | "(" + mathExpr + ")"
var literal = (I forget but there is a class factory to create C# string literals)
var strExpr = new NonTerminal("strExpr")';
//This is preferred over math if it is name + name, Irony chooses it but I would like to set in the parser
strEexpr.Rule = literal | name | name + strExpr | literal + strExpr
var test = new NonTerminal("test");
var boolExpr = new NonTermainl("boolExpr");
var boolFactor = new NonTerminal("boolFactor");
var boolTerm = new NonTerminal("boolTerm");
test.rule = boolExpr + "=" + boolExpr | numExpr + "=" + numExpr | strExpr + "=" + numExpr;
boolExpr.Rule = boolExpr + "or" + boolTerm | boolTerm;
boolTerm.Rule = boolTerm + "and" + boolFactor;
//I need a way to say true and false take precedence over name in the scanner
boolFactor.Rule = "true" | "false" | name | "(" + "boolExpr" + ")" | test
I tried writing
a or b
and it says that == is expected, it parses b as a strExpr even though that won't work and parsing it as a boolExpr would.