From 282c02c47577d3ba8aaed89a62b975ed74ba44e0 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 12 Jan 2019 20:22:03 -0500 Subject: [PATCH] Update comments and text. --- README.md | 2 +- src/core/peg.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 98a93809..470457e5 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ Janet only uses Make and batch files to compile on Posix and windows respectively. To configure janet, edit the header file src/include/janet/janet.h before compilation. -### Unix-like +### macos and Unix-like On most platforms, use Make to build janet. The resulting binary will be in `build/janet`. diff --git a/src/core/peg.c b/src/core/peg.c index 2a8048d5..54e66d2c 100644 --- a/src/core/peg.c +++ b/src/core/peg.c @@ -24,9 +24,33 @@ #include #include "util.h" +/* Potential opcodes for peg vm. + * These are not yet implemented, but efficiently express the current semantics + * of the current implementation. +typedef enum { + POP_LITERAL, [len, bytes...] + POP_NCHAR, [n] + POP_RANGE, [lo | hi << 16 (1 word)] + POP_SET, [bitmap (8 words)] + POP_LOOK, [offset, rule] + POP_CHOICE, [len, rules...] + POP_SEQUENCE, [len, rules...] + POP_IFNOT, [a, b (a if not b)] + POP_NOT, [a] + POP_ATLEAST, [n, rule] + POP_BETWEEN, [lo, hi, rule] + POP_CAPTURE, [rule] + POP_POSITION, [] + POP_SUBSTITUTE, [rule] + POP_GROUP, [rule] + POP_CONSTANT, [constant] + POP_REPLACE, [constant] + POP_REPINDEX, [capture index] + POP_ARGUMENT [argument index] +} Opcode; +*/ + /* TODO - * - Capture substitution - allow substitution in captures, perhaps with a buffer in state - * that can accumulate custom data. * - Compilation - compile peg to binary form - one grammar, patterns reference each other by index * and bytecode "opcodes" identify primitive patterns and pattern "constructors". Main pattern is * pattern index 0. The logic of patterns would not change much, but we could elide arity checking,