Skip to content

Comparative Symbols #1

Description

@csharpworker

to detect Comparative symbols ( < , > , != , <= , >= , <> ) just add this lines for ReadSymbol() method

            case '!':
            case '<':
            case '>':
                this.buffer.Append(currentChar);
                this.ReadNextChar();

                if (currentChar == '=' || currentChar == '>')
                {
                    this.buffer.Append(currentChar);
                    this.ReadNextChar();
                }

                var nottoken = new Token { Value = this.buffer.ToString(), Type = TokenType.Symbol };
                this.buffer.Clear();
                return nottoken;

by completed method:

private Token ReadSymbol()
    {
        switch (currentChar)
        {
            case '+':
            case '-':
            case '*':
            case '/':
            case '^':
            case '(':
            case ')':
            case '[':
            case ']':
            case ';':
            case ':':
            case '=':
            case '.':
            case ',':
                var token = new Token { Value = currentChar.ToString(), Type = TokenType.Symbol };
                this.buffer.Clear();
                this.ReadNextChar();
                return token;
            case '!':
            case '<':
            case '>':
                this.buffer.Append(currentChar);
                this.ReadNextChar();

                if (currentChar == '=' || currentChar == '>')
                {
                    this.buffer.Append(currentChar);
                    this.ReadNextChar();
                }

                var nottoken = new Token { Value = this.buffer.ToString(), Type = TokenType.Symbol };
                this.buffer.Clear();
                return nottoken;
            default:
                this.ReadNextChar();
                break;
        }

        return null;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions