aboutsummaryrefslogtreecommitdiff
path: root/bpeg.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-09-10 03:41:03 -0700
committerBruce Hill <bruce@bruce-hill.com>2020-09-10 03:41:03 -0700
commit4e201e6a70e60d24b22ce62109b5af3d90c0a27e (patch)
tree66fe24760a34e66019b16b59444ddd606d3e009d /bpeg.c
parentaa0b8fc59168c9b86eeae311702133a0b896d2c8 (diff)
Added dashes to identifiers
Diffstat (limited to 'bpeg.c')
-rw-r--r--bpeg.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/bpeg.c b/bpeg.c
index 37018d1..b9b4232 100644
--- a/bpeg.c
+++ b/bpeg.c
@@ -702,14 +702,10 @@ static vm_op_t *compile_bpeg(const char *source, const char *str)
visualize(source, str, "Ref");
--str;
const char *refname = str;
- size_t len = 1;
- for (++str; isalnum(*str); ++str) {
- ++len;
- visualize(source, str, NULL);
- }
+ str = after_name(str);
op->op = VM_REF;
- //debug("Ref: %s\n", refname);
- op->args.s = strndup(refname, len);
+ op->len = (size_t)(str - refname);
+ op->args.s = strndup(refname, op->len);
break;
} else {
visualize(source, str, "Finished");
@@ -828,10 +824,10 @@ static void load_defs(void)
load_def("esc", "\\e"); load_def("e", "\\e");
load_def("tab", "\\t"); load_def("t", "\\t");
load_def("nl", "\\n"); load_def("lf", "\\n"); load_def("n", "\\n");
- load_def("cBlockComment", "'/*' &&'*/'");
- load_def("cLineComment", "'//' &$");
- load_def("cComment", "cLineComment / cBlockComment");
- load_def("hashComment", "`# &$");
+ load_def("c-block-comment", "'/*' &&'*/'");
+ load_def("c-line-comment", "'//' &$");
+ load_def("c-comment", "c-line-comment / c-block-comment");
+ load_def("hash-comment", "`# &$");
load_def("comment", "!(/)"); // undefined by default
load_def("WS", "` /\\t/\\n/\\r/comment");
load_def("ws", "` /\\t");
@@ -1062,8 +1058,7 @@ static vm_op_t *load_grammar(const char *grammar)
name = strndup(name, 1);
defs += 1;
} else {
- check(isalpha(*name), "Definition must begin with a name");
- while (isalnum(*defs)) ++defs;
+ defs = after_name(defs);
name = strndup(name, (size_t)(defs-name));
}
defs = after_spaces(defs);