Skip to content

Commit

Permalink
Allow identifier escapes w/o initial quote
Browse files Browse the repository at this point in the history
Fixes #656
  • Loading branch information
jclark committed Nov 28, 2020
1 parent 35dc424 commit 170f79d
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions lang/spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,14 @@ <h2 id="lexical_structure">4. Lexical structure</h2>

<pre
class="grammar">identifier := UnquotedIdentifier | QuotedIdentifier
UnquotedIdentifier :=
IdentifierInitialChar IdentifierFollowingChar*
QuotedIdentifier := <code>'</code> QuotedIdentifierChar+
QuotedIdentifierChar :=
IdentifierFollowingChar
| QuotedIdentifierEscape
| StringNumericEscape
UnquotedIdentifier := (IdentifierInitialChar | IdentifierEscape) (IdentifierFollowingChar | IdentifierEscape)*
QuotedIdentifier := <code>'</code> (IdentifierFollowingChar | IdentifierEscape)+
IdentifierInitialChar := AsciiLetter | <code>_</code> | UnicodeIdentifierChar
IdentifierFollowingChar := IdentifierInitialChar | Digit
QuotedIdentifierEscape := <code>\</code> ^ ( AsciiLetter | 0x9 | 0xA | 0xD | UnicodePatternWhiteSpaceChar )
IdentifierEscape := IdentifierSingleEscape | NumericEscape
IdentifierSingleEscape := <code>\</code> ^ ( AsciiLetter | 0x9 | 0xA | 0xD | UnicodePatternWhiteSpaceChar )
NumericEscape := <code>\u{</code> CodePoint <code>}</code>
CodePoint := HexDigit+
AsciiLetter := <code>A</code> .. <code>Z</code> | <code>a</code> .. <code>z</code>
UnicodeIdentifierChar := ^ ( AsciiChar | UnicodeNonIdentifierChar )
AsciiChar := 0x0 .. 0x7F
Expand All @@ -292,10 +290,14 @@ <h2 id="lexical_structure">4. Lexical structure</h2>
the sense that it does not change between Unicode versions.
</p>
<p>
The QuotedIdentifier syntax allows an arbitrary non-empty string to be treated
as an identifier. In particular, a reserved keyword <code><var>K</var></code>
can be used as an identifier by preceding it with a single quote i.e.
<code>'<var>K</var></code>.
The <code>QuotedIdentifier</code> syntax allows a reserved keyword
<code><var>K</var></code> can be used as an identifier by preceding it with a
single quote i.e. <code>'<var>K</var></code>. The <code>IdentifierEscape</code>
syntax allows an arbitrary non-empty string to be treated as an identifier. In a
<code>NumericEscape</code>, <code>CodePoint</code> must valid Unicode code
point; more precisely, it must be a hexadecimal numeral denoting an integer
<em>n</em> where 0 &#x2264; <em>n</em> &lt; 0xD800 or 0xDFFF &lt; n &#x2264;
0x10FFFF.
</p>

<pre
Expand Down Expand Up @@ -1153,10 +1155,8 @@ <h4>Strings</h4>
string-literal := DoubleQuotedStringLiteral
DoubleQuotedStringLiteral := <code>"</code> (StringChar | StringEscape)* <code>"</code>
StringChar := ^ ( 0xA | 0xD | <code>\</code> | <code>"</code> )
StringEscape := StringSingleEscape | StringNumericEscape
StringEscape := StringSingleEscape | NumericEscape
StringSingleEscape := <code>\t</code> | <code>\n</code> | <code>\r</code> | <code>\\</code> | <code>\"</code>
StringNumericEscape := <code>\u{</code> CodePoint <code>}</code>
CodePoint := HexDigit+
</pre>
<p>
A string is an sequence of zero or more Unicode characters. More precisely, it
Expand All @@ -1167,12 +1167,6 @@ <h4>Strings</h4>
and 0xFFFF.
</p>
<p>
In a <code>StringNumericEscape</code>, <code>CodePoint</code> must valid Unicode
code point; more precisely, it must be a hexadecimal numeral denoting an
integer <em>n</em> where 0 &#x2264; <em>n</em> &lt; 0xD800 or 0xDFFF &lt; n &#x2264;
0x10FFFF.
</p>
<p>
String values do not have storage identity and so the string basic type is
inherently immutable.
</p>
Expand Down

0 comments on commit 170f79d

Please sign in to comment.