Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

parsimmon/issues/296

node v10.24.1
version: 5.0.0
endpointsharetweet
const P = require("parsimmon"); const FileShape = P.regexp(/[^\n\r]+/) .sepBy(P.newline) // I think this is easier if you read all the lines at once and then process // them with an `.assert` call .assert((lines) => { console.log(lines); return lines.every((line) => line.length === 9); }) .desc("all lines are 9 characters long"); const FileContents = P.regexp(/[a-z-]+/) // Separate each line .sepBy(P.newline) // Remove the "blank" line at the end caused by trailing newlines in files .trim(P.optWhitespace); const FileParser = P.lookahead(FileShape).then(FileContents); FileParser.parse(`\ aaaa-bbbb cccc-dddd-1111 eeee-ffff gggg-hhhh `);
Nicer error message above.
FileParser.parse(`\ aaaa-bbbb cccc-ddd7 eeee-ffff gggg-hhhh `);
This error message above seems wrong. It should be an error message from `FileContents`, but we appear to be getting an error message from deep within FileShape
FileParser.parse(`\ aaaa-bbbb cccc-dddd eeee-ffff gggg-hhhh `);
This parses correctly.
Loading…

no comments

    sign in to comment