예제 #1
0
 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;
 }
예제 #2
0
 private bool IsRelationalToken(Token t)
 {
     return
         t.Kind == TokenKind.LessThan ||
         t.Kind == TokenKind.LessThanOrEqual ||
         t.Kind == TokenKind.GreaterThan ||
         t.Kind == TokenKind.GreaterThanOrEqual;
 }
예제 #3
0
 private bool IsMultiplicativeToken(Token t)
 {
     return
         t.Kind == TokenKind.Multiply ||
         t.Kind == TokenKind.Divide ||
         t.Kind == TokenKind.Mod;
 }
예제 #4
0
 private bool IsPostfixToken(Token t)
 {
     return
         t.Kind == TokenKind.Increment ||
         t.Kind == TokenKind.Decrement;
 }
예제 #5
0
        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;
            }
        }
예제 #6
0
 private bool IsEqualityToken(Token t)
 {
     return t.Kind == TokenKind.Equals || t.Kind == TokenKind.NotEquals;
 }
예제 #7
0
 private bool IsAdditiveToken(Token t)
 {
     return
         t.Kind == TokenKind.Add ||
         t.Kind == TokenKind.Subtract;
 }
예제 #8
0
        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;
        }
예제 #9
0
        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);
        }
예제 #10
0
 private bool PeekToken(Token check)
 {
     return PeekToken() == check;
 }
예제 #11
0
파일: Token.cs 프로젝트: Alxandr/IronTotem
 public TokenWithSpan(Token token, IndexSpan span)
 {
     this.token = token;
     this.span = span;
 }