aboutsummaryrefslogtreecommitdiff
path: root/grammars
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-09-28 15:13:54 -0700
committerBruce Hill <bruce@bruce-hill.com>2020-09-28 15:13:54 -0700
commit88571d7639d1bfa134b9b4f89ddd031b11fe8f69 (patch)
tree9cd12006b10ed1794139928b0490ceb6ca68a3eb /grammars
parent344c1b1709de522e07b97fe39afa96f46dd74515 (diff)
More intuitive escape sequences for string patterns
Diffstat (limited to 'grammars')
-rw-r--r--grammars/bpeg.bpeg3
-rw-r--r--grammars/builtins.bpeg8
2 files changed, 5 insertions, 6 deletions
diff --git a/grammars/bpeg.bpeg b/grammars/bpeg.bpeg
index 4c46c6b..f3e2f48 100644
--- a/grammars/bpeg.bpeg
+++ b/grammars/bpeg.bpeg
@@ -7,7 +7,7 @@ Def: @[name]id _ `: __ (
/ @[!]{...>(`;/id_`:/$) => "Invalid definition: @0"})
# This is used for command line arguments:
-String-pattern: 0+(`\ pat 0-1`; / .)
+String-pattern: 0+(`\ (escape-sequence / pat 0-1`;) / .)
pat: suffixed-pat / simple-pat
simple-pat: Upto-and / Dot / String / Char-range / Char / Escape-range / Escape / No
@@ -37,7 +37,6 @@ escape-sequence: (
`n/`t/`r/`e/`b/`a/`v
/ 1-3 `0-7
/ `x 2 (`0-9/`a-f/`A-F)
- / .
)
No: `! (_@pat / @[!]{=>"Expected a pattern after the exclamation mark"})
Nodent: `|
diff --git a/grammars/builtins.bpeg b/grammars/builtins.bpeg
index fd17b79..72da396 100644
--- a/grammars/builtins.bpeg
+++ b/grammars/builtins.bpeg
@@ -49,7 +49,7 @@ utf8-codepoint: (
/ \xf0-xf7 3\x80-xbf
)
crlf: \r\n
-cr: \r; r: \r
+cr: \r
anglebraces: `< 0+(anglebraces / !`>$.) `>
brackets: `[ 0+(brackets / !`]$.) `]
braces: `{ 0+(braces / !`}$.) `}
@@ -66,9 +66,9 @@ digit: `0-9
Abc: `a-z/`A-Z
ABC: `A-Z
abc: `a-z
-esc: \e; e: \e
-tab: \t; t: \t
-nl: \n; lf: \n; n: \n
+esc: \e
+tab: \t
+nl: \n; lf: \n
c-block-comment: '/*' ... '*/'
c-line-comment: '//' ..$
c-comment: c-line-comment / c-block-comment