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/325

node v14.17.6
version: 1.0.0
endpointsharetweet
const P = require("parsimmon"); const word = P.regexp(/\S+/).desc("word"); const ws = P.whitespace; const nonkeyword = word.chain((str) => { if (str === "as" || str === "define") return P.fail(str); return P.succeed(str); }); const name = nonkeyword.sepBy1(ws); const renamedDefinition = P.seq( P.string("define").skip(ws), name.skip(ws), P.string("as").skip(ws), name ); const simpleDefinition = P.seq(P.string("define").skip(ws), name); const definition = P.alt(renamedDefinition, simpleDefinition);
definition.parse("define apple pie");
definition.parse("define apple pie as tasty dessert");
Loading…

no comments

    sign in to comment