private bool IsPrefixToken(Token t) { return t.Kind == TokenKind.Increment || t.Kind == TokenKind.Decrement || t.Kind == TokenKind.Subtract || t.Kind == TokenKind.Add || t.Kind == TokenKind.LogicalNot || t.Kind == TokenKind.KeywordAwait; }
private bool IsRelationalToken(Token t) { return t.Kind == TokenKind.LessThan || t.Kind == TokenKind.LessThanOrEqual || t.Kind == TokenKind.GreaterThan || t.Kind == TokenKind.GreaterThanOrEqual; }
private bool IsMultiplicativeToken(Token t) { return t.Kind == TokenKind.Multiply || t.Kind == TokenKind.Divide || t.Kind == TokenKind.Mod; }
private bool IsPostfixToken(Token t) { return t.Kind == TokenKind.Increment || t.Kind == TokenKind.Decrement; }
private bool IsAssignToken(Token token) { switch (token.Kind) { case TokenKind.AddEqual: case TokenKind.SubtractEqual: case TokenKind.PowerEqual: case TokenKind.MultiplyEqual: case TokenKind.DivideEqual: case TokenKind.ModEqual: case TokenKind.LeftShiftEqual: case TokenKind.RightShiftEqual: case TokenKind.BitwiseAndEqual: case TokenKind.BitwiseOrEqual: case TokenKind.ExclusiveOrEqual: case TokenKind.Assign: return true; default: return false; } }
private bool IsEqualityToken(Token t) { return t.Kind == TokenKind.Equals || t.Kind == TokenKind.NotEquals; }
private bool IsAdditiveToken(Token t) { return t.Kind == TokenKind.Add || t.Kind == TokenKind.Subtract; }
private static string GetErrorMessage(Token t, int errorCode) { string msg; if (t.Kind != TokenKind.EndOfFile) { msg = Resources.UnexpectedToken; } else { msg = "unexpected EOF while parsing"; } return msg; }
private void ReportSyntaxError(Token t, IndexSpan span, int errorCode, bool allowIncomplete) { var start = span.Start; var end = span.End; if (allowIncomplete && (t.Kind == TokenKind.EndOfFile || (_tokenizer.IsEndOfFile && t.Kind == TokenKind.NLToken))) { errorCode |= ErrorCodes.IncompleteStatement; } string msg = String.Format(System.Globalization.CultureInfo.InvariantCulture, GetErrorMessage(t, errorCode), t.Image); ReportSyntaxError(start, end, msg, errorCode); }
private bool PeekToken(Token check) { return PeekToken() == check; }
public TokenWithSpan(Token token, IndexSpan span) { this.token = token; this.span = span; }