Пример #1
0
        public Token(int start, int length, int line, TokenType type, IContext context, string quickInfo = null, Token matchingToken = null)
        {
            Start = start;
            End = start + length;
            Length = length;
            Line = line;
            Type = type;
            Context = context;
            QuickInfo = quickInfo;
            MatchingToken = matchingToken;

            switch (type)
            {
                case TokenType.Comment:
                    Classification = Classifications.Comment;
                    break;

                case TokenType.Keyword:
                    Classification = Classifications.Keyword;
                    break;

                case TokenType.Identifier:
                    Classification = Classifications.Property;
                    break;

                case TokenType.OpenBrace:
                case TokenType.OpenCurlyBrace:
                case TokenType.OpenFunctionBrace:
                case TokenType.CloseBrace:
                case TokenType.CloseCurlyBrace:
                case TokenType.CloseFunctionBrace:
                    Classification = Classifications.Operator;
                    break;
            }
        }
Пример #2
0
        public Token Add(Token token)
        {
            tokens[token.Start] = token;

            if (lines.ContainsKey(token.Line))
            {
                lines[token.Line].Add(token);
            }
            else
            {
                lines[token.Line] = new List<Token> { token };
            }

            return token;
        }
Пример #3
0
 public void Push(Token token, bool scopeChanged)
 {
     switch (token.Type)
     {
         case TokenType.OpenBrace:
             braceStack.Push(new Brace(token, scopeChanged));
             break;
         case TokenType.OpenCurlyBrace:
             curlyBraceStack.Push(new Brace(token, scopeChanged));
             break;
         case TokenType.OpenFunctionBrace:
             functionBraceStack.Push(new Brace(token, scopeChanged));
             break;
         case TokenType.OpenBracket:
             bracketStack.Push(new Brace(token, scopeChanged));
             break;
     }
 }
Пример #4
0
 public Brace(Token token, bool scopeChanged)
 {
     Token = token;
     ScopeChanged = scopeChanged;
 }