Skip to content

Commit e89fece

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 14b0998 commit e89fece

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
@@ -328,9 +336,9 @@ $(GNAME EscapeSequence):
328336
$(B \\) $(GLINK2 entity, NamedCharacterEntity)
329337

330338
$(GNAME StringPostfix):
331-
$(B c)
332-
$(B w)
333-
$(B d)
339+
$(B c) $(GLINK IdentifierStartError)$(OPT)
340+
$(B w) $(GLINK IdentifierStartError)$(OPT)
341+
$(B d) $(GLINK IdentifierStartError)$(OPT)
334342
)
335343

336344
$(H3 $(LNAME2 wysiwyg, Wysiwyg Strings))
@@ -626,7 +634,7 @@ $(H2 $(LNAME2 integerliteral, Integer Literals))
626634
$(GRAMMAR_LEX
627635
$(GNAME IntegerLiteral):
628636
$(GLINK Integer)
629-
$(GLINK Integer) $(GLINK IntegerSuffix)
637+
$(GLINK Integer) $(GLINK IntegerSuffix) $(GLINK IdentifierStartError)$(OPT)
630638

631639
$(GNAME Integer):
632640
$(GLINK DecimalInteger)
@@ -842,9 +850,11 @@ $(H2 $(LNAME2 floatliteral, Floating Point Literals))
842850

843851
$(GRAMMAR_LEX
844852
$(GNAME FloatLiteral):
845-
$(GLINK Float) $(GLINK Suffix)$(OPT)
846-
$(GLINK Integer) $(GLINK FloatSuffix) $(GLINK ImaginarySuffix)$(OPT)
853+
$(GLINK Float)
854+
$(GLINK Float) $(GLINK Suffix) $(GLINK IdentifierStartError)$(OPT)
855+
$(GLINK Integer) $(GLINK FloatSuffix) $(GLINK IdentifierStartError)$(OPT)
847856
$(GLINK Integer) $(GLINK RealSuffix)$(OPT) $(GLINK ImaginarySuffix)
857+
$(GLINK Integer) $(GLINK FloatSuffix) $(GLINK ImaginarySuffix)
848858

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

0 commit comments

Comments
 (0)