forked from uwol/proleap-vb6-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisualBasic6.g4
More file actions
executable file
·2226 lines (1568 loc) · 31 KB
/
VisualBasic6.g4
File metadata and controls
executable file
·2226 lines (1568 loc) · 31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2017, Ulrich Wolffgang <ulrich.wolffgang@proleap.io>
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/*
* Visual Basic 6.0 Grammar for ANTLR4
*
* This is a Visual Basic 6.0 grammar, which is part of the Visual Basic 6.0
* parser at https://github.com/uwol/proleap-vb6-parser.
*
* The grammar is derived from the Visual Basic 6.0 language reference
* http://msdn.microsoft.com/en-us/library/aa338033%28v=vs.60%29.aspx
* and has been tested with MSDN VB6 statements as well as several Visual
* Basic 6.0 code repositories.
*/
grammar VisualBasic6;
// module ----------------------------------
startRule
: module EOF
;
module
: WS? NEWLINE* (moduleHeader NEWLINE +)? moduleReferences? NEWLINE* controlProperties? NEWLINE* moduleConfig? NEWLINE* moduleAttributes? NEWLINE* moduleOptions? NEWLINE* moduleBody? NEWLINE* WS?
;
moduleReferences
: moduleReference+
;
moduleReference
: OBJECT WS? EQ WS? moduleReferenceValue (SEMICOLON WS? moduleReferenceComponent)? NEWLINE*
;
moduleReferenceValue
: STRINGLITERAL
;
moduleReferenceComponent
: STRINGLITERAL
;
moduleHeader
: VERSION WS DOUBLELITERAL (WS CLASS)?
;
moduleConfig
: BEGIN NEWLINE + moduleConfigElement + END NEWLINE +
;
moduleConfigElement
: ambiguousIdentifier WS? EQ WS? literal NEWLINE
;
moduleAttributes
: (attributeStmt NEWLINE +) +
;
moduleOptions
: (moduleOption NEWLINE +) +
;
moduleOption
: OPTION_BASE WS INTEGERLITERAL # optionBaseStmt
| OPTION_COMPARE WS (BINARY | TEXT) # optionCompareStmt
| OPTION_EXPLICIT # optionExplicitStmt
| OPTION_PRIVATE_MODULE # optionPrivateModuleStmt
;
moduleBody
: moduleBodyElement (NEWLINE + moduleBodyElement)*
;
moduleBodyElement
: moduleBlock
| moduleOption
| declareStmt
| enumerationStmt
| eventStmt
| functionStmt
| macroIfThenElseStmt
| propertyGetStmt
| propertySetStmt
| propertyLetStmt
| subStmt
| typeStmt
;
// controls ----------------------------------
controlProperties
: WS? BEGIN WS cp_ControlType WS cp_ControlIdentifier WS? NEWLINE+ cp_Properties+ END NEWLINE*
;
cp_Properties
: cp_SingleProperty
| cp_NestedProperty
| controlProperties;
cp_SingleProperty
: WS? implicitCallStmt_InStmt WS? EQ WS? '$'? cp_PropertyValue FRX_OFFSET? NEWLINE+
;
cp_PropertyName
: (OBJECT DOT)? ambiguousIdentifier (LPAREN literal RPAREN)? (DOT ambiguousIdentifier (LPAREN literal RPAREN)?)*
;
cp_PropertyValue
: DOLLAR? (literal | (LBRACE ambiguousIdentifier RBRACE) | POW ambiguousIdentifier)
;
cp_NestedProperty
: WS? BEGINPROPERTY WS ambiguousIdentifier (LPAREN INTEGERLITERAL RPAREN)? (WS GUID)? NEWLINE+ (cp_Properties+)? ENDPROPERTY NEWLINE+
;
cp_ControlType
: complexType
;
cp_ControlIdentifier
: ambiguousIdentifier
;
// block ----------------------------------
moduleBlock
: block
;
attributeStmt
: ATTRIBUTE WS implicitCallStmt_InStmt WS? EQ WS? literal (WS? COMMA WS? literal)*
;
block
: blockStmt (NEWLINE + WS? blockStmt)*
;
blockStmt
: appActivateStmt
| attributeStmt
| beepStmt
| chDirStmt
| chDriveStmt
| closeStmt
| constStmt
| dateStmt
| deleteSettingStmt
| deftypeStmt
| doLoopStmt
| endStmt
| eraseStmt
| errorStmt
| exitStmt
| explicitCallStmt
| filecopyStmt
| forEachStmt
| forNextStmt
| getStmt
| goSubStmt
| goToStmt
| ifThenElseStmt
| implementsStmt
| inputStmt
| killStmt
| letStmt
| lineInputStmt
| lineLabel
| loadStmt
| lockStmt
| lsetStmt
| macroIfThenElseStmt
| midStmt
| mkdirStmt
| nameStmt
| onErrorStmt
| onGoToStmt
| onGoSubStmt
| openStmt
| printStmt
| putStmt
| raiseEventStmt
| randomizeStmt
| redimStmt
| resetStmt
| resumeStmt
| returnStmt
| rmdirStmt
| rsetStmt
| savepictureStmt
| saveSettingStmt
| seekStmt
| selectCaseStmt
| sendkeysStmt
| setattrStmt
| setStmt
| stopStmt
| timeStmt
| unloadStmt
| unlockStmt
| variableStmt
| whileWendStmt
| widthStmt
| withStmt
| writeStmt
| implicitCallStmt_InBlock
;
// statements ----------------------------------
appActivateStmt
: APPACTIVATE WS valueStmt (WS? COMMA WS? valueStmt)?
;
beepStmt
: BEEP
;
chDirStmt
: CHDIR WS valueStmt
;
chDriveStmt
: CHDRIVE WS valueStmt
;
closeStmt
: CLOSE (WS valueStmt (WS? COMMA WS? valueStmt)*)?
;
constStmt
: (publicPrivateGlobalVisibility WS)? CONST WS constSubStmt (WS? COMMA WS? constSubStmt)*
;
constSubStmt
: ambiguousIdentifier typeHint? (WS asTypeClause)? WS? EQ WS? valueStmt
;
dateStmt
: DATE WS? EQ WS? valueStmt
;
declareStmt
: (visibility WS)? DECLARE WS (FUNCTION typeHint? | SUB) WS ambiguousIdentifier typeHint? WS LIB WS STRINGLITERAL (WS ALIAS WS STRINGLITERAL)? (WS? argList)? (WS asTypeClause)?
;
deftypeStmt
: (DEFBOOL | DEFBYTE | DEFINT | DEFLNG | DEFCUR | DEFSNG | DEFDBL | DEFDEC | DEFDATE | DEFSTR | DEFOBJ | DEFVAR) WS letterrange (WS? COMMA WS? letterrange)*
;
deleteSettingStmt
: DELETESETTING WS valueStmt WS? COMMA WS? valueStmt (WS? COMMA WS? valueStmt)?
;
doLoopStmt
: DO NEWLINE + (block NEWLINE +)? LOOP
| DO WS (WHILE | UNTIL) WS valueStmt NEWLINE + (block NEWLINE +)? LOOP
| DO NEWLINE + (block NEWLINE +) LOOP WS (WHILE | UNTIL) WS valueStmt
;
endStmt
: END
;
enumerationStmt
: (publicPrivateVisibility WS)? ENUM WS ambiguousIdentifier NEWLINE + (enumerationStmt_Constant)* END_ENUM
;
enumerationStmt_Constant
: ambiguousIdentifier (WS? EQ WS? valueStmt)? NEWLINE +
;
eraseStmt
: ERASE WS valueStmt (WS? COMMA WS? valueStmt)*
;
errorStmt
: ERROR WS valueStmt
;
eventStmt
: (visibility WS)? EVENT WS ambiguousIdentifier WS? argList
;
exitStmt
: EXIT_DO
| EXIT_FOR
| EXIT_FUNCTION
| EXIT_PROPERTY
| EXIT_SUB
;
filecopyStmt
: FILECOPY WS valueStmt WS? COMMA WS? valueStmt
;
forEachStmt
: FOR WS EACH WS ambiguousIdentifier typeHint? WS IN WS valueStmt NEWLINE + (block NEWLINE +)? NEXT (WS ambiguousIdentifier)?
;
forNextStmt
: FOR WS iCS_S_VariableOrProcedureCall typeHint? (WS asTypeClause)? WS? EQ WS? valueStmt WS TO WS valueStmt (WS STEP WS valueStmt)? NEWLINE + (block NEWLINE +)? NEXT (WS ambiguousIdentifier typeHint?)?
;
functionStmt
: (visibility WS)? (STATIC WS)? FUNCTION WS ambiguousIdentifier (WS? argList)? (WS asTypeClause)? NEWLINE + (block NEWLINE +)? END_FUNCTION
;
getStmt
: GET WS valueStmt WS? COMMA WS? valueStmt? WS? COMMA WS? valueStmt
;
goSubStmt
: GOSUB WS valueStmt
;
goToStmt
: GOTO WS valueStmt
;
ifThenElseStmt
: IF WS ifConditionStmt WS THEN WS blockStmt (WS ELSE WS blockStmt)? # inlineIfThenElse
| ifBlockStmt ifElseIfBlockStmt* ifElseBlockStmt? END_IF # blockIfThenElse
;
ifBlockStmt
: IF WS ifConditionStmt WS THEN NEWLINE + (block NEWLINE +)?
;
ifConditionStmt
: valueStmt
;
ifElseIfBlockStmt
: ELSEIF WS ifConditionStmt WS THEN NEWLINE + (block NEWLINE +)?
;
ifElseBlockStmt
: ELSE NEWLINE + (block NEWLINE +)?
;
implementsStmt
: IMPLEMENTS WS ambiguousIdentifier
;
inputStmt
: INPUT WS valueStmt (WS? COMMA WS? valueStmt) +
;
killStmt
: KILL WS valueStmt
;
letStmt
: (LET WS)? implicitCallStmt_InStmt WS? (EQ | PLUS_EQ | MINUS_EQ) WS? valueStmt
;
lineInputStmt
: LINE_INPUT WS valueStmt WS? COMMA WS? valueStmt
;
loadStmt
: LOAD WS valueStmt
;
lockStmt
: LOCK WS valueStmt (WS? COMMA WS? valueStmt (WS TO WS valueStmt)?)?
;
lsetStmt
: LSET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt
;
macroIfThenElseStmt
: macroIfBlockStmt macroElseIfBlockStmt* macroElseBlockStmt? MACRO_END_IF
;
macroIfBlockStmt
: MACRO_IF WS ifConditionStmt WS THEN NEWLINE + (moduleBody NEWLINE +)?
;
macroElseIfBlockStmt
: MACRO_ELSEIF WS ifConditionStmt WS THEN NEWLINE + (moduleBody NEWLINE +)?
;
macroElseBlockStmt
: MACRO_ELSE NEWLINE + (moduleBody NEWLINE +)?
;
midStmt
: MID WS? LPAREN WS? argsCall WS? RPAREN
;
mkdirStmt
: MKDIR WS valueStmt
;
nameStmt
: NAME WS valueStmt WS AS WS valueStmt
;
onErrorStmt
: (ON_ERROR | ON_LOCAL_ERROR) WS (GOTO WS valueStmt COLON? | RESUME WS NEXT)
;
onGoToStmt
: ON WS valueStmt WS GOTO WS valueStmt (WS? COMMA WS? valueStmt)*
;
onGoSubStmt
: ON WS valueStmt WS GOSUB WS valueStmt (WS? COMMA WS? valueStmt)*
;
openStmt
: OPEN WS valueStmt WS FOR WS (APPEND | BINARY | INPUT | OUTPUT | RANDOM) (WS ACCESS WS (READ | WRITE | READ_WRITE))? (WS (SHARED | LOCK_READ | LOCK_WRITE | LOCK_READ_WRITE))? WS AS WS valueStmt (WS LEN WS? EQ WS? valueStmt)?
;
outputList
: outputList_Expression (WS? (SEMICOLON | COMMA) WS? outputList_Expression?)*
| outputList_Expression? (WS? (SEMICOLON | COMMA) WS? outputList_Expression?) +
;
outputList_Expression
: (SPC | TAB) (WS? LPAREN WS? argsCall WS? RPAREN)?
| valueStmt
;
printStmt
: PRINT WS valueStmt WS? COMMA (WS? outputList)?
;
propertyGetStmt
: (visibility WS)? (STATIC WS)? PROPERTY_GET WS ambiguousIdentifier typeHint? (WS? argList)? (WS asTypeClause)? NEWLINE + (block NEWLINE +)? END_PROPERTY
;
propertySetStmt
: (visibility WS)? (STATIC WS)? PROPERTY_SET WS ambiguousIdentifier (WS? argList)? NEWLINE + (block NEWLINE +)? END_PROPERTY
;
propertyLetStmt
: (visibility WS)? (STATIC WS)? PROPERTY_LET WS ambiguousIdentifier (WS? argList)? NEWLINE + (block NEWLINE +)? END_PROPERTY
;
putStmt
: PUT WS valueStmt WS? COMMA WS? valueStmt? WS? COMMA WS? valueStmt
;
raiseEventStmt
: RAISEEVENT WS ambiguousIdentifier (WS? LPAREN WS? (argsCall WS?)? RPAREN)?
;
randomizeStmt
: RANDOMIZE (WS valueStmt)?
;
redimStmt
: REDIM WS (PRESERVE WS)? redimSubStmt (WS? COMMA WS? redimSubStmt)*
;
redimSubStmt
: implicitCallStmt_InStmt WS? LPAREN WS? subscripts WS? RPAREN (WS asTypeClause)?
;
resetStmt
: RESET
;
resumeStmt
: RESUME (WS (NEXT | ambiguousIdentifier))?
;
returnStmt
: RETURN
;
rmdirStmt
: RMDIR WS valueStmt
;
rsetStmt
: RSET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt
;
savepictureStmt
: SAVEPICTURE WS valueStmt WS? COMMA WS? valueStmt
;
saveSettingStmt
: SAVESETTING WS valueStmt WS? COMMA WS? valueStmt WS? COMMA WS? valueStmt WS? COMMA WS? valueStmt
;
seekStmt
: SEEK WS valueStmt WS? COMMA WS? valueStmt
;
selectCaseStmt
: SELECT WS CASE WS valueStmt NEWLINE + sC_Case* WS? END_SELECT
;
sC_Case
: CASE WS sC_Cond WS? (COLON? NEWLINE* | NEWLINE +) (block NEWLINE +)?
;
// ELSE first, so that it is not interpreted as a variable call
sC_Cond
: ELSE # caseCondElse
| sC_CondExpr (WS? COMMA WS? sC_CondExpr)* #caseCondExpr
;
sC_CondExpr
: IS WS? comparisonOperator WS? valueStmt # caseCondExprIs
| valueStmt # caseCondExprValue
| valueStmt WS TO WS valueStmt # caseCondExprTo
;
sendkeysStmt
: SENDKEYS WS valueStmt (WS? COMMA WS? valueStmt)?
;
setattrStmt
: SETATTR WS valueStmt WS? COMMA WS? valueStmt
;
setStmt
: SET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt
;
stopStmt
: STOP
;
subStmt
: (visibility WS)? (STATIC WS)? SUB WS ambiguousIdentifier (WS? argList)? NEWLINE + (block NEWLINE +)? END_SUB
;
timeStmt
: TIME WS? EQ WS? valueStmt
;
typeStmt
: (visibility WS)? TYPE WS ambiguousIdentifier NEWLINE + (typeStmt_Element)* END_TYPE
;
typeStmt_Element
: ambiguousIdentifier (WS? LPAREN (WS? subscripts)? WS? RPAREN)? (WS asTypeClause)? NEWLINE +
;
typeOfStmt
: TYPEOF WS valueStmt (WS IS WS type)?
;
unloadStmt
: UNLOAD WS valueStmt
;
unlockStmt
: UNLOCK WS valueStmt (WS? COMMA WS? valueStmt (WS TO WS valueStmt)?)?
;
// operator precedence is represented by rule order
valueStmt
: literal # vsLiteral
| LPAREN WS? valueStmt (WS? COMMA WS? valueStmt)* WS? RPAREN # vsStruct
| NEW WS valueStmt # vsNew
| typeOfStmt # vsTypeOf
| ADDRESSOF WS valueStmt # vsAddressOf
| implicitCallStmt_InStmt WS? ASSIGN WS? valueStmt # vsAssign
| valueStmt WS? POW WS? valueStmt # vsPow
| MINUS WS? valueStmt # vsNegation
| PLUS WS? valueStmt # vsPlus
| valueStmt WS? DIV WS? valueStmt # vsDiv
| valueStmt WS? MULT WS? valueStmt # vsMult
| valueStmt WS? MOD WS? valueStmt # vsMod
| valueStmt WS? PLUS WS? valueStmt # vsAdd
| valueStmt WS? MINUS WS? valueStmt # vsMinus
| valueStmt WS? AMPERSAND WS? valueStmt # vsAmp
| valueStmt WS? EQ WS? valueStmt # vsEq
| valueStmt WS? NEQ WS? valueStmt # vsNeq
| valueStmt WS? LT WS? valueStmt # vsLt
| valueStmt WS? GT WS? valueStmt # vsGt
| valueStmt WS? LEQ WS? valueStmt # vsLeq
| valueStmt WS? GEQ WS? valueStmt # vsGeq
| valueStmt WS LIKE WS valueStmt # vsLike
| valueStmt WS IS WS valueStmt # vsIs
| NOT (WS valueStmt | LPAREN WS? valueStmt WS? RPAREN) # vsNot
| valueStmt WS? AND WS? valueStmt # vsAnd
| valueStmt WS? OR WS? valueStmt # vsOr
| valueStmt WS? XOR WS? valueStmt # vsXor
| valueStmt WS? EQV WS? valueStmt # vsEqv
| valueStmt WS? IMP WS? valueStmt # vsImp
| implicitCallStmt_InStmt # vsICS
| midStmt # vsMid
;
variableStmt
: (DIM | STATIC | visibility) WS (WITHEVENTS WS)? variableListStmt
;
variableListStmt
: variableSubStmt (WS? COMMA WS? variableSubStmt)*
;
variableSubStmt
: ambiguousIdentifier typeHint? (WS? LPAREN WS? (subscripts WS?)? RPAREN WS?)? (WS asTypeClause)?
;
whileWendStmt
: WHILE WS valueStmt NEWLINE + block* NEWLINE* WEND
;
widthStmt
: WIDTH WS valueStmt WS? COMMA WS? valueStmt
;
withStmt
: WITH WS (NEW WS)? implicitCallStmt_InStmt NEWLINE + (block NEWLINE +)? END_WITH
;
writeStmt
: WRITE WS valueStmt WS? COMMA (WS? outputList)?
;
// complex call statements ----------------------------------
explicitCallStmt
: eCS_ProcedureCall
| eCS_MemberProcedureCall
;
// parantheses are required in case of args -> empty parantheses are removed
eCS_ProcedureCall
: CALL WS ambiguousIdentifier typeHint? (WS? LPAREN WS? argsCall WS? RPAREN)?
;
// parantheses are required in case of args -> empty parantheses are removed
eCS_MemberProcedureCall
: CALL WS implicitCallStmt_InStmt? DOT WS? ambiguousIdentifier typeHint? (WS? LPAREN WS? argsCall WS? RPAREN)?
;
implicitCallStmt_InBlock
: iCS_B_ProcedureCall
| iCS_B_MemberProcedureCall
;
// parantheses are forbidden in case of args
// variables cannot be called in blocks
// certainIdentifier instead of ambiguousIdentifier for preventing ambiguity with statement keywords
iCS_B_ProcedureCall
: certainIdentifier (WS argsCall)?
;
iCS_B_MemberProcedureCall
: implicitCallStmt_InStmt? DOT ambiguousIdentifier typeHint? (WS argsCall)? dictionaryCallStmt?
;
// iCS_S_MembersCall first, so that member calls are not resolved as separate iCS_S_VariableOrProcedureCalls
implicitCallStmt_InStmt
: iCS_S_MembersCall
| iCS_S_VariableOrProcedureCall
| iCS_S_ProcedureOrArrayCall
| iCS_S_DictionaryCall
;
iCS_S_VariableOrProcedureCall
: ambiguousIdentifier typeHint? dictionaryCallStmt?
;
iCS_S_ProcedureOrArrayCall
: (ambiguousIdentifier | baseType | iCS_S_NestedProcedureCall) typeHint? WS? (LPAREN WS? (argsCall WS?)? RPAREN)+ dictionaryCallStmt?
;
iCS_S_NestedProcedureCall
: ambiguousIdentifier typeHint? WS? LPAREN WS? (argsCall WS?)? RPAREN
;
iCS_S_MembersCall
: (iCS_S_VariableOrProcedureCall | iCS_S_ProcedureOrArrayCall)? iCS_S_MemberCall + dictionaryCallStmt?
;
iCS_S_MemberCall
: WS? DOT (iCS_S_VariableOrProcedureCall | iCS_S_ProcedureOrArrayCall)
;
iCS_S_DictionaryCall
: dictionaryCallStmt
;
// atomic call statements ----------------------------------
argsCall
: (argCall? WS? (COMMA | SEMICOLON) WS?)* argCall (WS? (COMMA | SEMICOLON) WS? argCall?)*
;
argCall
: ((BYVAL | BYREF | PARAMARRAY) WS)? valueStmt
;
dictionaryCallStmt
: EXCLAMATIONMARK ambiguousIdentifier typeHint?
;
// atomic rules for statements
argList
: LPAREN (WS? arg (WS? COMMA WS? arg)*)? WS? RPAREN
;
arg
: (OPTIONAL WS)? ((BYVAL | BYREF) WS)? (PARAMARRAY WS)? ambiguousIdentifier typeHint? (WS? LPAREN WS? RPAREN)? (WS asTypeClause)? (WS? argDefaultValue)?
;
argDefaultValue
: EQ WS? valueStmt
;
subscripts
: subscript (WS? COMMA WS? subscript)*
;
subscript
: (valueStmt WS TO WS)? valueStmt
;
// atomic rules ----------------------------------
ambiguousIdentifier
: (IDENTIFIER | ambiguousKeyword) +
| L_SQUARE_BRACKET (IDENTIFIER | ambiguousKeyword) + R_SQUARE_BRACKET
;
asTypeClause
: AS WS (NEW WS)? type (WS fieldLength)?
;
baseType
: BOOLEAN
| BYTE
| COLLECTION
| DATE
| DOUBLE
| INTEGER
| LONG
| OBJECT
| SINGLE
| STRING
| VARIANT
;
certainIdentifier
: IDENTIFIER (ambiguousKeyword | IDENTIFIER)*
| ambiguousKeyword (ambiguousKeyword | IDENTIFIER) +
;
comparisonOperator
: LT
| LEQ
| GT
| GEQ
| EQ
| NEQ
| IS
| LIKE
;
complexType
: ambiguousIdentifier (DOT ambiguousIdentifier)*
;
fieldLength
: MULT WS? (INTEGERLITERAL | ambiguousIdentifier)
;
letterrange
: certainIdentifier (WS? MINUS WS? certainIdentifier)?
;
lineLabel
: ambiguousIdentifier COLON
;
literal
: COLORLITERAL
| DATELITERAL
| DOUBLELITERAL
| FILENUMBER
| INTEGERLITERAL
| OCTALLITERAL
| STRINGLITERAL
| TRUE
| FALSE
| NOTHING
| NULL
;
publicPrivateVisibility
: PRIVATE
| PUBLIC
;
publicPrivateGlobalVisibility
: PRIVATE
| PUBLIC
| GLOBAL
;
type
: (baseType | complexType) (WS? LPAREN WS? RPAREN)?
;
typeHint
: AMPERSAND
| AT
| DOLLAR
| EXCLAMATIONMARK
| HASH
| PERCENT
;
visibility
: PRIVATE
| PUBLIC
| FRIEND
| GLOBAL
;
// ambiguous keywords
ambiguousKeyword
: ACCESS
| ADDRESSOF
| ALIAS
| AND
| ATTRIBUTE
| APPACTIVATE
| APPEND
| AS
| BEEP
| BEGIN
| BINARY
| BOOLEAN
| BYVAL
| BYREF
| BYTE
| CALL
| CASE
| CLASS
| CLOSE
| CHDIR
| CHDRIVE
| COLLECTION
| CONST
| DATE
| DECLARE
| DEFBOOL
| DEFBYTE
| DEFCUR
| DEFDBL
| DEFDATE
| DEFDEC
| DEFINT
| DEFLNG
| DEFOBJ
| DEFSNG
| DEFSTR
| DEFVAR
| DELETESETTING
| DIM
| DO
| DOUBLE
| EACH
| ELSE
| ELSEIF
| END
| ENUM
| EQV
| ERASE
| ERROR
| EVENT
| FALSE
| FILECOPY
| FRIEND
| FOR
| FUNCTION
| GET
| GLOBAL
| GOSUB
| GOTO
| IF
| IMP
| IMPLEMENTS
| IN
| INPUT
| IS
| INTEGER
| KILL
| LOAD
| LOCK
| LONG
| LOOP
| LEN
| LET
| LIB
| LIKE
| LSET
| ME
| MID
| MKDIR
| MOD
| NAME
| NEXT
| NEW
| NOT
| NOTHING
| NULL
| OBJECT
| ON
| OPEN
| OPTIONAL
| OR
| OUTPUT
| PARAMARRAY
| PRESERVE
| PRINT
| PRIVATE
| PUBLIC
| PUT
| RANDOM
| RANDOMIZE
| RAISEEVENT
| READ
| REDIM
| REM
| RESET
| RESUME
| RETURN
| RMDIR
| RSET
| SAVEPICTURE
| SAVESETTING
| SEEK
| SELECT
| SENDKEYS
| SET
| SETATTR
| SHARED
| SINGLE
| SPC
| STATIC
| STEP
| STOP
| STRING
| SUB
| TAB
| TEXT
| THEN
| TIME
| TO
| TRUE
| TYPE
| TYPEOF
| UNLOAD
| UNLOCK
| UNTIL
| VARIANT
| VERSION
| WEND
| WHILE
| WIDTH
| WITH
| WITHEVENTS
| WRITE
| XOR
;
// lexer rules --------------------------------------------------------------------------------
// keywords
ACCESS
: A C C E S S
;
ADDRESSOF
: A D D R E S S O F
;
ALIAS
: A L I A S
;
AND
: A N D
;