-
-
Notifications
You must be signed in to change notification settings - Fork 36
Allow name-char as first character of unquoted-literal #990
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
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 |
---|---|---|
|
@@ -735,19 +735,17 @@ escaped as `\\` and `\|`. | |
An **_<dfn>unquoted literal</dfn>_** is a _literal_ that does not require the `|` | ||
quotes around it to be distinct from the rest of the _message_ syntax. | ||
An _unquoted literal_ MAY be used when the content of the _literal_ | ||
contains no whitespace and otherwise matches the `unquoted` production. | ||
contains no whitespace and otherwise matches the `unquoted-literal` production. | ||
Implementations MUST NOT distinguish between _quoted literals_ and _unquoted literals_ | ||
that have the same sequence of code points. | ||
|
||
_Unquoted literals_ can contain a _name_ or consist of a _number-literal_. | ||
A _number-literal_ uses the same syntax as JSON and is intended for the encoding | ||
of number values in _operands_ or _options_, or as _keys_ for _variants_. | ||
_Unquoted literals_ can contain any characters also valid in _name_, | ||
less _name_'s additional restrictions on the first character. | ||
|
||
```abnf | ||
literal = quoted-literal / unquoted-literal | ||
quoted-literal = "|" *(quoted-char / escaped-char) "|" | ||
unquoted-literal = name / number-literal | ||
number-literal = ["-"] (%x30 / (%x31-39 *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT] | ||
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. Yet another step towards making everything a string :-( 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. I think that comment is a confusion about thinking that quoted literal mean string, when they are completely separate. The main syntax shouldn't talk about what format literal numbers are, or what format literal dates are, or what format literal units are; that's up to the functions. |
||
unquoted-literal = 1*name-char | ||
``` | ||
|
||
### Names and Identifiers | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ | |
"src": "{|2006-01-02T15:04:06| :datetime}" | ||
}, | ||
{ | ||
"src": "{|2006-01-02T15:04:06| :datetime year=numeric month=|2-digit|}" | ||
"src": "{|2006-01-02T15:04:06| :datetime year=numeric month=2-digit}" | ||
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. With this change the parsers now need a pretty big lookahead. Before you it was enough to look at the first character: 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. How does that change? Anywhere that literal is valid, single-character lookahead still suffices.
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. I agree with @gibson042. It is trivial to check the first character. A number literal can only start with one of 11 characters: - or 0..9. All of these are contained in
So the first character is enough to send you down the path. Of course, once you start down the path to any of these outcomes, you could end up with something bogus |
||
}, | ||
{ | ||
"src": "{|2006-01-02T15:04:06| :datetime dateStyle=long}" | ||
|
Uh oh!
There was an error while loading. Please reload this page.