Skip to content

Possible EOF tracking issue #13

@evantrimboli

Description

@evantrimboli

Consider the following code sample:

export const fnName1 = P.matchWhile((c) => c === 'S' || c === 'U' || c === 'M');

export const fnName2 = P.str('SUM');

export const fnName3 = P.pipe<CU.CharStream[], CU.CharStream>(P.many1(P.letter))(CU.CharStream.concat);

// Test with full execution
const nameAndParen = P.left<CU.CharStream, CU.CharStream>(fnName1)(P.char('('));

const parser = P.seq(nameAndParen)(P.eof);

const input = new CU.CharStream('SUM(');
console.log('initial hasEOF', input.hasEOF);
const nameTest = parser(input);
let result = nameTest.next();
if (result.done) {
  console.log('final', result.value);
}

When using fnName1, the parse fails because it doesn't reach EOF. When using fnName2 or fnName3 it succeeds.

Is this an incorrect way to match?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions