@@ -26,15 +26,11 @@ directiveParenthesizedExpression
2626 : ' (' WS ? directiveExpression WS ? ' )'
2727 ;
2828
29- directiveUnaryMinusExpression
30- : ' -' WS ? directiveExpression
31- ;
32-
3329directiveLiteralExpression
34- : DATELITERAL
35- | FLOATLITERAL
36- | INTEGERLITERAL
37- | STRINGLITERAL
30+ : LITDATE
31+ | LITFLOAT
32+ | LITINTEGER
33+ | LITSTRING
3834 | literalIdentifier
3935 ;
4036
@@ -58,29 +54,31 @@ variantLiteralIdentifier
5854 | NULL_
5955 ;
6056
57+ // Operators
58+ orderOfOps1 : DIVD | MULT ;
59+ orderOfOps2 : MOD ;
60+ orderOfOps3 : PLUS | SUBT ;
61+ orderOfOps4 : AMP ;
62+ orderOfOps5 : LIKE | (LT | GT )? (LT | GT | EQ ) | EQ ;
63+ orderOfOps6 : AND | OR | XOR | EQV | IMP ;
64+
65+
6166directiveExpression
6267 : directiveLiteralExpression
6368 | directiveParenthesizedExpression
64- | directiveUnaryMinusExpression
65- // | directiveExpression wsc? (divOperator | multOperator) wsc? directiveExpression
66- // | directiveExpression wsc? modOperator wsc? directiveExpression
67- // | directiveExpression wsc? (plusOperator | minusOperator) wsc? directiveExpression
68- // | directiveExpression wsc? ampOperator wsc? directiveExpression
69- // | directiveExpression wsc? (
70- // IS
71- // | LIKE
72- // | geqOperator
73- // | leqOperator
74- // | gtOperator
75- // | ltOperator
76- // | neqOperator
77- // | eqOperator
78- // ) wsc? directiveExpression
79- // | notOperatorExpression
80- // | directiveExpression wsc? (andOperator | orOperator | xorOperator | eqvOperator | impOperator) wsc? directiveExpression
81- // | lExpression
69+ | directiveExpression WS ? orderOfOps1 WS ? directiveExpression
70+ | directiveExpression WS ? orderOfOps2 WS ? directiveExpression
71+ | directiveExpression WS ? orderOfOps3 WS ? directiveExpression
72+ | directiveExpression WS ? orderOfOps4 WS ? directiveExpression
73+ | directiveExpression WS ? orderOfOps5 WS ? directiveExpression
74+ | notDirectiveExpression
75+ | directiveExpression WS ? orderOfOps6 WS ? directiveExpression
76+ | unreservedWord
8277 ;
8378
79+ notDirectiveExpression
80+ : NOT WS directiveExpression;
81+
8482constDirectiveStatement
8583 : CONST WS constDirectiveName WS ? EQ WS ? directiveExpression endOfStatement
8684 ;
@@ -131,7 +129,7 @@ booleanExpression
131129 ;
132130
133131booleanPart
134- : WS ? (AND | OR | XOR | EQV | IMP )? WS ? NOT ? WS ? (compilerConstant | anyWord )
132+ : WS ? (AND | OR | XOR | EQV | IMP )? WS ? NOT ? WS ? (compilerConstant | unreservedWord )
135133 ;
136134
137135compilerConstant
@@ -143,18 +141,34 @@ compilerConstant
143141 | MAC
144142 ;
145143
146- anyWord : (
147- ANYCHARS
148- | EQ
149- | STRINGLITERAL
150- | FLOATLITERAL
151- | DATELITERAL
152- | TRUE
153- | FALSE
154- | NOTHING
155- | EMPTY_X
156- | NULL_
157- )+;
144+ reservedWord
145+ : AMP
146+ | AND
147+ | AS
148+ | DIVD
149+ | EMPTY_X
150+ | EQ
151+ | MOD
152+ | MULT
153+ | PLUS
154+ | SUBT
155+ | THEN
156+ | compilerConstant
157+ ;
158+
159+ unreservedWord
160+ : ANYCHARS
161+ | FALSE
162+ | LITDATE
163+ | LITINTEGER
164+ | LITSTRING
165+ | LITFLOAT
166+ | NOTHING
167+ | NULL_
168+ | TRUE
169+ ;
170+
171+ anyWord : ( unreservedWord | reservedWord)+;
158172
159173anyOtherLine
160174 : (WS * anyWord)+
@@ -175,7 +189,7 @@ endOfStatement
175189commentBody : COMMENT ;
176190remStatement : REMCOMMENT ;
177191
178- // wsc : (WS | LINE_CONTINUATION)+;
192+ // WS : (WS | LINE_CONTINUATION)+;
179193
180194
181195
240254 : ' MAC'
241255 ;
242256
257+ MULT : ' *' ;
258+ DIVD : INTDIV | DBLDIV ;
259+ MOD : ' MOD' ;
260+ PLUS : ' +' ;
261+ SUBT : ' -' ;
262+ AMP : ' &' ;
263+ LIKE : ' LIKE' ;
264+ LT : ' <' ;
265+ GT : ' >' ;
266+
267+ fragment INTDIV : ' \\ ' ;
268+ fragment DBLDIV : ' /' ;
269+
243270REMCOMMENT
244271 : COLON ? REM WS (LINE_CONTINUATION | ~[\r\n\u2028\u2029])*
245272 ;
@@ -324,17 +351,17 @@ EMPTY_X
324351 : ' EMPTY'
325352 ;
326353
327- STRINGLITERAL
354+ LITSTRING
328355 : ' "' (~[" \r\n ] | '" " ')* '" '
329356 ;
330357
331- INTEGERLITERAL
332- : (DIGIT DIGIT* | ' &H ' [0-9A-F]+ | ' &' [O]? [0-7]+) [%&^]?
358+ LITINTEGER
359+ : ' - ' ? (DIGIT DIGIT* | ' &H ' [0-9A-F]+ | ' &' [O]? [0-7]+) [%&^]?
333360 ;
334361
335- FLOATLITERAL
336- : FLOATINGPOINTLITERAL [!#@]?
337- | DECIMALLITERAL [!#@]
362+ LITFLOAT
363+ : ' - ' ? FLOATINGPOINTLITERAL [!#@]?
364+ | ' - ' ? DECIMALLITERAL [!#@]
338365 ;
339366
340367fragment FLOATINGPOINTLITERAL
@@ -347,7 +374,7 @@ fragment DECIMALLITERAL
347374 : DIGIT DIGIT*
348375 ;
349376
350- DATELITERAL
377+ LITDATE
351378 : ' #' DATEORTIME ' #'
352379 ;
353380
0 commit comments