1
- import {
1
+ import type {
2
2
CstNode as ChevrotainCstNode ,
3
3
IToken as ChevrotainIToken ,
4
4
CstNodeLocation ,
@@ -7,15 +7,10 @@ import {
7
7
8
8
export interface CstNode extends ChevrotainCstNode {
9
9
children : CstChildrenDictionary ;
10
- leadingComments ?: IToken [ ] ;
11
- trailingComments ?: IToken [ ] ;
12
- ignore ?: boolean ;
13
- location : CstNodeLocation ;
10
+ location : Required < CstNodeLocation > ;
14
11
}
15
12
16
13
export interface IToken extends ChevrotainIToken {
17
- leadingComments ?: IToken [ ] ;
18
- trailingComments ?: IToken [ ] ;
19
14
startOffset : number ;
20
15
startLine : number ;
21
16
startColumn : number ;
@@ -24,7 +19,246 @@ export interface IToken extends ChevrotainIToken {
24
19
endColumn : number ;
25
20
}
26
21
27
- export type CstElement = IToken | CstNode ;
22
+ export type CstElement =
23
+ | IToken
24
+ | AdditionalBoundCstNode
25
+ | AmbiguousNameCstNode
26
+ | AnnotationCstNode
27
+ | AnnotationInterfaceBodyCstNode
28
+ | AnnotationInterfaceDeclarationCstNode
29
+ | AnnotationInterfaceElementDeclarationCstNode
30
+ | AnnotationInterfaceElementModifierCstNode
31
+ | AnnotationInterfaceMemberDeclarationCstNode
32
+ | ArgumentListCstNode
33
+ | ArrayAccessSuffixCstNode
34
+ | ArrayCreationExpressionCstNode
35
+ | ArrayCreationExpressionWithoutInitializerSuffixCstNode
36
+ | ArrayCreationWithInitializerSuffixCstNode
37
+ | ArrayInitializerCstNode
38
+ | AssertStatementCstNode
39
+ | BasicForStatementCstNode
40
+ | BinaryExpressionCstNode
41
+ | BlockCstNode
42
+ | BlockStatementCstNode
43
+ | BlockStatementsCstNode
44
+ | BooleanLiteralCstNode
45
+ | BreakStatementCstNode
46
+ | CaseConstantCstNode
47
+ | CasePatternCstNode
48
+ | CastExpressionCstNode
49
+ | CatchClauseCstNode
50
+ | CatchesCstNode
51
+ | CatchFormalParameterCstNode
52
+ | CatchTypeCstNode
53
+ | ClassBodyCstNode
54
+ | ClassBodyDeclarationCstNode
55
+ | ClassDeclarationCstNode
56
+ | ClassExtendsCstNode
57
+ | ClassImplementsCstNode
58
+ | ClassLiteralSuffixCstNode
59
+ | ClassMemberDeclarationCstNode
60
+ | ClassModifierCstNode
61
+ | ClassOrInterfaceTypeCstNode
62
+ | ClassOrInterfaceTypeToInstantiateCstNode
63
+ | ClassPermitsCstNode
64
+ | ClassTypeCstNode
65
+ | CompactConstructorDeclarationCstNode
66
+ | CompilationUnitCstNode
67
+ | ComponentPatternCstNode
68
+ | ComponentPatternListCstNode
69
+ | ConciseLambdaParameterCstNode
70
+ | ConciseLambdaParameterListCstNode
71
+ | ConditionalExpressionCstNode
72
+ | ConstantDeclarationCstNode
73
+ | ConstantModifierCstNode
74
+ | ConstructorBodyCstNode
75
+ | ConstructorDeclarationCstNode
76
+ | ConstructorDeclaratorCstNode
77
+ | ConstructorModifierCstNode
78
+ | ContinueStatementCstNode
79
+ | DefaultValueCstNode
80
+ | DiamondCstNode
81
+ | DimExprCstNode
82
+ | DimExprsCstNode
83
+ | DimsCstNode
84
+ | DoStatementCstNode
85
+ | ElementValueArrayInitializerCstNode
86
+ | ElementValueCstNode
87
+ | ElementValueListCstNode
88
+ | ElementValuePairCstNode
89
+ | ElementValuePairListCstNode
90
+ | EmbeddedExpressionCstNode
91
+ | EmptyStatementCstNode
92
+ | EnhancedForStatementCstNode
93
+ | EnumBodyCstNode
94
+ | EnumBodyDeclarationsCstNode
95
+ | EnumConstantCstNode
96
+ | EnumConstantListCstNode
97
+ | EnumConstantModifierCstNode
98
+ | EnumDeclarationCstNode
99
+ | ExceptionTypeCstNode
100
+ | ExceptionTypeListCstNode
101
+ | ExplicitConstructorInvocationCstNode
102
+ | ExportsModuleDirectiveCstNode
103
+ | ExpressionCstNode
104
+ | ExpressionNameCstNode
105
+ | ExpressionStatementCstNode
106
+ | FieldDeclarationCstNode
107
+ | FieldModifierCstNode
108
+ | FinallyCstNode
109
+ | FloatingPointLiteralCstNode
110
+ | FloatingPointTypeCstNode
111
+ | ForInitCstNode
112
+ | FormalParameterCstNode
113
+ | FormalParameterListCstNode
114
+ | ForStatementCstNode
115
+ | ForUpdateCstNode
116
+ | FqnOrRefTypeCstNode
117
+ | FqnOrRefTypePartCommonCstNode
118
+ | FqnOrRefTypePartFirstCstNode
119
+ | FqnOrRefTypePartRestCstNode
120
+ | GuardCstNode
121
+ | IfStatementCstNode
122
+ | ImportDeclarationCstNode
123
+ | InstanceInitializerCstNode
124
+ | IntegerLiteralCstNode
125
+ | IntegralTypeCstNode
126
+ | InterfaceBodyCstNode
127
+ | InterfaceDeclarationCstNode
128
+ | InterfaceExtendsCstNode
129
+ | InterfaceMemberDeclarationCstNode
130
+ | InterfaceMethodDeclarationCstNode
131
+ | InterfaceMethodModifierCstNode
132
+ | InterfaceModifierCstNode
133
+ | InterfacePermitsCstNode
134
+ | InterfaceTypeCstNode
135
+ | InterfaceTypeListCstNode
136
+ | LabeledStatementCstNode
137
+ | LambdaBodyCstNode
138
+ | LambdaExpressionCstNode
139
+ | LambdaParameterListCstNode
140
+ | LambdaParametersCstNode
141
+ | LambdaParametersWithBracesCstNode
142
+ | LambdaParameterTypeCstNode
143
+ | LiteralCstNode
144
+ | LocalVariableDeclarationCstNode
145
+ | LocalVariableDeclarationStatementCstNode
146
+ | LocalVariableTypeCstNode
147
+ | MatchAllPatternCstNode
148
+ | MethodBodyCstNode
149
+ | MethodDeclarationCstNode
150
+ | MethodDeclaratorCstNode
151
+ | MethodHeaderCstNode
152
+ | MethodInvocationSuffixCstNode
153
+ | MethodModifierCstNode
154
+ | MethodNameCstNode
155
+ | MethodReferenceSuffixCstNode
156
+ | ModularCompilationUnitCstNode
157
+ | ModuleDeclarationCstNode
158
+ | ModuleDirectiveCstNode
159
+ | ModuleNameCstNode
160
+ | NewExpressionCstNode
161
+ | NormalClassDeclarationCstNode
162
+ | NormalInterfaceDeclarationCstNode
163
+ | NormalLambdaParameterCstNode
164
+ | NormalLambdaParameterListCstNode
165
+ | NumericTypeCstNode
166
+ | OpensModuleDirectiveCstNode
167
+ | OrdinaryCompilationUnitCstNode
168
+ | PackageDeclarationCstNode
169
+ | PackageModifierCstNode
170
+ | PackageNameCstNode
171
+ | PackageOrTypeNameCstNode
172
+ | ParenthesisExpressionCstNode
173
+ | PatternCstNode
174
+ | PrimaryCstNode
175
+ | PrimaryPrefixCstNode
176
+ | PrimarySuffixCstNode
177
+ | PrimitiveCastExpressionCstNode
178
+ | PrimitiveTypeCstNode
179
+ | ProvidesModuleDirectiveCstNode
180
+ | QualifiedExplicitConstructorInvocationCstNode
181
+ | ReceiverParameterCstNode
182
+ | RecordBodyCstNode
183
+ | RecordBodyDeclarationCstNode
184
+ | RecordComponentCstNode
185
+ | RecordComponentListCstNode
186
+ | RecordComponentModifierCstNode
187
+ | RecordDeclarationCstNode
188
+ | RecordHeaderCstNode
189
+ | RecordPatternCstNode
190
+ | ReferenceTypeCastExpressionCstNode
191
+ | ReferenceTypeCstNode
192
+ | RegularLambdaParameterCstNode
193
+ | RequiresModifierCstNode
194
+ | RequiresModuleDirectiveCstNode
195
+ | ResourceCstNode
196
+ | ResourceListCstNode
197
+ | ResourceSpecificationCstNode
198
+ | ResultCstNode
199
+ | ReturnStatementCstNode
200
+ | ShiftOperatorCstNode
201
+ | SimpleTypeNameCstNode
202
+ | StatementCstNode
203
+ | StatementExpressionCstNode
204
+ | StatementExpressionListCstNode
205
+ | StatementWithoutTrailingSubstatementCstNode
206
+ | StaticInitializerCstNode
207
+ | StringTemplateCstNode
208
+ | SwitchBlockCstNode
209
+ | SwitchBlockStatementGroupCstNode
210
+ | SwitchLabelCstNode
211
+ | SwitchRuleCstNode
212
+ | SwitchStatementCstNode
213
+ | SynchronizedStatementCstNode
214
+ | TemplateArgumentCstNode
215
+ | TemplateCstNode
216
+ | TextBlockTemplateCstNode
217
+ | ThrowsCstNode
218
+ | ThrowStatementCstNode
219
+ | TryStatementCstNode
220
+ | TryWithResourcesStatementCstNode
221
+ | TypeArgumentCstNode
222
+ | TypeArgumentListCstNode
223
+ | TypeArgumentsCstNode
224
+ | TypeArgumentsOrDiamondCstNode
225
+ | TypeBoundCstNode
226
+ | TypeDeclarationCstNode
227
+ | TypeIdentifierCstNode
228
+ | TypeNameCstNode
229
+ | TypeParameterCstNode
230
+ | TypeParameterListCstNode
231
+ | TypeParameterModifierCstNode
232
+ | TypeParametersCstNode
233
+ | TypePatternCstNode
234
+ | TypeVariableCstNode
235
+ | UnannClassOrInterfaceTypeCstNode
236
+ | UnannClassTypeCstNode
237
+ | UnannInterfaceTypeCstNode
238
+ | UnannPrimitiveTypeCstNode
239
+ | UnannPrimitiveTypeWithOptionalDimsSuffixCstNode
240
+ | UnannReferenceTypeCstNode
241
+ | UnannTypeCstNode
242
+ | UnannTypeVariableCstNode
243
+ | UnaryExpressionCstNode
244
+ | UnaryExpressionNotPlusMinusCstNode
245
+ | UnqualifiedClassInstanceCreationExpressionCstNode
246
+ | UnqualifiedExplicitConstructorInvocationCstNode
247
+ | UsesModuleDirectiveCstNode
248
+ | VariableAccessCstNode
249
+ | VariableArityParameterCstNode
250
+ | VariableArityRecordComponentCstNode
251
+ | VariableDeclaratorCstNode
252
+ | VariableDeclaratorIdCstNode
253
+ | VariableDeclaratorListCstNode
254
+ | VariableInitializerCstNode
255
+ | VariableInitializerListCstNode
256
+ | VariableModifierCstNode
257
+ | VariableParaRegularParameterCstNode
258
+ | WhileStatementCstNode
259
+ | WildcardBoundsCstNode
260
+ | WildcardCstNode
261
+ | YieldStatementCstNode ;
28
262
29
263
export declare type CstChildrenDictionary = {
30
264
[ identifier : string ] : CstElement [ ] ;
@@ -38,7 +272,10 @@ export function lexAndParse(
38
272
cst : CstNode ;
39
273
} ;
40
274
41
- export function parse ( text : string , startProduction ?: string ) : CstNode ;
275
+ export function parse (
276
+ text : string ,
277
+ startProduction ?: string
278
+ ) : CstNode & { comments ?: IToken [ ] } ;
42
279
43
280
export const BaseJavaCstVisitor : JavaCstVisitorConstructor < any , any > ;
44
281
export const BaseJavaCstVisitorWithDefaults : JavaCstVisitorWithDefaultsConstructor <
@@ -57,6 +294,7 @@ export abstract class JavaCstVisitor<IN, OUT> implements ICstVisitor<IN, OUT> {
57
294
integerLiteral ( ctx : IntegerLiteralCtx , param ?: IN ) : OUT ;
58
295
floatingPointLiteral ( ctx : FloatingPointLiteralCtx , param ?: IN ) : OUT ;
59
296
booleanLiteral ( ctx : BooleanLiteralCtx , param ?: IN ) : OUT ;
297
+ shiftOperator ( cts : ShiftOperatorCtx , param ?: IN ) : OUT ;
60
298
primitiveType ( ctx : PrimitiveTypeCtx , param ?: IN ) : OUT ;
61
299
numericType ( ctx : NumericTypeCtx , param ?: IN ) : OUT ;
62
300
integralType ( ctx : IntegralTypeCtx , param ?: IN ) : OUT ;
@@ -300,7 +538,7 @@ export abstract class JavaCstVisitor<IN, OUT> implements ICstVisitor<IN, OUT> {
300
538
param ?: IN
301
539
) : OUT ;
302
540
normalLambdaParameterList ( ctx : NormalLambdaParameterListCtx , param ?: IN ) : OUT ;
303
- normalLambdaParameter ( ctx : LambdaParameterCtx , param ?: IN ) : OUT ;
541
+ normalLambdaParameter ( ctx : NormalLambdaParameterCtx , param ?: IN ) : OUT ;
304
542
regularLambdaParameter ( ctx : RegularLambdaParameterCtx , param ?: IN ) : OUT ;
305
543
lambdaParameterType ( ctx : LambdaParameterTypeCtx , param ?: IN ) : OUT ;
306
544
conciseLambdaParameter ( ctx : ConciseLambdaParameterCtx , param ?: IN ) : OUT ;
@@ -385,6 +623,7 @@ export abstract class JavaCstVisitorWithDefaults<IN, OUT>
385
623
integerLiteral ( ctx : IntegerLiteralCtx , param ?: IN ) : OUT ;
386
624
floatingPointLiteral ( ctx : FloatingPointLiteralCtx , param ?: IN ) : OUT ;
387
625
booleanLiteral ( ctx : BooleanLiteralCtx , param ?: IN ) : OUT ;
626
+ shiftOperator ( cts : ShiftOperatorCtx , param ?: IN ) : OUT ;
388
627
primitiveType ( ctx : PrimitiveTypeCtx , param ?: IN ) : OUT ;
389
628
numericType ( ctx : NumericTypeCtx , param ?: IN ) : OUT ;
390
629
integralType ( ctx : IntegralTypeCtx , param ?: IN ) : OUT ;
@@ -628,7 +867,7 @@ export abstract class JavaCstVisitorWithDefaults<IN, OUT>
628
867
param ?: IN
629
868
) : OUT ;
630
869
normalLambdaParameterList ( ctx : NormalLambdaParameterListCtx , param ?: IN ) : OUT ;
631
- normalLambdaParameter ( ctx : LambdaParameterCtx , param ?: IN ) : OUT ;
870
+ normalLambdaParameter ( ctx : NormalLambdaParameterCtx , param ?: IN ) : OUT ;
632
871
regularLambdaParameter ( ctx : RegularLambdaParameterCtx , param ?: IN ) : OUT ;
633
872
lambdaParameterType ( ctx : LambdaParameterTypeCtx , param ?: IN ) : OUT ;
634
873
conciseLambdaParameter ( ctx : ConciseLambdaParameterCtx , param ?: IN ) : OUT ;
@@ -755,6 +994,16 @@ export type BooleanLiteralCtx = {
755
994
False ?: IToken [ ] ;
756
995
} ;
757
996
997
+ export interface ShiftOperatorCstNode extends CstNode {
998
+ name : "shiftOperator" ;
999
+ children : ShiftOperatorCtx ;
1000
+ }
1001
+
1002
+ export type ShiftOperatorCtx = {
1003
+ Less ?: IToken [ ] ;
1004
+ Greater ?: IToken [ ] ;
1005
+ } ;
1006
+
758
1007
export interface PrimitiveTypeCstNode extends CstNode {
759
1008
name : "primitiveType" ;
760
1009
children : PrimitiveTypeCtx ;
@@ -1801,17 +2050,16 @@ export interface CompilationUnitCstNode extends CstNode {
1801
2050
1802
2051
export type AbstractOrdinaryCompilationUnitCtx = {
1803
2052
ordinaryCompilationUnit : OrdinaryCompilationUnitCstNode [ ] ;
1804
- EOF : IToken [ ] ;
1805
2053
} ;
1806
2054
1807
2055
export type AbstractModularCompilationUnitCtx = {
1808
2056
modularCompilationUnit : OrdinaryCompilationUnitCstNode [ ] ;
1809
- EOF : IToken [ ] ;
1810
2057
} ;
1811
2058
1812
2059
export type CompilationUnitCtx =
1813
2060
| AbstractOrdinaryCompilationUnitCtx
1814
- | AbstractModularCompilationUnitCtx ;
2061
+ | AbstractModularCompilationUnitCtx
2062
+ | { EOF : IToken [ ] } ;
1815
2063
1816
2064
export interface OrdinaryCompilationUnitCstNode extends CstNode {
1817
2065
name : "ordinaryCompilationUnit" ;
@@ -2894,10 +3142,10 @@ export type NormalLambdaParameterListCtx = {
2894
3142
2895
3143
export interface NormalLambdaParameterCstNode extends CstNode {
2896
3144
name : "normalLambdaParameter" ;
2897
- children : LambdaParameterCtx ;
3145
+ children : NormalLambdaParameterCtx ;
2898
3146
}
2899
3147
2900
- export type LambdaParameterCtx = {
3148
+ export type NormalLambdaParameterCtx = {
2901
3149
regularLambdaParameter ?: RegularLambdaParameterCstNode [ ] ;
2902
3150
variableArityParameter ?: VariableArityParameterCstNode [ ] ;
2903
3151
} ;
@@ -2967,8 +3215,7 @@ export type BinaryExpressionCtx = {
2967
3215
referenceType ?: ReferenceTypeCstNode [ ] ;
2968
3216
AssignmentOperator ?: IToken [ ] ;
2969
3217
expression ?: ExpressionCstNode [ ] ;
2970
- Less ?: IToken [ ] ;
2971
- Greater ?: IToken [ ] ;
3218
+ shiftOperator ?: ShiftOperatorCstNode [ ] ;
2972
3219
BinaryOperator ?: IToken [ ] ;
2973
3220
} ;
2974
3221
0 commit comments