public const char InverseOne = (char)255; // -1 public static string KindToString(ExprTokenKind kind) { string result; KindToStringValues.TryGetValue(kind, out result); return(result ?? String.Empty); }
public void Expected(ExprTokenKind wanted) { Kind = ExprTokenKind.ERROR; if (wanted == ExprTokenKind.ERROR || wanted == ExprTokenKind.UNKNOWN) { throw new ParseError(String.Format(ParseError.ParseError_InvalidToken, this)); } else { throw new ParseError(String.Format(ParseError.ParseError_InvalidTokenWanted, this, wanted)); } }
public void Unexpected(char wanted) { ExprTokenKind prevKind = Kind; Kind = ExprTokenKind.ERROR; if (wanted == default(char)) { switch (prevKind) { case ExprTokenKind.TOK_EOF: throw new ParseError(ParseError.ParseError_UnexpectedEndOfExpression); case ExprTokenKind.IDENT: throw new ParseError(String.Format(ParseError.ParseError_UnexpectedSymbol, Value)); case ExprTokenKind.VALUE: throw new ParseError(String.Format(ParseError.ParseError_UnexpectedValue, Value)); default: throw new ParseError(String.Format(ParseError.ParseError_UnexpectedExpressionToken, Symbol)); } } else { switch (prevKind) { case ExprTokenKind.TOK_EOF: throw new ParseError(String.Format(ParseError.ParseError_UnexpectedEndOfExpressionWanted, wanted)); case ExprTokenKind.IDENT: throw new ParseError(String.Format(ParseError.ParseError_UnexpectedSymbolWanted, Value, wanted)); case ExprTokenKind.VALUE: throw new ParseError(String.Format(ParseError.ParseError_UnexpectedValueWanted, Value, wanted)); default: throw new ParseError(String.Format(ParseError.ParseError_UnexpectedExpressionTokenWanted, Symbol, wanted)); } } }
public ExprToken(ExprTokenKind kind, Value value) : this() { Kind = kind; Value = value; }
private void ReadAndCheckTokenProps(Func <int> act, ref ExprToken token, InputTextStream inStream, int expectedResult, ExprTokenKind expectedKind, int expectedLength, Value expectedValue, string expectedSymbol) { inStream.PeekNextNonWS(); token.Clear(); int result = act(); Assert.Equal(expectedResult, result); Assert.Equal(expectedKind, token.Kind); Assert.Equal(expectedLength, token.Length); Assert.True(expectedValue.IsEqualTo(token.Value)); Assert.Equal(expectedSymbol, token.Symbol); }