public static void Push(this Stack<Token> stack, TokenType tokenType, string value) { var token = new Token { TokenType = tokenType, Value = value }; stack.Push(token); }
public bool TryConsume(ref string text, out Token token) { var result = false; token = null; var match = _startsWithExpresion.Match(text); if (match.Success) { var matchedText = match.Groups.Cast<Group>().Single().Value; text = text.Substring(matchedText.Length); token = new Token { TokenType = TokenType, Value = matchedText }; result = true; } return result; }