public ParserResult Concat(ParserResult other)
 {
     if(!IsSuccessed || !other.IsSuccessed) return new ParserResult(false, new SyntaxException(""));
     switch(Token.Name) {
         case RegisterKeys.Rule:
             switch(other.Token.Name) {
                 case RegisterKeys.Rule:
                     return RuleAction(other);
                 case RegisterKeys.MapRule:
                     return RuleMapAction(other);
                 default:
                     return new ParserResult(false, new SyntaxException(""));
             }
         case RegisterKeys.ReduceRule:
             switch(other.Token.Name) {
                 case RegisterKeys.ReduceRule:
                     return ReduceAction(other);
                 default:
                     return new ParserResult(false, new SyntaxException(""));
             }
         case RegisterKeys.MapRule:
             switch(other.Token.Name) {
                 case RegisterKeys.MapRule:
                     return MapRuleAction(other);
                 case RegisterKeys.ReduceRule:
                     return MapReduceAction(other);
                 case RegisterKeys.ForEach:
                     return MapForEachAction(other);
                 default:
                     return new ParserResult(false, new SyntaxException(""));
             }
         default:
             return new ParserResult(false, new SyntaxException(""));
     }
 }
 private ParserResult MapRuleAction(ParserResult other)
 {
     Type source = Token.SourceType;
     Type target = other.Token.TargetType;
     var invoker = (IInvoker)Utilities.CreateType(typeof(MapGroupInvoker<,>), source, target)
                    .CreateInstance(Expression, other.Expression);
     var expr = invoker.Invoke();
     var token = new TokenInfo(RegisterKeys.MapRule, source, target);
     return new ParserResult(token, true, expr);
 }
 public static void AddResult(this Parser parser, string key, ParserResult value)
 {
     parser.Context.Set(key, value);
 }
 private ParserResult RuleAction(ParserResult other)
 {
     Type source = Token.SourceType;
     var invoker = (IInvoker)Utilities.CreateType(typeof(RuleGroupInvoker<>), source)
                    .CreateInstance(Expression, other.Expression);
     var expr = invoker.Invoke();
     var token = new TokenInfo(RegisterKeys.Rule, source, source);
     return new ParserResult(token, true, expr);
 }