public string GetShownString(Token tk) { if (tk == null) { return ""; } switch (tk.Type) { case TokenType.Condition: return "条件"; case TokenType.DT: return "小数处理"; case TokenType.Fixed: return "内(" + GetFixItemName(tk.Value.ToString()) + ")"; case TokenType.Id: return GetPRItemName(tk.Value.ToString()); case TokenType.NE: return "≠"; case TokenType.Sum: return "求和"; case TokenType.SumFlag: return GetSumFlagName(tk.Value.ToString()); default: return tk.ToString(); } }
public ConSyntaxTreeNode(Token t) : base(t) { }
public SumSyntaxTreeNode(Token t, ICalcFunction icalc) : base(t) { this.icalc = icalc; }
public SumFlagSyntaxTreeNode(Token t) : base(t) { }
public OpSyntaxTreeNode(Token t) : base(t) { }
public NumSynTaxTreeNode(Token t) : base(t) { }
public SyntaxTreeNode(Token t) { tk = t; children = new List<SyntaxTreeNode>(); }
/// <summary> /// 分析表达式,生成token、列表和语法树。 /// </summary> public void Parse() { tree = null; curTok = scanner.GetToken(); if (null == CurToken) { return; } tree = Exp(); if (CurToken != null) { throw new ParseException("unexpected token:", CurToken); } }
private void MatchToken(TokenType expected) { if (CurToken.Type == expected) { curTok = scanner.GetToken(); } else { throw new ParseException("unexpected token:", CurToken); } }
public ParseException(string message) : base(message) { occuToken = null; }
public ParseException(string message, Token tk) : base(message) { occuToken = tk; }
public ParseException(string message, Token tk, Exception inner) : base(message, inner) { occuToken = tk; }
public ParseException(string message, Exception inner) : base(message, inner) { occuToken = null; }
public Token(Token t) { tktppe = t.tktppe; value = t.value; }
public TokenEx(Token t, string shown) : base(t) { this.shown = shown; }