-
-
Notifications
You must be signed in to change notification settings - Fork 35
Define the grammar as an ABNF (RFC 5234) #347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7d193e7
8c3a4e5
27edd64
ec6c07e
52fe0ca
fe29172
18ec7c1
6ffc08d
8a00351
7ef8a11
f3a73d8
ad48d07
4787729
4205cd2
517612d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,59 @@ | ||||||||||||||||||||||
message = [s] *(declaration [s]) body [s] | ||||||||||||||||||||||
|
||||||||||||||||||||||
declaration = let s variable [s] "=" [s] "{" [s] expression [s] "}" | ||||||||||||||||||||||
body = pattern | ||||||||||||||||||||||
/ (selectors 1*([s] variant)) | ||||||||||||||||||||||
Comment on lines
+1
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my comment below, I think these rules would be more readable with conventional OWS and RWS (as in "{optional,required} white space") rules, and column-aligned as in RFC 5234.
Suggested change
and so on. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we discuss using I'm against column alignment for as long as we expect the grammar to change. They generate needless diffs. Let's do it once when the grammar stabilizes. |
||||||||||||||||||||||
|
||||||||||||||||||||||
pattern = "{" *(text / placeholder) "}" | ||||||||||||||||||||||
selectors = match 1*([s] selector) | ||||||||||||||||||||||
selector = "{" [s] expression [s] "}" | ||||||||||||||||||||||
variant = when 1*(s key) [s] pattern | ||||||||||||||||||||||
key = nmtoken / literal / "*" | ||||||||||||||||||||||
Comment on lines
+7
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for suggesting this. As I said above, I'd prefer to not column-align the ABNF for now because I don't think the names of production are final and I expect the next few weeks to bring a few changes. |
||||||||||||||||||||||
|
||||||||||||||||||||||
placeholder = "{" [s] expression [s] "}" | ||||||||||||||||||||||
/ "{" [s] markup-start *(s option) [s] "}" | ||||||||||||||||||||||
/ "{" [s] markup-end [s] "}" | ||||||||||||||||||||||
|
||||||||||||||||||||||
expression = ((literal / variable) [s annotation]) | ||||||||||||||||||||||
/ annotation | ||||||||||||||||||||||
annotation = function *(s option) | ||||||||||||||||||||||
option = name [s] "=" [s] (literal / nmtoken / variable) | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the expected semantics of an option value that is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It parses as a literal, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hrm, so the value of an option is either a variable or a literal, but the literal can be implicit rather than quoted? Are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a super-subtle difference between An A There may be a "tripping hazard" here for users who can't see the difference between:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes.
As far as I recall we have not had an explicit discussion on this, but my position would be that during formatting the |
||||||||||||||||||||||
|
||||||||||||||||||||||
; reserved keywords are always lowercase | ||||||||||||||||||||||
let = %x6C.65.74 ; "let" | ||||||||||||||||||||||
match = %x6D.61.74.63.68 ; "match" | ||||||||||||||||||||||
when = %x77.68.65.6E ; "when" | ||||||||||||||||||||||
|
||||||||||||||||||||||
text = 1*(text-char / text-escape) | ||||||||||||||||||||||
text-char = %x0-5B ; omit \ | ||||||||||||||||||||||
/ %x5D-7A ; omit { | ||||||||||||||||||||||
/ %x7C ; omit } | ||||||||||||||||||||||
/ %x7E-D7FF ; omit surrogates | ||||||||||||||||||||||
/ %xE000-10FFFF | ||||||||||||||||||||||
|
||||||||||||||||||||||
literal = "(" *(literal-char / literal-escape) ")" | ||||||||||||||||||||||
literal-char = %x0-27 ; omit ( and ) | ||||||||||||||||||||||
/ %x2A-5B ; omit \ | ||||||||||||||||||||||
/ %x5D-D7FF ; omit surrogates | ||||||||||||||||||||||
/ %xE000-10FFFF | ||||||||||||||||||||||
|
||||||||||||||||||||||
variable = "$" name | ||||||||||||||||||||||
function = ":" name | ||||||||||||||||||||||
markup-start = "+" name | ||||||||||||||||||||||
markup-end = "-" name | ||||||||||||||||||||||
|
||||||||||||||||||||||
name = name-start *name-char ; matches XML https://www.w3.org/TR/xml/#NT-Name | ||||||||||||||||||||||
nmtoken = 1*name-char ; matches XML https://www.w3.org/TR/xml/#NT-Nmtokens | ||||||||||||||||||||||
name-start = ALPHA / "_" | ||||||||||||||||||||||
stasm marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
/ %xC0-D6 / %xD8-F6 / %xF8-2FF | ||||||||||||||||||||||
/ %x370-37D / %x37F-1FFF / %x200C-200D | ||||||||||||||||||||||
/ %x2070-218F / %x2C00-2FEF / %x3001-D7FF | ||||||||||||||||||||||
/ %xF900-FDCF / %xFDF0-FFFD / %x10000-EFFFF | ||||||||||||||||||||||
name-char = name-start / DIGIT / "-" / "." / %xB7 | ||||||||||||||||||||||
/ %x0300-036F / %x203F-2040 | ||||||||||||||||||||||
|
||||||||||||||||||||||
text-escape = backslash ( backslash / "{" / "}" ) | ||||||||||||||||||||||
literal-escape = backslash ( backslash / "(" / ")" ) | ||||||||||||||||||||||
backslash = %x5C ; U+005C REVERSE SOLIDUS "\" | ||||||||||||||||||||||
|
||||||||||||||||||||||
s = 1*( SP / HTAB / CR / LF ) |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.