aboutsummaryrefslogtreecommitdiff
path: root/grammars
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-09-13 23:31:38 -0700
committerBruce Hill <bruce@bruce-hill.com>2020-09-13 23:31:38 -0700
commit4135115229d27c54b70cd945e2211e652ab58d2f (patch)
treed81a088a3ee56b7f28252c14d2ffe2ba1d0bd7ae /grammars
parent1570dd55e8f3601e72893d6954044317973d7c60 (diff)
Spruced up a bunch of stuff, tweaked the grammar, added docs
Diffstat (limited to 'grammars')
-rw-r--r--grammars/builtins.bpeg10
-rw-r--r--grammars/html.bpeg8
2 files changed, 9 insertions, 9 deletions
diff --git a/grammars/builtins.bpeg b/grammars/builtins.bpeg
index c558c21..c871408 100644
--- a/grammars/builtins.bpeg
+++ b/grammars/builtins.bpeg
@@ -1,6 +1,6 @@
# Meta-rules for acting on everything
pattern = !(/); # Not defined by default
-replacement = {!(/)=>}; # Not defined by default
+replacement = !(/); # Not defined by default
replace-all = +(...@replacement) ...;
find-all = {... >matching-line =>} +(matching-line/non-matching-line) ?{!<\n => "\n"};
only-matches = +{...@pattern=>'@1\n'};
@@ -10,10 +10,10 @@ non-matching-line = {..$=>};
# Helper definitions (commonly used)
crlf = \r\n;
cr = \r; r = \r;
-anglebraces = `< *(anglebraces / ~~`>) `>;
-brackets = `[ *(brackets / ~~`]) `];
-braces = `{ *(braces / ~~`}) `};
-parens = `( *(parens / ~~`)) `);
+anglebraces = `< *(anglebraces / !`>.) `>;
+brackets = `[ *(brackets / !`].) `];
+braces = `{ *(braces / !`}.) `};
+parens = `( *(parens / !`).) `);
id = !<(`a-z/`A-Z/`_/`0-9) (`a-z/`A-Z/`_) *(`a-z/`A-Z/`_/`0-9);
word = !<(`a-z/`A-Z/`_/`0-9) +(`a-z/`A-Z) !>(`0-9/`_);
HEX = `0-9/`A-F;
diff --git a/grammars/html.bpeg b/grammars/html.bpeg
index 7f8976a..9d74f5e 100644
--- a/grammars/html.bpeg
+++ b/grammars/html.bpeg
@@ -11,17 +11,17 @@ html-element = (
void-element = `< @[tag](id==match-tag) __attributes__ `/? __ `>;
-template-element = `< @[tag](id==match-tag) __`> __ >match-body @[body]0+(~~`< / comment / html-element / ~~("</"tag__`>)) ("</"tag__`>);
+template-element = `< @[tag](id==match-tag) __`> __ >match-body @[body]0+(!`<$. / comment / html-element / !("</"tag__`>)$.) ("</"tag__`>);
-raw-element = `< @[tag](id==match-tag) __attributes__ `> >match-body @[body]*~~("</"tag__`>) ("</"tag__`>);
+raw-element = `< @[tag](id==match-tag) __attributes__ `> >match-body @[body].. ("</"tag__`>);
-normal-element = `< @[tag](id==match-tag) __attributes__ `> >match-body @[body]*(~~`< / comment / html-element / ~~("</"tag__`>)) "</"tag__`>;
+normal-element = `< @[tag](id==match-tag) __attributes__ `> >match-body @[body]*(!`<$. / comment / html-element / !("</"tag__`>)$.) "</"tag__`>;
comment = "<!--" &&"-->";
attributes = *(!(attribute==match-attribute))%__ __(attribute==match-attribute)__ *attribute%__;
attribute = (+id%`:)__`=__ (id / `" &`" / `' &`');
-attribute = (+id%`:)__`=__ (id / `" *~`" `" / `' *~`' `');
+attribute = (+id%`:)__`=__ (id / `" .. `" / `' .. `');
match-attribute = attribute;
match-tag = id;
match-body = (/);