static void Main(string[] args) { var num = (Parse.Literal("0") | Parse.Literal("1")).Select(int.Parse); var arith = Parse.Build <int>(e => e.Then(Parse.Literal("+")).Then(e).Select(x => x.Item1.Item1 + x.Item2) | e.Then(Parse.Literal("-")).Then(e).Select(x => x.Item1.Item1 - x.Item2) | num); var ans = arith.BeginParse("0+1-1+1+1+1"); }