Skip to content

Commit 24daf6e

Browse files
authored
Merge pull request #118 from eed3si9n/wip/spec-correct
Spec-correct identifier
2 parents 6120785 + 57a0e42 commit 24daf6e

File tree

4 files changed

+187
-139
lines changed

4 files changed

+187
-139
lines changed

corpus/definitions.txt

Lines changed: 127 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,113 @@
1+
=======================================
2+
Identifiers
3+
=======================================
4+
5+
def m = ???
6+
def unary_! = true
7+
def a_-> = ???
8+
def __symtem = ???
9+
def empty_? = ???
10+
def ひらがな = ???
11+
def a_^ = ???
12+
13+
---
14+
15+
(compilation_unit
16+
(function_definition (identifier) (operator_identifier))
17+
(function_definition (identifier) (boolean_literal))
18+
(function_definition (identifier) (operator_identifier))
19+
(function_definition (identifier) (operator_identifier))
20+
(function_definition (identifier) (operator_identifier))
21+
(function_definition (identifier) (operator_identifier))
22+
(function_definition (identifier) (operator_identifier)))
23+
24+
=======================================
25+
$ in identifier names
26+
=======================================
27+
28+
class $A$B$ {
29+
val b$, c$ : Int
30+
val d$ : String
31+
}
32+
33+
---
34+
35+
(compilation_unit
36+
(class_definition
37+
(identifier)
38+
(template_body
39+
(val_declaration
40+
(identifier)
41+
(identifier)
42+
(type_identifier))
43+
(val_declaration
44+
(identifier)
45+
(type_identifier)))))
46+
47+
===================================
48+
Operator identifiers
49+
===================================
50+
51+
type ::[+Ab] = scala.collection.immutable.::[Ab]
52+
val :: = scala.collection.immutable.::
53+
54+
val +: = scala.collection.+:
55+
val :+ = scala.collection.:+
56+
57+
def → = ???
58+
59+
val test = id.##
60+
61+
---
62+
63+
(compilation_unit
64+
(type_definition
65+
(type_identifier)
66+
(type_parameters
67+
(covariant_type_parameter
68+
(identifier)))
69+
(infix_type
70+
(stable_type_identifier
71+
(stable_identifier
72+
(identifier)
73+
(identifier))
74+
(type_identifier))
75+
(operator_identifier)
76+
(generic_type
77+
(type_identifier
78+
(MISSING _alpha_identifier))
79+
(type_arguments
80+
(type_identifier)))))
81+
(val_definition
82+
(operator_identifier)
83+
(postfix_expression
84+
(field_expression
85+
(field_expression
86+
(identifier)
87+
(identifier))
88+
(identifier))
89+
(operator_identifier)))
90+
(val_definition
91+
(operator_identifier)
92+
(postfix_expression
93+
(field_expression
94+
(identifier)
95+
(identifier))
96+
(operator_identifier)))
97+
(val_definition
98+
(operator_identifier)
99+
(postfix_expression
100+
(field_expression
101+
(identifier)
102+
(identifier))
103+
(operator_identifier)))
104+
(function_definition (operator_identifier) (operator_identifier))
105+
(val_definition
106+
(identifier)
107+
(postfix_expression
108+
(identifier)
109+
(operator_identifier))))
110+
1111
================================
2112
Package
3113
================================
@@ -68,12 +178,13 @@ import reflect.io.{Directory, File, Path}
68178

69179
(compilation_unit
70180
(import_declaration
71-
(stable_identifier (identifier) (identifier)))
181+
(identifier) (identifier))
72182
(import_declaration
73-
(stable_identifier (identifier) (identifier))
74-
(stable_identifier (identifier) (identifier)))
183+
(identifier)
184+
(identifier)
185+
(identifier) (identifier))
75186
(import_declaration
76-
(stable_identifier (identifier) (identifier))
187+
(identifier) (identifier)
77188
(import_selectors (identifier) (identifier) (identifier))))
78189

79190
================================
@@ -86,21 +197,26 @@ import tools.nsc.classpath._
86197

87198
(compilation_unit
88199
(import_declaration
89-
(stable_identifier (stable_identifier (identifier) (identifier)) (identifier))
200+
(identifier) (identifier) (identifier)
90201
(import_wildcard)))
91202

92203
================================
93204
Imports: Wildcard (Scala 3 syntax)
94205
================================
95206

96207
import tools.nsc.classpath.*
208+
import a.b.*, b.c, c.*
97209

98210
---
99211

100212
(compilation_unit
101213
(import_declaration
102-
(stable_identifier (stable_identifier (identifier) (identifier)) (identifier))
103-
(import_wildcard)))
214+
(identifier) (identifier) (identifier) (import_wildcard))
215+
216+
(import_declaration
217+
(identifier) (identifier) (import_wildcard)
218+
(identifier) (identifier)
219+
(identifier) (import_wildcard)))
104220

