コード例 #1
0
 public static ParserResult CreateRule(Token token, Context context)
 {
     XElement input = token.Value;
     if (input.Attribute(REFERNCENAME) != null) {
         var resultName = input.Attribute(REFERNCENAME).Value;
         var result = context.Get<ParserResult>(resultName);
         if(result == null) throw new SyntaxException(token, string.Format("cannot find the refenerce: {0}", resultName));
         return result;
     }
     TokenInfo info = TokenInfo.Create(input, context);
     if(info != null) {
         if (token.TokenType == TokenType.RULE) {
             return CreateRule(info);
         }else if (token.TokenType == TokenType.MAPRULE) {
             return CreateMapRule(info);
         } else if (token.TokenType == TokenType.REDUCERULE) {
             return CreateReduceRule(info);
         } else {
             throw new SyntaxException(token, string.Format("error on create parse result, cannot find the rule: {0}", info.Image));
         }
     } else {
         return null;
     }
 }
コード例 #2
0
 public SyntaxException(Token source, string message)
     : this(message)
 {
     Source = source;
 }