-
Notifications
You must be signed in to change notification settings - Fork 25
/
Proparse.g4
5694 lines (5113 loc) · 114 KB
/
Proparse.g4
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) 2015-2024 Riverside Software
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License, v. 2.0 are satisfied: GNU Lesser General Public License v3.0
* which is available at https://www.gnu.org/licenses/lgpl-3.0.txt
*
* SPDX-License-Identifier: EPL-2.0 OR LGPL-3.0
********************************************************************************/
// Based on original work by John Green
parser grammar Proparse;
@header {
import org.antlr.v4.runtime.BufferedTokenStream;
import org.prorefactor.core.ABLNodeType;
import org.prorefactor.proparse.support.IProparseEnvironment;
import org.prorefactor.proparse.support.IntegerIndex;
import org.prorefactor.proparse.support.ParserSupport;
import org.prorefactor.proparse.support.SymbolScope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.progress.xref.CrossReference;
}
options {
tokenVocab=BaseTokenTypes;
}
@members {
private static final Logger LOGGER = LoggerFactory.getLogger(Proparse.class);
private ParserSupport support;
private boolean c3;
public void initialize(IProparseEnvironment session, CrossReference xref) {
this.initialize(session, xref, false);
}
public void initialize(IProparseEnvironment session, CrossReference xref, boolean c3) {
this.support = new ParserSupport(session, xref);
this.c3 = c3;
}
public void initialize(ParserSupport support, boolean c3) {
this.support = support;
this.c3 = c3;
}
/**
* @deprecated
* Use {@link Proparse#initialize(IProparseEnvironment, CrossReference)}
*/
@Deprecated
public void initAntlr4(IProparseEnvironment session, CrossReference xref) {
this.initialize(session, xref, false);
}
public ParserSupport getParserSupport() {
return this.support;
}
private boolean assignmentListSemanticPredicate() {
return (_input.LA(2) == NAMEDOT) || !support.isVar(_input.LT(1).getText());
}
private boolean blockLabelSemanticPredicate() {
return (_input.LT(1).getType() != ABLNodeType.FINALLY.getType());
}
private boolean clearStatementSemanticPredicate() {
return (_input.LA(3) != OBJCOLON);
}
private boolean defineMenuStatementSemanticPredicate() {
return (_input.LA(2) == RULE) || (_input.LA(2) == SKIP) || (_input.LA(2) == SUBMENU) || (_input.LA(2) == MENUITEM);
}
private boolean expressionTerm2SemanticPredicate() {
return (support.isMethodOrFunc(_input.LT(1)) != 0);
}
private boolean expressionTerm2SemanticPredicate2() {
return c3 || (support.isClass() && support.unknownMethodCallsAllowed());
}
private boolean functionParamStdSemanticPredicate() {
return (_input.LA(2) != NAMEDOT);
}
private boolean parameterSemanticPredicate() {
return (_input.LA(3) != OBJCOLON) && (_input.LA(3) != DOUBLECOLON);
}
private boolean parameterArgSemanticPredicate() {
return (_input.LA(3) != OBJCOLON) && (_input.LA(3) != DOUBLECOLON);
}
private boolean recordSemanticPredicate() {
return c3 || support.recordSemanticPredicate(_input.LT(1), _input.LT(2), _input.LT(3));
}
private boolean varRecFieldSemanticPredicate() {
return (_input.LA(2) != NAMEDOT) && support.isVar(_input.LT(1).getText());
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Begin syntax
///////////////////////////////////////////////////////////////////////////////////////////////////
program:
blockOrStatement* EOF
;
codeBlock:
blockOrStatement*
;
blockOrStatement:
emptyStatement
| annotation
| dotComment
| assignStatement2
| statement
| expressionStatement
;
abstractClassCodeBlock:
abstractClassBlockOrStatement*
;
classCodeBlock:
classBlockOrStatement*
;
interfaceCodeBlock:
interfaceBlockOrStatement*
;
classBlockOrStatement:
emptyStatement
| annotation
| inClassStatement
;
abstractClassBlockOrStatement:
emptyStatement
| annotation
| inAbstractClassStatement
;
interfaceBlockOrStatement:
emptyStatement
| annotation
| inInterfaceStatement
;
emptyStatement:
PERIOD
;
dotComment:
NAMEDOT notStatementEnd+ statementEnd
;
expressionStatement:
expression NOERROR? statementEnd
;
blockColon:
LEXCOLON | PERIOD
;
blockEnd:
{ !c3 }? EOF
| END statementEnd
;
blockFor:
// This is the FOR option, like, DO FOR..., REPEAT FOR...
FOR record ( COMMA record )*
;
blockOption:
fieldExpr EQUAL expression TO expression ( BY constant )? # blockOptionIterator
| queryTuningPhrase # blockOptionQueryTuning
| WHILE expression # blockOptionWhile
| TRANSACTION # blockOptionTransaction
| stopAfter # blockOptionStopAfter
| onPhrase # blockOptionOnPhrase
| framePhrase # blockOptionFramePhrase
| BREAK # blockOptionBreak
| byExpr # blockOptionByExpr
| collatePhrase # blockOptionCollatePhrase
| // weird. Couldn't find GROUP BY in the docs, and couldn't even figure out how it gets through PSC's parser.
GROUP byExpr+ # blockOptionGroupBy
;
blockPreselect:
PRESELECT multiRecordSearch
;
statement:
aaTraceOnOffStatement
| aaTraceCloseStatement
| aaTraceStatement
| accumulateStatement
| aggregateStatement
| analyzeStatement
| applyStatement
| assignStatement
| bellStatement
| blockLevelStatement
| bufferCompareStatement
| bufferCopyStatement
| callStatement
| caseStatement
| catchStatement
| chooseStatement
| classStatement
| abstractClassStatement
| dynamicNewStatement
| enumStatement
| clearStatement
| closeQueryStatement
| closeStoredProcedureStatement
| colorStatement
| compileStatement
| connectStatement
| copyLobStatement
| createWidgetPoolStatement // CREATE WIDGET-POOL is ambiguous if you have a table named "widget-pool". ABL seems to treat this as a CREATE WIDGET-POOL Statement
| createStatement
| createWhateverStatement
| createAliasStatement
| createBrowseStatement
| createQueryStatement
| createBufferStatement
| createDatabaseStatement
| createServerStatement
| createServerSocketStatement
| createSocketStatement
| createTempTableStatement
| createWidgetPoolStatement
| createWidgetStatement
| ddeAdviseStatement
| ddeExecuteStatement
| ddeGetStatement
| ddeInitiateStatement
| ddeRequestStatement
| ddeSendStatement
| ddeTerminateStatement
| defineBrowseStatement
| defineBufferStatement
| defineButtonStatement
| defineDatasetStatement
| defineDataSourceStatement
| defineEventStatement
| defineFrameStatement
| defineImageStatement
| defineMenuStatement
| defineParameterStatement
| defineQueryStatement
| defineRectangleStatement
| defineStreamStatement
| defineSubMenuStatement
| defineTempTableStatement
| defineWorkTableStatement
| defineVariableStatement
| varStatement
| dictionaryStatement
| deleteWidgetPoolStatement
| deleteStatement
| deleteAliasStatement
| deleteObjectStatement
| deleteProcedureStatement
| deleteWidgetStatement
| deleteWidgetPoolStatement
| disableStatement
| disableTriggersStatement
| disconnectStatement
| displayStatement
| doStatement
| downStatement
| emptyTempTableStatement
| enableStatement
| exportStatement
| finallyStatement
| findStatement
| forStatement
| formStatement
| functionStatement
| getStatement
| getKeyValueStatement
| hideStatement
| ifStatement
| importStatement
| inputStatement
| inputOutputStatement
| insertStatement
| interfaceStatement
| leaveStatement
| loadStatement
| messageStatement
| nextStatement
| nextPromptStatement
| noReturnValueStatement
| onStatement
| openQueryStatement
| osAppendStatement
| osCommandStatement
| osCopyStatement
| osCreateDirStatement
| osDeleteStatement
| osRenameStatement
| outputStatement
| pageStatement
| pauseStatement
| procedureStatement
| processEventsStatement
| promptForStatement
| publishStatement
| putCursorStatement
| putStatement
| putScreenStatement
| putKeyValueStatement
| quitStatement
| rawTransferStatement
| readkeyStatement
| releaseStatementWrapper
| repeatStatement
| repositionStatement
| returnStatement
| routineLevelStatement
| runStatementWrapper
| saveCacheStatement
| scrollStatement
| seekStatement
| setStatement
| showStatsStatement
| statusStatement
| stopStatement
| superStatement
| subscribeStatement
| systemDialogColorStatement
| systemDialogFontStatement
| systemDialogGetDirStatement
| systemDialogGetFileStatement
| systemDialogPrinterSetupStatement
| systemHelpStatement
| thisObjectStatement
| transactionModeAutomaticStatement
| triggerProcedureStatement
| underlineStatement
| undoStatement
| unloadStatement
| unsubscribeStatement
| upStatement
| updateStatement
| useStatement
| usingStatement
| validateStatement
| viewStatement
| waitForStatement
;
inClassStatement:
defineBrowseStatement
| defineBufferStatement
| defineButtonStatement
| defineDatasetStatement
| defineDataSourceStatement
| defineEventStatement
| defineFrameStatement
| defineImageStatement
| defineMenuStatement
| defineParameterStatement
| definePropertyStatement
| defineQueryStatement
| defineRectangleStatement
| defineStreamStatement
| defineSubMenuStatement
| defineTempTableStatement
| defineWorkTableStatement
| defineVariableStatement
| formStatement
| varStatement
| constructorStatement
| destructorStatement
| methodStatement
| externalProcedureStatement // Only external procedures are accepted
| externalFunctionStatement // Only FUNCTION ... IN ... are accepted
| onStatement
;
inAbstractClassStatement:
defineBrowseStatement
| defineBufferStatement
| defineButtonStatement
| defineDatasetStatement
| defineDataSourceStatement
| defineEventStatement
| defineFrameStatement
| defineImageStatement
| defineMenuStatement
| defineParameterStatement
| definePropertyStatement
| defineQueryStatement
| defineRectangleStatement
| defineStreamStatement
| defineSubMenuStatement
| defineTempTableStatement
| defineWorkTableStatement
| defineVariableStatement
| formStatement
| varStatement
| constructorStatement
| destructorStatement
| methodStatement
| abstractMethodStatement
| externalProcedureStatement // Only external procedures are accepted
| externalFunctionStatement // Only FUNCTION ... IN ... are accepted
| onStatement
;
inInterfaceStatement:
defineDatasetStatement
| defineEventStatement
| definePropertyStatement
| defineTempTableStatement
| defineWorkTableStatement
| methodDefinitionStatement
| externalProcedureStatement // Only external procedures are accepted
| externalFunctionStatement // Only FUNCTION ... IN ... are accepted
;
pseudoFunction:
// See PSC's grammar for <pseudfn> and for <asignmt>.
// These are functions that can (or, in some cases, must) be an l-value.
// Productions that are named *_pseudfn /must/ be l-values.
// Widget attributes are ambiguous with pretty much anything, because
// the first bit before the colon can be any expression.
memoryManagementFunction
| AAMSG // not the whole func - we don't want its arguments here
| currentValueFunction
| CURRENTWINDOW
| dynamicCurrentValueFunction
| dynamicPropertyFunction
| entryFunction
| lengthFunction
| nextValueFunction
| rawFunction
| substringFunction
// Keywords from <optargfn> and <noargfn>. Assignments to those
// are accepted by the compiler, however, assignment to them seems to have
// no affect at runtime.
// The following are from <optargfn>
| PAGESIZE | LINECOUNTER | PAGENUMBER | FRAMECOL
| FRAMEDOWN | FRAMELINE | FRAMEROW | USERID | ETIME
| PROVERSION
// The following are from <noargfn>
| DBNAME | TIME | OPSYS | RETRY | AASERIAL | AACONTROL
| MESSAGELINES | TERMINAL | PROPATH | CURRENTLANGUAGE | PROMSGS
| SCREENLINES | LASTKEY
| FRAMEFIELD | FRAMEFILE | FRAMEVALUE | GOPENDING
| PROGRESS | FRAMEINDEX | FRAMEDB | FRAMENAME | DATASERVERS
| NUMDBS | NUMALIASES | ISATTRSPACE | PROCSTATUS
| PROCHANDLE | CURSOR | OSERROR | RETURNVALUE | OSDRIVES
| TRANSACTION | MACHINECLASS
| AAPCONTROL | GETCODEPAGES | COMSELF | PROCESSARCHITECTURE
;
memoryManagementFunction:
( EXTENT | FIXCODEPAGE | OVERLAY | PUTBITS | PUTBYTE | PUTBYTES | PUTDOUBLE | PUTFLOAT | PUTINT64 | PUTLONG | PUTSHORT | PUTSTRING | PUTUNSIGNEDLONG | PUTUNSIGNEDSHORT | SETBYTEORDER | SETPOINTERVALUE | SETSIZE )
functionArgs
;
// ## IMPORTANT ## If you add a function keyword here, also add it to NodeTypes.
builtinFunction:
ACCUMULATE accumulateWhat ( byExpr expression | expression )
| canFindFunction
| CAST LEFTPAREN expression COMMA typeName RIGHTPAREN
| currentValueFunction // is also a pseudfn.
| dynamicCurrentValueFunction // is also a pseudfn.
| DYNAMICFUNCTION LEFTPAREN expression inExpression? (COMMA parameter)* RIGHTPAREN NOERROR?
| DYNAMICINVOKE
LEFTPAREN
( expression | typeName )
COMMA expression
(COMMA parameter)*
RIGHTPAREN
// ENTERED and NOTENTERED are only dealt with as part of an expression term. See: exprt.
| FRAMECOL LEFTPAREN widgetname RIGHTPAREN // also noarg
| FRAMEDOWN LEFTPAREN widgetname RIGHTPAREN // also noarg
| FRAMELINE LEFTPAREN widgetname RIGHTPAREN // also noarg
| FRAMEROW LEFTPAREN widgetname RIGHTPAREN // also noarg
| GETCLASS LEFTPAREN typeName RIGHTPAREN
| IF expression THEN expression ELSE expression
| ldbnameFunction
| LINECOUNTER LEFTPAREN streamname RIGHTPAREN // also noarg
| nextValueFunction // is also a pseudfn.
| PAGENUMBER LEFTPAREN streamname RIGHTPAREN // also noarg
| PAGESIZE LEFTPAREN streamname RIGHTPAREN // also noarg
| SEEK LEFTPAREN ( INPUT | OUTPUT | streamname | STREAMHANDLE expression ) RIGHTPAREN // streamname, /not/ stream_name_or_handle.
| TYPEOF LEFTPAREN expression COMMA typeName RIGHTPAREN
| argFunction
| optionalArgFunction
| recordFunction
;
parameter:
// This is the syntax for parameters when calling or running something.
// This can refer to a buffer/tablehandle, but it doesn't define one.
BUFFER identifier FOR record # parameterBufferFor
| // BUFFER parameter. Be careful not to pick up BUFFER customer:whatever or BUFFER sports2000.customer:whatever or BUFFER foo::fld1 or BUFFER sports2000.foo::fld1
{ parameterSemanticPredicate() }? BUFFER record # parameterBufferRecord
| p=( OUTPUT | INPUTOUTPUT | INPUT )?
parameterArg
( BYPOINTER | BYVARIANTPOINTER )?
# parameterOther
;
parameterArg:
TABLEHANDLE fieldExpr parameterDatasetOptions # parameterArgTableHandle
| TABLE FOR? record parameterDatasetOptions # parameterArgTable
| { parameterArgSemanticPredicate() }? DATASET identifier parameterDatasetOptions # parameterArgDataset
| DATASETHANDLE fieldExpr parameterDatasetOptions # parameterArgDatasetHandle
| PARAMETER fieldExpr EQUAL expression # parameterArgStoredProcedure // for RUN STORED-PROCEDURE
| expression ( AS datatype )? # parameterArgExpression
;
parameterDatasetOptions:
APPEND? ( BYVALUE | BYREFERENCE | BIND )?
;
parameterList:
parameterListNoRoot
;
parameterListNoRoot:
// This is used by user defd funcs, because the udfunc name /is/ the root for its parameter list.
// Using a Parameter_list node would be unnecessary and silly.
LEFTPAREN ( parameter ( COMMA parameter )* )? RIGHTPAREN
;
eventList:
. ( COMMA . )*
;
functionArgs:
// Use funargs /only/ if it is the child of a root-node keyword.
LEFTPAREN parameter ( COMMA parameter )* RIGHTPAREN
;
optionalFunctionArgs:
// Use optfunargs /only/ if it is the child of a root-node keyword.
LEFTPAREN ( parameter ( COMMA parameter )* )? RIGHTPAREN
;
// ... or value phrases
// There are a number of situations where you can have name, filename,
// or "Anything", or that can be substituted with "value(expression)".
anyOrValue:
VALUE LEFTPAREN expression RIGHTPAREN # anyOrValueValue
| ~( PERIOD | VALUE ) # anyOrValueAny
;
filenameOrValue:
valueExpression | filename
;
valueExpression:
VALUE LEFTPAREN expression RIGHTPAREN
;
quotedStringOrValue:
valueExpression | QSTRING
;
expressionOrValue:
valueExpression | expression
;
findWhich:
CURRENT | EACH | FIRST | LAST | NEXT | PREV
;
lockHow:
SHARELOCK | EXCLUSIVELOCK | NOLOCK
;
///////////////////////////////////////////////////////////////////////////////////////////////////
// expression
///////////////////////////////////////////////////////////////////////////////////////////////////
expression:
MINUS expressionTerm # expressionMinus
| PLUS expressionTerm # expressionPlus
| expression ( STAR | MULTIPLY | SLASH | DIVIDE | MODULO ) expression # expressionOp1
| expression ( PLUS | MINUS) expression # expressionOp2
| expression ( EQUAL | EQ | GTORLT | NE | RIGHTANGLE | GTHAN | GTOREQUAL | GE | LEFTANGLE | LTHAN | LTOREQUAL | LE ) expression # expressionComparison
| expression ( MATCHES | BEGINS | CONTAINS ) expression # expressionStringComparison
| NOT expression # expressionNot
| expression XOR expression # expressionXor
| expression AND expression # expressionAnd
| expression OR expression # expressionOr
| expressionTerm # expressionExprt
;
///////////////////////////////////////////////////////////////////////////////////////////////////
// Expression bits
///////////////////////////////////////////////////////////////////////////////////////////////////
expressionTerm:
expressionTerm ( OBJCOLON | ELVIS ) methodName methodParamList # exprTermMethodCall
| expressionTerm ( OBJCOLON | ELVIS ) attributeName # exprTermAttribute
| expressionTerm DOUBLECOLON memberName methodParamList? # exprTermNamedMember
| expressionTerm LEFTBRACE expression ( FOR constant )? RIGHTBRACE # exprTermArray
| expressionTerm inuic # exprTermInUI
| widName # exprTermWidget
| expressionTerm2 # exprTermOther
;
methodName:
nonPunctuating;
attributeName:
nonPunctuating;
memberName:
nonPunctuating;
expressionTerm2:
LEFTPAREN expression RIGHTPAREN # exprt2ParenExpr
| NEW typeName parameterList # exprt2New
| // Methods take precedence over built-in functions. The compiler does not seem to try recognize by function/method signature.
{ expressionTerm2SemanticPredicate() }? fname=identifier parameterListNoRoot # exprt2ParenCall
| // Have to predicate all of builtinfunc, because it can be ambiguous with method call.
builtinFunction # exprt2BuiltinFunc
| // We are going to have lots of cases where we are inheriting methods
// from a superclass which we don't have the source for. At this
// point in expression evaluation, if we have anything followed by a left-paren,
// we're going to assume it's a method call.
// Method names which are reserved keywords must be prefixed with THIS-OBJECT:.
{ expressionTerm2SemanticPredicate2() }? methodname=identifier parameterListNoRoot # exprt2ParenCall2
| constant # exprt2Constant
| noArgFunction # exprt2NoArgFunc
| field ( NOT? ENTERED )? # exprt2Field
| SUPER # exprt2Super
;
widName:
systemHandleName
| DATASET identifier
| DATASOURCE identifier
| FIELD fieldExpr
| FRAME identifier
| MENU identifier
| SUBMENU identifier
| MENUITEM identifier
| BROWSE identifier
| QUERY identifier
| TEMPTABLE identifier
| BUFFER identifier
| XDOCUMENT identifier
| XNODEREF identifier
| SOCKET identifier
| STREAM streamname
;
gWidget:
sWidget inuic?
;
widgetList:
gWidget ( COMMA gWidget )*
;
sWidget:
widName | fieldExpr
;
filn:
t1=identifier ( NAMEDOT t2=identifier )?
;
fieldn:
t1=identifier ( NAMEDOT t2=identifier ( NAMEDOT t3=identifier )? )?
;
field:
INPUT? fieldFrameOrBrowse? id=fieldn { support.fieldReference($id.text); }
;
fieldExpr:
field ( LEFTBRACE expression ( FOR expression )? RIGHTBRACE )?
;
fieldFrameOrBrowse:
FRAME widgetname
| BROWSE widgetname
;
methodParamList:
LEFTPAREN parameter? ( COMMA parameter? )* RIGHTPAREN
;
inuic:
IN ( MENU | FRAME | BROWSE | SUBMENU | BUFFER ) widgetname
;
varRecField:
// If there's junk in front, like INPUT FRAME, then it won't get picked up
// as a record - we don't have to worry about that. So, we can look at the
// very next token, and if it's an identifier it might be record - check its name.
{ varRecFieldSemanticPredicate() }? fieldExpr
| record
| fieldExpr
;
recordAsFormItem:
record
;
record:
// RECORD can be any db table name, work/temp table name, buffer name.
{ recordSemanticPredicate() }? f=filn { support.pushRecordExpression(_localctx, $f.text); }
;
//// Names ////
blockLabel:
// Block labels can begin with [#|$|%], which are picked up as FILENAME by the lexer.
{ blockLabelSemanticPredicate() }?
identifier | FILENAME
;
sequencename:
identifier
;
streamname:
identifier
;
widgetname:
identifier
;
identifier:
// identifier gets us an ID node for an unqualified (local) reference.
// Only an ID or unreservedkeyword can be used as an unqualified reference.
// Reserved keywords as names can be referenced if they are prefixed with
// an object handle or THIS-OBJECT.
ID # identifierID
| unreservedkeyword # identifierUKW
;
newIdentifier:
// new_identifier gets us an ID node when naming (defining) a new named thing.
// Reserved keywords can be used as names.
.
;
filename:
t1=filenamePart
( { ( _input.LA(1) != Token.EOF) && !support.hasHiddenBefore(_input) }? t2=filenamePart )*
;
filenamePart:
// RIGHTANGLE and LEFTANGLE can't be in a filename - see RUN statement.
// LEXCOLON has a space after it, and a colon can't be the last character in a filename.
// OBJCOLON has no whitespace after it, so it is allowed in the middle of a filename.
// (Like c:\myfile.txt)
// PERIOD has space after it, and we don't allow '.' at the end of a filename.
// NAMEDOT has no space after it, and '.' is OK in the middle of a filename.
// "run abc(def.p." and "run abc{def.p." do not compile.
~( PERIOD | LEXCOLON | RIGHTANGLE | LEFTANGLE | LEFTPAREN | LEFTCURLY )
;
typeName:
nonPunctuating ( LEFTANGLE typeName RIGHTANGLE )?
;
// Different action in the visitor (no class lookup in typeName2)
typeName2:
nonPunctuating ( LEFTANGLE typeName RIGHTANGLE )?
;
// These are necessarily reserved keywords.
constant:
LEXDATE | NULL | NUMBER | QSTRING | UNKNOWNVALUE
| BIGENDIAN
| DLLCALLTYPE
| EXCLUSIVELOCK
| FALSE
| FALSELEAKS
| FINDCASESENSITIVE
| FINDGLOBAL
| FINDNEXTOCCURRENCE
| FINDPREVOCCURRENCE
| FINDSELECT
| FINDWRAPAROUND
| FUNCTIONCALLTYPE
| GETATTRCALLTYPE
| HOSTBYTEORDER
| LEAKDETECTION
| LITTLEENDIAN
| NO
| NOLOCK
| NOWAIT
| PROCEDURECALLTYPE
| READAVAILABLE
| READEXACTNUM
| ROWCREATED
| ROWDELETED
| ROWMODIFIED
| ROWUNMODIFIED
| SAXCOMPLETE
| SAXPARSERERROR
| SAXRUNNING
| SAXUNINITIALIZED
| SAXWRITEBEGIN
| SAXWRITECOMPLETE
| SAXWRITECONTENT
| SAXWRITEELEMENT
| SAXWRITEERROR
| SAXWRITEIDLE
| SAXWRITETAG
| SEARCHSELF
| SEARCHTARGET
| SETATTRCALLTYPE
| SHARELOCK
| STOMPDETECTION
| STOMPFREQUENCY
| TRUE
| WINDOWDELAYEDMINIMIZE
| WINDOWMAXIMIZED
| WINDOWMINIMIZED
| WINDOWNORMAL
| YES
;
nonPunctuating:
~(
EOF | PERIOD | SLASH | LEXCOLON | OBJCOLON | LEXAT | LEFTBRACE | RIGHTBRACE | CARET | COMMA | EXCLAMATION
| EQUAL | LEFTPAREN | RIGHTPAREN | SEMI | STAR | UNKNOWNVALUE | BACKTICK | GTOREQUAL | RIGHTANGLE | GTORLT
| LTOREQUAL | LEFTANGLE | PLUS | MINUS
)
;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// begin PROGRESS syntax features, in alphabetical order
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
aaTraceCloseStatement:
AATRACE streamNameOrHandle? CLOSE statementEnd
;
aaTraceOnOffStatement:
AATRACE ( OFF | ON AALIST? ) statementEnd
;
aaTraceStatement:
AATRACE streamNameOrHandle? ( TO | FROM | THROUGH ) ioPhraseStateEnd
;
accumulateWhat:
AVERAGE | COUNT | MAXIMUM | MINIMUM | TOTAL | SUBAVERAGE | SUBCOUNT | SUBMAXIMUM | SUBMINIMUM | SUBTOTAL | SUM
;
accumulateStatement:
ACCUMULATE displayItem* statementEnd
;
aggregatePhrase:
LEFTPAREN aggregateOption+ byExpr* RIGHTPAREN
;
aggregateOption: // SEMITRANSLATED
accumulateWhat labelConstant?
;
allExceptFields:
ALL exceptFields?
;
aggregateStatement:
AGGREGATE expressionTerm EQUAL aggregateExpression FOR record ( WHERE expression )? statementEnd
;
aggregateExpression:
( COUNT | TOTAL | AVERAGE ) LEFTPAREN fieldn RIGHTPAREN
;
analyzeStatement:
// Don't ask me - I don't know. I just found it in PSC's grammar.
ANALYZE filenameOrValue filenameOrValue ( OUTPUT filenameOrValue )?
( APPEND | ALL | NOERROR )*
statementEnd
;
annotation:
ANNOTATION notStatementEnd* statementEnd
;
applyStatement:
// APPLY is not necessarily an IO statement. See the language ref.
APPLY expression applyStatementSub? statementEnd
;
applyStatementSub:
TO gWidget
;
assignOption:
// Used in defining widgets - sets widget attributes
ASSIGN assignOptionSub+
;
assignOptionSub:
. EQUAL expression
;
assignStatement:
ASSIGN assignmentList NOERROR? statementEnd
;
assignmentList:
record exceptFields
| // We want to pick up record only if it can't be a variable name
{ assignmentListSemanticPredicate() }?
record
| ( assignEqual whenExpression? | assignField whenExpression? )*
;
assignStatement2:
assignEqualLeft ( EQUAL | PLUSEQUAL | MINUSEQUAL | STAREQUAL | SLASHEQUAL ) expression NOERROR? statementEnd
;
assignEqual:
left=assignEqualLeft ( EQUAL | PLUSEQUAL | MINUSEQUAL | STAREQUAL | SLASHEQUAL ) right=expression
;
assignEqualLeft:
pseudoFunction | expressionTerm
;
assignField:
fieldExpr
;
atExpression:
AT expression
;
atPhrase:
AT ( atPhraseSub atPhraseSub | expression ) ( COLONALIGNED | LEFTALIGNED | RIGHTALIGNED )?
;
atPhraseSub:
( COLUMN | COLUMNS ) expression
| ( COLUMNOF | COLOF ) referencePoint
| ROW expression
| ROWOF referencePoint
| X expression
| XOF referencePoint
| Y expression
| YOF referencePoint
;
referencePoint:
fieldExpr ( ( PLUS | MINUS ) expression )?
;
bellStatement:
BELL statementEnd
;
blockLevelStatement:
BLOCKLEVEL ON ERROR UNDO COMMA THROW statementEnd
;
bufferCompareStatement:
BUFFERCOMPARE record exceptUsingFields? TO record
( CASESENSITIVE | BINARY )?
bufferCompareSave?
EXPLICIT?
(