105221
================================
106222
Imports: Wildcard and wildcard givens (Scala 3 syntax)
@@ -113,7 +229,7 @@ import tools.given
113229

114230
(compilation_unit
115231
(import_declaration
116-
(stable_identifier (stable_identifier (identifier) (identifier)) (identifier))
232+
(identifier) (identifier) (identifier)
117233
(import_selectors
118234
(import_wildcard)
119235
(import_wildcard)))
@@ -131,7 +247,7 @@ import tools.nsc.classpath.{given Test, given Test2, Test3}
131247

132248
(compilation_unit
133249
(import_declaration
134-
(stable_identifier (stable_identifier (identifier) (identifier)) (identifier))
250+
(identifier) (identifier) (identifier)
135251
(import_selectors
136252
(type_identifier)
137253
(type_identifier)
@@ -147,7 +263,7 @@ import lang.System.{lineSeparator as EOL}
147263

148264
(compilation_unit
149265
(import_declaration
150-
(stable_identifier (identifier) (identifier))
266+
(identifier) (identifier)
151267
(import_selectors (renamed_identifier (identifier) (identifier)))))
152268

153269
================================
@@ -160,7 +276,7 @@ import lang.System.{lineSeparator => EOL}
160276

161277
(compilation_unit
162278
(import_declaration
163-
(stable_identifier (identifier) (identifier))
279+
(identifier) (identifier)
164280
(import_selectors (renamed_identifier (identifier) (identifier)))))
165281

166282

@@ -368,30 +484,6 @@ class A {
368484
(identifier)
369485
(type_identifier)))))
370486

371-
=======================================
372-
$ in identifier names
373-
=======================================
374-
375-
class $A$B$ {
376-
val b$, c$ : Int
377-
val d$ : String
378-
}
379-
380-
---
381-
382-
(compilation_unit
383-
(class_definition
384-
(identifier)
385-
(template_body
386-
(val_declaration
387-
(identifier)
388-
(identifier)
389-
(type_identifier))
390-
(val_declaration
391-
(identifier)
392-
(type_identifier)))))
393-
394-
395487
=======================================
396488
Value declarations (Scala 3 syntax)
397489
=======================================
@@ -873,69 +965,6 @@ class B {
873965

874966

875967

876-
===================================
877-
Operator identifiers
878-
===================================
879-
880-
type ::[+Ab] = scala.collection.immutable.::[Ab]
881-
val :: = scala.collection.immutable.::
882-
883-
val +: = scala.collection.+:
884-
val :+ = scala.collection.:+
885-
886-
val test = id.##
887-
888-
---
889-
890-
(compilation_unit
891-
(type_definition
892-
(type_identifier)
893-
(type_parameters
894-
(covariant_type_parameter
895-
(identifier)))
896-
(infix_type
897-
(stable_type_identifier
898-
(stable_identifier
899-
(identifier)
900-
(identifier))
901-
(type_identifier))
902-
(operator_identifier)
903-
(generic_type
904-
(type_identifier
905-
(MISSING _plainid))
906-
(type_arguments
907-
(type_identifier)))))
908-
(val_definition
909-
(operator_identifier)
910-
(postfix_expression
911-
(field_expression
912-
(field_expression
913-
(identifier)
914-
(identifier))
915-
(identifier))
916-
(operator_identifier)))
917-
(val_definition
918-
(operator_identifier)
919-
(postfix_expression
920-
(field_expression
921-
(identifier)
922-
(identifier))
923-
(operator_identifier)))
924-
(val_definition
925-
(operator_identifier)
926-
(postfix_expression
927-
(field_expression
928-
(identifier)
929-
(identifier))
930-
(operator_identifier)))
931-
(val_definition
932-
(identifier)
933-
(postfix_expression
934-
(identifier)
935-
(operator_identifier))))
936-
937-
938-
939968
=======================================
940969
Inline methods and parameters (Scala 3)
941970
=======================================

corpus/types.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Stable type identifiers
55
object Main {
66
type A = B.C
77
type D = E.F.G
8+
type H = __root__.scala.Int
89
}
910

1011
---
@@ -14,6 +15,9 @@ object Main {
1415
(type_definition
1516
(type_identifier)
1617
(stable_type_identifier (identifier) (type_identifier)))
18+
(type_definition
19+
(type_identifier)
20+
(stable_type_identifier (stable_identifier (identifier) (identifier)) (type_identifier)))
1721
(type_definition
1822
(type_identifier)
1923
(stable_type_identifier (stable_identifier (identifier) (identifier)) (type_identifier))))))

0 commit comments

Comments
 (0)