Example #1
0
 public abstract bool Get(TextBuffer text_buffer);
Example #2
0
 public override bool Get(TextBuffer text_buffer)
 {
     return(true);
 }
Example #3
0
        public override bool Get(TextBuffer text_buffer)
        {
            char ch = text_buffer.Char();

            switch (ch)
            {
            case '+':
                m_type = TokenType.PLUS;
                text_buffer.NextChar();
                break;

            case '-':
                m_type = TokenType.MINUS;
                text_buffer.NextChar();
                break;

            case '*':
                m_type = TokenType.STAR;
                text_buffer.NextChar();
                break;

            case '/':
                m_type = TokenType.SLASH;
                text_buffer.NextChar();
                break;

            case '(':
                m_type = TokenType.LEFT_PAREN;
                text_buffer.NextChar();
                break;

            case ')':
                m_type = TokenType.RIGHT_PAREN;
                text_buffer.NextChar();
                break;

            case '[':
                m_type = TokenType.LEFT_BRACKET;
                text_buffer.NextChar();
                break;

            case ']':
                m_type = TokenType.RIGHT_BRACKET;
                text_buffer.NextChar();
                break;

            case '.':
                m_type = TokenType.PERIOD;
                text_buffer.NextChar();
                break;

            case ',':
                m_type = TokenType.COMMA;
                text_buffer.NextChar();
                break;

            case '?':
                m_type = TokenType.QUESTION;
                text_buffer.NextChar();
                break;

            case ':':
                m_type = TokenType.SEMICOLON;
                text_buffer.NextChar();
                break;

            case '=':
                m_type = TokenType.EQUAL;
                ch     = text_buffer.NextChar();
                if (ch == '=')
                {
                    m_type = TokenType.EQUAL_EQUAL;
                    text_buffer.NextChar();
                }
                break;

            case '!':
                m_type = TokenType.NOT;
                ch     = text_buffer.NextChar();
                if (ch == '=')
                {
                    m_type = TokenType.NOT_EQUAL;
                    text_buffer.NextChar();
                }
                break;

            case '>':
                m_type = TokenType.GREATER;
                ch     = text_buffer.NextChar();
                if (ch == '=')
                {
                    m_type = TokenType.GREATER_EQUAL;
                    text_buffer.NextChar();
                }
                break;

            case '<':
                m_type = TokenType.LESS;
                ch     = text_buffer.NextChar();
                if (ch == '=')
                {
                    m_type = TokenType.LESS_EQUAL;
                    text_buffer.NextChar();
                }
                break;

            case '&':
                m_type = TokenType.AND_BITWISE;
                ch     = text_buffer.NextChar();
                if (ch == '&')
                {
                    m_type = TokenType.AND;
                    text_buffer.NextChar();
                }
                break;

            case '|':
                m_type = TokenType.OR_BITWISE;
                ch     = text_buffer.NextChar();
                if (ch == '|')
                {
                    m_type = TokenType.OR;
                    text_buffer.NextChar();
                }
                break;

            default:
                LogWrapper.LogError("Expression: SymbolToken.Get(), illegal symbol, index = ", text_buffer.CurrentIndex, ", char = ", text_buffer.Char());
                m_type = TokenType.ERROR;
                return(false);
            }
            return(true);
        }