On 14/02/2018 10:32 AM, Jonathan M Davis wrote:
On Wednesday, February 14, 2018 10:14:44 Kagamin via Digitalmars-d-announce
It looks like EntityRange requires forward range, is it ok for a

It's very difficult in general to write a parser that isn't at least a
forward range, because without that, you're stuck at only one character of
look ahead unless you play a lot of games with putting data from the input
range in a buffer so that you can keep it around to look at it again after
you've looked farther ahead.

Honestly, pure input ranges are borderline useless for a _lot_ of cases.
It's generally only the cases where you only care about operating on each
element individually irrespective of what's going on with other elements in
the range that pure input ranges are really useable, and parsing definitely
doesn't fall into that camp.

- Jonathan M Davis

See lines:
- Input!IR temp = input;
- input = temp;

           bool commentLine() {
                Input!IR temp = input;

                if (!temp.empty && temp.front.c == '/') {
                        if (!temp.empty && temp.front.c == '/')
                                return false;
                } else
                        return false;

                if (!temp.empty) {
                        size_t endOffset = temp.front.location.fileOffset;

                        while(temp.front.location.lineOffset != 0) {
                                endOffset = temp.front.location.fileOffset;

                                if (temp.empty) {
                        current.type = Token.Type.Comment_Line;
                        current.location = input.front.location;
                        current.location.length = endOffset - 
                        input = temp;
                        return true;
                } else
                        return false;

Reply via email to