mirror of
https://github.com/abcv7/sfbx-cloud.git
synced 2026-08-16 19:49:49 +00:00
first commit
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
lexer grammar RuleLexer;
|
||||
|
||||
COUNT : 'count';
|
||||
|
||||
AVG : 'avg';
|
||||
|
||||
SUM : 'sum';
|
||||
|
||||
MAX : 'max';
|
||||
|
||||
MIN : 'min';
|
||||
|
||||
AND : 'and'|'&&'|','|'\u5e76\u4e14'|'\u4e14';
|
||||
OR : 'or'|'||'|'\u6216\u8005'|'\u6216';
|
||||
|
||||
Datatype : 'String'
|
||||
| 'int'
|
||||
| 'Integer'
|
||||
| 'double'
|
||||
| 'Double'
|
||||
| 'long'
|
||||
| 'Long'
|
||||
| 'float'
|
||||
| 'Float'
|
||||
| 'BigDecimal'
|
||||
| 'boolean'
|
||||
| 'Boolean'
|
||||
| 'Date'
|
||||
| 'List'
|
||||
| 'Set'
|
||||
| 'Map'
|
||||
| 'Enum'
|
||||
| 'Object'
|
||||
;
|
||||
|
||||
GreaterThen : '>'|'\u5927\u4e8e';
|
||||
|
||||
GreaterThenOrEquals : '>='|'\u5927\u4e8e\u7b49\u4e8e';
|
||||
|
||||
LessThen : '<'|'\u5c0f\u4e8e';
|
||||
|
||||
LessThenOrEquals : '<='|'\u5c0f\u4e8e\u7b49\u4e8e';
|
||||
|
||||
Equals : '=='|'\u7b49\u4e8e';
|
||||
|
||||
NotEquals : '!='|'\u4e0d\u7b49\u4e8e';
|
||||
|
||||
EndWith : 'EndWith'|'\u7ed3\u675f\u4e8e';
|
||||
|
||||
NotEndWith : 'NotEndWith'|'\u4e0d\u7ed3\u675f\u4e8e' ;
|
||||
|
||||
StartWith : 'StartWith'|'\u5f00\u59cb\u4e8e';
|
||||
|
||||
NotStartWith : 'NotStartWith'|'\u4e0d\u5f00\u59cb\u4e8e';
|
||||
|
||||
In : 'In'|'\u5728\u96c6\u5408\u4e2d';
|
||||
|
||||
NotIn : 'NotIn'|'\u4e0d\u5728\u96c6\u5408\u4e2d';
|
||||
|
||||
Match : 'Match'|'\u5339\u914d';
|
||||
|
||||
NotMatch : 'NotMatch'|'\u4e0d\u5339\u914d';
|
||||
|
||||
EqualsIgnoreCase : 'EqualsIgnoreCase'|'\u5ffd\u7565\u5927\u5c0f\u5199\u7b49\u4e8e';
|
||||
|
||||
NotEqualsIgnoreCase : 'NotEqualsIgnoreCase'|'\u5ffd\u7565\u5927\u5c0f\u5199\u4e0d\u7b49\u4e8e';
|
||||
|
||||
ARITH
|
||||
:
|
||||
'+'
|
||||
| '-'
|
||||
| '*'
|
||||
| '/'
|
||||
| '%'
|
||||
;
|
||||
|
||||
NUMBER
|
||||
:
|
||||
'-'? INT '.' INT EXP? // ('-'? INT '.' INT EXP?)1.35, 1.35E-9, 0.3, -4.5
|
||||
| '-'? INT EXP // 1e10 -3e4
|
||||
| '-'? INT // -3, 45
|
||||
;
|
||||
|
||||
Boolean : 'true'
|
||||
| 'false'
|
||||
;
|
||||
|
||||
Identifier
|
||||
:
|
||||
StartChar Char*
|
||||
;
|
||||
|
||||
STRING :
|
||||
'"' STRING_CONTENT '"'
|
||||
;
|
||||
|
||||
|
||||
fragment
|
||||
STRING_CONTENT :
|
||||
( EscapeSequence | ~('"'))*
|
||||
;
|
||||
|
||||
|
||||
fragment
|
||||
INT
|
||||
:
|
||||
DIGIT+
|
||||
;
|
||||
|
||||
fragment
|
||||
EXP
|
||||
:
|
||||
[Ee] [+\-]? INT
|
||||
; // \- since - means "range" inside [...]
|
||||
|
||||
fragment
|
||||
EscapeSequence
|
||||
: '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
|
||||
| UnicodeEscape
|
||||
| OctalEscape
|
||||
;
|
||||
|
||||
fragment
|
||||
OctalEscape
|
||||
: '\\' ('0'..'3') ('0'..'7') ('0'..'7')
|
||||
| '\\' ('0'..'7') ('0'..'7')
|
||||
| '\\' ('0'..'7')
|
||||
;
|
||||
|
||||
fragment
|
||||
UnicodeEscape
|
||||
:
|
||||
'\\' 'u' HEX HEX HEX HEX
|
||||
;
|
||||
|
||||
fragment
|
||||
Char : StartChar
|
||||
| '-' | '_' | DIGIT
|
||||
| '\u00B7'
|
||||
| '\u0300'..'\u036F'
|
||||
| '\u203F'..'\u2040'
|
||||
;
|
||||
|
||||
fragment
|
||||
StartChar
|
||||
: [a-zA-Z]
|
||||
| '\u2070'..'\u218F'
|
||||
| '\u2C00'..'\u2FEF'
|
||||
| '\u3001'..'\uD7FF'
|
||||
| '\uF900'..'\uFDCF'
|
||||
| '\uFDF0'..'\uFFFD'
|
||||
;
|
||||
|
||||
fragment
|
||||
DIGIT
|
||||
:
|
||||
[0-9]
|
||||
;
|
||||
|
||||
fragment
|
||||
HEX
|
||||
:
|
||||
[0-9a-fA-F]
|
||||
;
|
||||
|
||||
WS
|
||||
:
|
||||
[ \t\r\n]+ -> channel(HIDDEN)
|
||||
;
|
||||
|
||||
NL
|
||||
:
|
||||
'\r'? '\n' ->channel(HIDDEN)
|
||||
;
|
||||
|
||||
|
||||
COMMENT
|
||||
: '/*' .*? '*/' ->channel(HIDDEN);
|
||||
|
||||
LINE_COMMENT
|
||||
: '//' ~[\r\n]* '\r'? '\n' ->channel(HIDDEN)
|
||||
;
|
||||
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
grammar RuleParser;
|
||||
|
||||
import RuleLexer;
|
||||
|
||||
ruleSet : ruleSetHeader
|
||||
ruleSetBody
|
||||
;
|
||||
|
||||
ruleSetHeader : resource*
|
||||
| functionImport*
|
||||
| resource* functionImport*
|
||||
| functionImport* resource*
|
||||
;
|
||||
|
||||
ruleSetBody : rules* ;
|
||||
|
||||
rules : ruleDef | loopRuleDef ;
|
||||
|
||||
functionImport : 'import' packageDef';'?;
|
||||
|
||||
packageDef : Identifier
|
||||
| Identifier('.'Identifier)+
|
||||
| packageDef'.*';
|
||||
|
||||
resource : importVariableLibrary
|
||||
| importActionLibrary
|
||||
| importConstantLibrary
|
||||
| importParameterLibrary
|
||||
;
|
||||
|
||||
importParameterLibrary : 'importParameterLibrary' STRING ';'?;
|
||||
|
||||
importVariableLibrary : 'importVariableLibrary' STRING ';'?;
|
||||
|
||||
importConstantLibrary : 'importConstantLibrary' STRING ';'?;
|
||||
|
||||
importActionLibrary : 'importActionLibrary' STRING ';'?;
|
||||
|
||||
functionDef : 'function' Identifier '(' functionParameters? ')' '{' expressionBody '}'';'?;
|
||||
|
||||
functionParameters : functionParameter (','functionParameter)* ;
|
||||
|
||||
functionParameter : Datatype Identifier ;
|
||||
|
||||
ruleDef : ('rule'|'\u89c4\u5219') STRING
|
||||
attribute*
|
||||
left
|
||||
right
|
||||
other?
|
||||
('end'|'\u7ed3\u675f') ';'?
|
||||
;
|
||||
|
||||
loopRuleDef : ('loopRule' | '\u5faa\u73af\u89c4\u5219') STRING
|
||||
attribute*
|
||||
loopTarget
|
||||
loopStart?
|
||||
left
|
||||
right
|
||||
other?
|
||||
loopEnd?
|
||||
('end'|'\u7ed3\u675f') ';'?
|
||||
;
|
||||
|
||||
loopTarget : ('loopTarget' | '\u5faa\u73af\u5bf9\u8c61') complexValue ;
|
||||
|
||||
loopStart : ('loopStart' | '\u5f00\u59cb\u524d\u52a8\u4f5c') action* ;
|
||||
|
||||
loopEnd : ('loopEnd' | '\u7ed3\u675f\u540e\u52a8\u4f5c') action*;
|
||||
|
||||
|
||||
attribute :loopAttribute
|
||||
| salienceAttribute
|
||||
| effectiveDateAttribute
|
||||
| expiresDateAttribute
|
||||
| enabledAttribute
|
||||
| debugAttribute
|
||||
| activationGroupAttribute
|
||||
| agendaGroupAttribute
|
||||
| autoFocusAttribute
|
||||
| ruleflowGroupAttribute
|
||||
;
|
||||
|
||||
loopAttribute : ('loop' | '\u5141\u8bb8\u5faa\u73af\u89e6\u53d1') '=' Boolean ','?;
|
||||
salienceAttribute : ('salience' | '\u4f18\u5148\u7ea7') '=' NUMBER ','?;
|
||||
effectiveDateAttribute : ('effective-date' | '\u751f\u6548\u65f6\u95f4' | '\u751f\u6548\u65e5\u671f') '=' STRING ','?;
|
||||
expiresDateAttribute : ('expires-date' | '\u5931\u6548\u65f6\u95f4' | '\u5931\u6548\u65e5\u671f') '=' STRING ','?;
|
||||
enabledAttribute : ('enabled' | '\u6fc0\u6d3b' | '\u542f\u7528') '=' Boolean ','?;
|
||||
debugAttribute : ('debug' | '\u8c03\u8bd5' | '\u5141\u8bb8\u8c03\u8bd5') '=' Boolean ','?;
|
||||
activationGroupAttribute : ('activation-group' | '\u6fc0\u6d3b\u7ec4') '=' STRING ','? ;
|
||||
agendaGroupAttribute : ('agenda-group' | '\u8bae\u7a0b\u7ec4') '=' STRING ','? ;
|
||||
autoFocusAttribute : ('auto-focus' | '\u81ea\u52a8\u83b7\u53d6\u7126\u70b9') '=' Boolean ','?;
|
||||
ruleflowGroupAttribute : ('ruleflow-group' | '\u89c4\u5219\u6d41\u7ec4') '=' STRING ','?;
|
||||
|
||||
left :
|
||||
('if'|'\u5982\u679c')
|
||||
condition?
|
||||
;
|
||||
|
||||
|
||||
condition : leftParen condition rightParen #parenConditions
|
||||
| condition (join condition)+ #multiConditions
|
||||
| conditionLeft op (complexValue|nullValue) #singleCondition
|
||||
| namedConditionSet #singleNamedConditionSet
|
||||
;
|
||||
|
||||
namedConditionSet : (refName colon)? refObject leftParen namedCondition rightParen;
|
||||
|
||||
namedCondition : leftParen namedCondition rightParen #parenNamedConditions
|
||||
| namedCondition (join namedCondition)+ #multiNamedConditions
|
||||
| property op (complexValue|nullValue) #singleNamedConditions
|
||||
;
|
||||
|
||||
|
||||
decisionTableCellCondition : op (complexValue|nullValue) #singleCellCondition
|
||||
| decisionTableCellCondition (join decisionTableCellCondition)+ #multiCellConditions
|
||||
| leftParen decisionTableCellCondition rightParen #parenCellConditions
|
||||
;
|
||||
|
||||
refName : Identifier ;
|
||||
|
||||
refObject : variableCategory | parameterName ;
|
||||
|
||||
|
||||
nullValue : 'null';
|
||||
|
||||
conditionLeft : (variable|parameter|functionInvoke|methodInvoke|expEval|expAll|expExists|expCollect|commonFunction) (ARITH value)* ;
|
||||
|
||||
expEval : 'eval'leftParen expressionBody rightParen;
|
||||
|
||||
expAll : 'all'leftParen
|
||||
(variable|parameter)
|
||||
',' exprCondition
|
||||
(',' (NUMBER|percent))?
|
||||
rightParen;
|
||||
|
||||
expExists : 'exist'leftParen
|
||||
(variable|parameter)
|
||||
',' exprCondition
|
||||
(',' (NUMBER|percent))?
|
||||
rightParen;
|
||||
|
||||
expCollect : 'collect'leftParen
|
||||
(variable|parameter)
|
||||
(',' exprCondition)?
|
||||
rightParen
|
||||
'.'
|
||||
( COUNT | property'.'(SUM|AVG|MAX|MIN))
|
||||
;
|
||||
|
||||
commonFunction : Identifier leftParen complexValue(','property)? rightParen ;
|
||||
|
||||
|
||||
exprCondition : property op (complexValue|nullValue)
|
||||
| exprCondition (join exprCondition)+
|
||||
;
|
||||
|
||||
expressionBody : .*? ;
|
||||
|
||||
percent : NUMBER'%';
|
||||
|
||||
leftParen : '(';
|
||||
|
||||
rightParen : ')';
|
||||
|
||||
colon : ':';
|
||||
|
||||
|
||||
join :
|
||||
AND
|
||||
| OR
|
||||
;
|
||||
|
||||
right : ('then'|'\u90a3\u4e48')
|
||||
action*
|
||||
;
|
||||
other : ('else'|'\u5426\u5219')
|
||||
action*
|
||||
;
|
||||
|
||||
actions : action*;
|
||||
|
||||
action : assignAction ';'?
|
||||
| outAction ';'?
|
||||
| methodInvoke ';'?
|
||||
| functionInvoke ';'?
|
||||
| commonFunction ';'?
|
||||
;
|
||||
|
||||
assignAction : (variable|namedVariable|parameter) '=' complexValue;
|
||||
|
||||
outAction : 'out''(' complexValue ')';
|
||||
|
||||
methodInvoke : beanMethod'('actionParameters?')';
|
||||
|
||||
functionInvoke : '@'Identifier'(' actionParameters? ')';
|
||||
|
||||
actionParameters : complexValue (',' complexValue)* ;
|
||||
|
||||
beanMethod : Identifier'.'Identifier ;
|
||||
|
||||
complexValue : value
|
||||
| variable
|
||||
| namedVariable
|
||||
| constant
|
||||
| variableCategory
|
||||
| parameter
|
||||
| methodInvoke
|
||||
| functionInvoke
|
||||
| commonFunction
|
||||
| leftParen complexValue rightParen
|
||||
| complexValue (ARITH complexValue)+
|
||||
;
|
||||
|
||||
parameter : parameterName'.'Identifier;
|
||||
|
||||
parameterName : 'parameter'|'\u53c2\u6570' ;
|
||||
|
||||
constant : constantCategory'.'property;
|
||||
|
||||
variable : variableCategory'.'property;
|
||||
|
||||
namedVariable : namedVariableCategory'.'property;
|
||||
|
||||
property : Identifier('.'Identifier)*;
|
||||
|
||||
variableCategory : Identifier;
|
||||
|
||||
namedVariableCategory : '!'Identifier;
|
||||
|
||||
constantCategory : '$'Identifier;
|
||||
|
||||
value :
|
||||
STRING
|
||||
| NUMBER
|
||||
| Boolean
|
||||
;
|
||||
op
|
||||
:
|
||||
GreaterThen
|
||||
| GreaterThenOrEquals
|
||||
| LessThen
|
||||
| LessThenOrEquals
|
||||
| Equals
|
||||
| NotEquals
|
||||
| EndWith
|
||||
| NotEndWith
|
||||
| StartWith
|
||||
| NotStartWith
|
||||
| In
|
||||
| NotIn
|
||||
| Match
|
||||
| NotMatch
|
||||
| EqualsIgnoreCase
|
||||
| NotEqualsIgnoreCase
|
||||
;
|
||||
Reference in New Issue
Block a user