empty parens better than empty brackets

hide-top-rule-name
Matthew Butterick 7 years ago
parent de1c42d4f9
commit 3d46506cde

@ -708,7 +708,7 @@ A @deftech{pattern} is one of the following:
@item{an explicit @deftech{sequence}: a @tech{pattern} surrounded by @litchar{(} and @litchar{)}.} @item{an explicit @deftech{sequence}: a @tech{pattern} surrounded by @litchar{(} and @litchar{)}.}
@item{the @deftech{empty set}: a special @tech{pattern} that matches a list of zero tokens. When it appears on the right side of a rule, the empty set will match empty input (which obviously contains zero tokens), but also the ``gap'' between two existing tokens (which less obviously also contains zero tokens). The empty set can be denoted by @litchar{[]} (empty square brackets), @litchar{∅} (the Unicode empty-set character), or @litchar{Ø} (the slashed O).} @item{the @deftech{empty set}: a special @tech{pattern} that matches a list of zero tokens. When it appears on the right side of a rule, the empty set will match empty input (which obviously contains zero tokens), but also the ``gap'' between two existing tokens (which less obviously also contains zero tokens). The empty set can be denoted by @litchar{()} (empty parentheses), @litchar{∅} (the Unicode empty-set character), or @litchar{Ø} (the slashed O).}
] ]

@ -1,6 +1,6 @@
#lang brag #lang brag
top : xs | ys | zs top : xs | ys | zs
xs : [] | "x" xs xs : () | "x" xs
ys : Ø | "y" /ys ys : Ø | "y" /ys
zs : | "z" @zs zs : | "z" @zs

@ -56,7 +56,7 @@
(:or (:* (:or "\\\"" esc-chars (:~ "\"" "\\"))) "\\\\") (:or (:* (:or "\\\"" esc-chars (:~ "\"" "\\"))) "\\\\")
"\"") "\"")
(token-LIT (unescape-lexeme lexeme #\"))] (token-LIT (unescape-lexeme lexeme #\"))]
[(:or "[]" "Ø" "") (token-EMPTY lexeme)] [(:or "()" "Ø" "") (token-EMPTY lexeme)]
["(" ["("
(token-LPAREN lexeme)] (token-LPAREN lexeme)]
["[" ["["

Loading…
Cancel
Save