From 6da602b0a29afcd2aa15725547375a80e30b3983 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 27 Nov 2024 02:12:12 +0100 Subject: initial commit --- samples/parser.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 samples/parser.js (limited to 'samples/parser.js') diff --git a/samples/parser.js b/samples/parser.js new file mode 100644 index 0000000..80d4aaa --- /dev/null +++ b/samples/parser.js @@ -0,0 +1,13 @@ +import * as parser from "../src/parser.js" +import * as fs from "fs" + +// try piping "Hello, World" into stdin! +const input = fs.readFileSync(0, "utf-8"); + +const parse = parser.DO(function* () { + const p = yield parser.string("Hello") + yield parser.char(',') + yield parser.char(' ') + return p +}) +console.log(parser.show(parse(input))) -- cgit v1.2.3