public Token GetToken(OpenExcel.Common.FormulaParser.TokenType type) { return(new Token(this.StartPos, this.EndPos) { Type = type }); }
public Token(int start, int end) { this.Type = OpenExcel.Common.FormulaParser.TokenType._UNDETERMINED_; this.startpos = start; this.endpos = end; this.Text = ""; this.Value = null; }
public Token LookAhead(params OpenExcel.Common.FormulaParser.TokenType[] expectedtokens) { List <OpenExcel.Common.FormulaParser.TokenType> tokens; int startPos = this.StartPos; Token item = null; if (((this.LookAheadToken != null) && (this.LookAheadToken.Type != OpenExcel.Common.FormulaParser.TokenType._UNDETERMINED_)) && (this.LookAheadToken.Type != OpenExcel.Common.FormulaParser.TokenType._NONE_)) { return(this.LookAheadToken); } if (expectedtokens.Length == 0) { tokens = this.Tokens; } else { tokens = new List <OpenExcel.Common.FormulaParser.TokenType>(expectedtokens); tokens.AddRange(this.SkipList); } do { int length = -1; OpenExcel.Common.FormulaParser.TokenType type = (OpenExcel.Common.FormulaParser.TokenType) 0x7fffffff; string input = this.Input.Substring(startPos); item = new Token(startPos, this.EndPos); for (int i = 0; i < tokens.Count; i++) { Match match = this.Patterns[tokens[i]].Match(input); if ((match.Success && (match.Index == 0)) && ((match.Length > length) || ((((OpenExcel.Common.FormulaParser.TokenType)tokens[i]) < type) && (match.Length == length)))) { length = match.Length; type = tokens[i]; } } if ((type >= OpenExcel.Common.FormulaParser.TokenType._NONE_) && (length >= 0)) { item.EndPos = startPos + length; item.Text = this.Input.Substring(item.StartPos, length); item.Type = type; } else if (item.StartPos < (item.EndPos - 1)) { item.Text = this.Input.Substring(item.StartPos, 1); } if (this.SkipList.Contains(item.Type)) { startPos = item.EndPos; this.Skipped.Add(item); } }while (this.SkipList.Contains(item.Type)); this.LookAheadToken = item; return(item); }
protected object GetValue(ParseTree tree, OpenExcel.Common.FormulaParser.TokenType type, ref int index) { if (index >= 0) { foreach (ParseNode node in this.nodes) { if (node.Token.Type == type) { index--; if (index < 0) { return(node.Eval(tree, new object[0])); } } } } return(null); }
protected object GetValue(ParseTree tree, OpenExcel.Common.FormulaParser.TokenType type, int index) { return(this.GetValue(tree, type, ref index)); }