diff options
Diffstat (limited to 'samples/parser.js')
-rw-r--r-- | samples/parser.js | 13 |
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))) |