Skip to content

Commit 8d9bb15

Browse files
committed
[spec/lex] Optional IdentifierStart after string/numeric literal suffix
This is for dlang/dmd#15339. I have ignored the ImaginarySuffix FloatLiteral variants, as they are deprecated.
1 parent e36cd95 commit 8d9bb15

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

spec/lex.dd

+14-6
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ $(GNAME IdentifierStart):
268268
$(I Letter)
269269
$(I UniversalAlpha)
270270

271+
$(GNAME IdentifierStartError):
272+
IdentifierStart
273+
271274
$(GNAME IdentifierChar):
272275
$(GLINK IdentifierStart)
273276
$(B 0)
@@ -282,6 +285,11 @@ Identifiers can be arbitrarily long, and are case sensitive.)
282285

283286
$(IMPLEMENTATION_DEFINED Identifiers starting with $(D __) (two underscores) are reserved.)
284287

288+
$(NOTE *IdentifierStartError* exists to enforce that a $(GLINK StringPostfix)
289+
or numeric literal with a suffix is not immediately followed by an identifier
290+
without whitespace.)
291+
292+
285293
$(H2 $(LNAME2 string_literals, String Literals))
286294

287295
$(GRAMMAR
@@ -342,9 +350,9 @@ $(GNAME EscapeSequence):
342350
$(B \\) $(GLINK2 entity, NamedCharacterEntity)
343351

344352
$(GNAME StringPostfix):
345-
$(B c)
346-
$(B w)
347-
$(B d)
353+
$(B c) $(GLINK IdentifierStartError)$(OPT)
354+
$(B w) $(GLINK IdentifierStartError)$(OPT)
355+
$(B d) $(GLINK IdentifierStartError)$(OPT)
348356

349357
$(GNAME DelimitedString):
350358
$(B q") $(GLINK Delimiter) $(GLINK WysiwygCharacters)$(OPT) $(GLINK MatchingDelimiter) $(B ") $(GLINK StringPostfix)$(OPT)
@@ -625,7 +633,7 @@ $(H2 $(LNAME2 integerliteral, Integer Literals))
625633
$(GRAMMAR_LEX
626634
$(GNAME IntegerLiteral):
627635
$(GLINK Integer)
628-
$(GLINK Integer) $(GLINK IntegerSuffix)
636+
$(GLINK Integer) $(GLINK IntegerSuffix) $(GLINK IdentifierStartError)$(OPT)
629637

630638
$(GNAME Integer):
631639
$(GLINK DecimalInteger)
@@ -832,8 +840,8 @@ $(H2 $(LNAME2 floatliteral, Floating Point Literals))
832840
$(GRAMMAR_LEX
833841
$(GNAME FloatLiteral):
834842
$(GLINK Float)
835-
$(GLINK Float) $(GLINK Suffix)
836-
$(GLINK Integer) $(GLINK FloatSuffix)
843+
$(GLINK Float) $(GLINK Suffix) $(GLINK IdentifierStartError)$(OPT)
844+
$(GLINK Integer) $(GLINK FloatSuffix) $(GLINK IdentifierStartError)$(OPT)
837845
$(GLINK Integer) $(GLINK ImaginarySuffix)
838846
$(GLINK Integer) $(GLINK FloatSuffix) $(GLINK ImaginarySuffix)
839847
$(GLINK Integer) $(GLINK RealSuffix) $(GLINK ImaginarySuffix)

0 commit comments

Comments
 (0)