Skip to content

Commit 4b27269

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 1549905 commit 4b27269

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

spec/lex.dd

+16-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)
@@ -841,9 +849,11 @@ $(H2 $(LNAME2 floatliteral, Floating Point Literals))
841849

842850
$(GRAMMAR_LEX
843851
$(GNAME FloatLiteral):
844-
$(GLINK Float) $(GLINK Suffix)$(OPT)
845-
$(GLINK Integer) $(GLINK FloatSuffix) $(GLINK ImaginarySuffix)$(OPT)
852+
$(GLINK Float)
853+
$(GLINK Float) $(GLINK Suffix) $(GLINK IdentifierStartError)$(OPT)
854+
$(GLINK Integer) $(GLINK FloatSuffix) $(GLINK IdentifierStartError)$(OPT)
846855
$(GLINK Integer) $(GLINK RealSuffix)$(OPT) $(GLINK ImaginarySuffix)
856+
$(GLINK Integer) $(GLINK FloatSuffix) $(GLINK ImaginarySuffix)
847857

848858
$(GNAME Float):
849859
$(GLINK DecimalFloat)

0 commit comments

Comments
 (0)