aboutsummaryrefslogtreecommitdiff
path: root/samples/parser.js
diff options
context:
space:
mode:
authorMarvin Borner2024-11-27 02:12:12 +0100
committerMarvin Borner2024-11-27 02:27:48 +0100
commit6da602b0a29afcd2aa15725547375a80e30b3983 (patch)
treebb268dc7935696c2687c4ec151c2e0108536fa6f /samples/parser.js
initial commit
Diffstat (limited to 'samples/parser.js')
-rw-r--r--samples/parser.js13
1 files changed, 13 insertions, 0 deletions
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)))