Skip to content

Commit

Permalink
[ADH-5405] Fix rule parser
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrulya-exe committed Dec 10, 2024
1 parent 9a8d988 commit b1dedb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
18 changes: 6 additions & 12 deletions smart-rule/src/main/antlr4/org/smartdata/rule/parser/SmartRule.g4
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ boolvalue

compareexpr
: numricexpr OPCMP numricexpr #cmpIdLong
| stringexpr OPEQCMP stringexpr #cmpIdString
| numricexpr OPEQ numricexpr #cmpEqIdLong
| stringexpr OPEQ stringexpr #cmpIdString
| stringexpr MATCHES stringexpr #cmpIdStringMatches
| timeintvalexpr OPCMP timeintvalexpr #cmpTimeintvalTimeintval
| timeintvalexpr OPEQ timeintvalexpr #cmpEqTimeintvalTimeintval
| timepointexpr OPCMP timepointexpr #cmpTimepointTimePoint
| timepointexpr OPEQ timepointexpr #cmpEqTimepointTimePoint
;

timeintvalexpr
Expand Down Expand Up @@ -128,27 +131,18 @@ id
| OBJECTTYPE '.' ID '(' constexpr (',' constexpr)* ')' #idObjAttPara
;

OPEQCMP
OPEQ
: '=='
| '!='
;

OPCMP
: OPEQCMP
| '>'
: '>'
| '<'
| '>='
| '<='
;

opr
: '*'
| '/'
| '+'
| '-'
| '%'
;

fileEvent
: FILECREATE
| FILECLOSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public void testValidRule() throws Exception {
rules.add("file : every 1s | storagePolicy == \"ALL_SSD\" | cache");
rules.add("file : accessCount(10min) < 20 | uncache");
rules.add("file : accessCount(10min) == 0 | uncache");
rules.add("file : accessCount(10min) != 0 | uncache");
rules.add("file : accessCount(10min) <= 1 | uncache");
rules.add("file : accessCount(1min) > 5 | cache -replica 2");
rules.add("file : age <= 1 | echo -msg \"crul world\"");
Expand Down

0 comments on commit b1dedb6

Please sign in to comment.