Skip to content

Commit a53efd6

Browse files
authored
Merge pull request #1652 from ehuss/2024-unprefixed-guarded-strings
2024: Add reserved syntax
2 parents 3b28797 + 35ee2a9 commit a53efd6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/tokens.md

+22
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,31 @@ r[lex.token.reserved-prefix.edition2021]
913913
> lexes!{'prefix#lt}
914914
> ```
915915
916+
## Reserved guards
917+
918+
r[lex.token.reserved-guards]
919+
920+
r[lex.token.reserved-guards.syntax]
921+
> **<sup>Lexer 2024+</sup>**\
922+
> RESERVED_GUARDED_STRING_LITERAL : `#`<sup>+</sup> [STRING_LITERAL]\
923+
> RESERVED_POUNDS : `#`<sup>2..</sup>
924+
925+
r[lex.token.reserved-guards.intro]
926+
The reserved guards are syntax reserved for future use, and will generate a compile error if used.
927+
928+
r[lex.token.reserved-guards.string-literal]
929+
The *reserved guarded string literal* is a token of one or more `U+0023` (`#`) immediately followed by a [STRING_LITERAL].
930+
931+
r[lex.token.reserved-guards.pounds]
932+
The *reserved pounds* is a token of two or more `U+0023` (`#`).
933+
934+
r[lex.token.reserved-guards.edition2024]
935+
> **Edition differences**: Before the 2024 edition, reserved guards are accepted by the lexer and interpreted as multiple tokens. For example, the `#"foo"#` form is interpreted as three tokens. `##` is interpreted as two tokens.
936+
916937
[Inferred types]: types/inferred.md
917938
[Range patterns]: patterns.md#range-patterns
918939
[Reference patterns]: patterns.md#reference-patterns
940+
[STRING_LITERAL]: tokens.md#string-literals
919941
[Subpattern binding]: patterns.md#identifier-patterns
920942
[Wildcard patterns]: patterns.md#wildcard-pattern
921943
[arith]: expressions/operator-expr.md#arithmetic-and-logical-binary-operators

0 commit comments

Comments
 (0)