Skip to content

Incorrect use of macros out of function causing infinite loop when scanning.  #1

@riz0id

Description

@riz0id

They're issues when using the read macron in this function. Possible infinite loop due to read() not incrementing pos.

Token Scanner::ScanString () {
    stringstream accum;
    char opening_char = Read (pos, source);
    while (CanAdvance (pos, 1, source)) {
        char current = Peek (pos, 1, source);
        if (current == opening_char) {
            ++pos;
            break;
        } else if (current == '\\') {
            accum << Read (pos, source);
            accum << Read (pos, source);
        } else
            accum << Read (pos, source);
    }
    cout << "String: " << accum.str () << endl;
    return Token (TokenType::String, accum.str ());
}```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions