-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added index for viewdoc * pushing first viewdoc * Added more formating for viewdoc * Added goornogo coverage test pipeline * Lowering minimum coverage by 0.1 % to pass on travis * change circle-ci to use goornogo * Merge from upstream * Now simple names is using Unicodes, hopefuly it covers most user's common letters * Added example to prove that function name, variable names are now accepting unicode in their identifier. * A little more test to check rule name and retraction can accept unicode.
Showing
14 changed files
with
1,008 additions
and
1,205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,80 @@ | ||
T__0=1 | ||
PLUS=2 | ||
MINUS=3 | ||
DIV=4 | ||
MUL=5 | ||
MOD=6 | ||
DOT=7 | ||
SEMICOLON=8 | ||
LR_BRACE=9 | ||
RR_BRACE=10 | ||
LR_BRACKET=11 | ||
RR_BRACKET=12 | ||
LS_BRACKET=13 | ||
RS_BRACKET=14 | ||
RULE=15 | ||
WHEN=16 | ||
THEN=17 | ||
AND=18 | ||
OR=19 | ||
TRUE=20 | ||
FALSE=21 | ||
NIL_LITERAL=22 | ||
NEGATION=23 | ||
SALIENCE=24 | ||
EQUALS=25 | ||
ASSIGN=26 | ||
PLUS_ASIGN=27 | ||
MINUS_ASIGN=28 | ||
DIV_ASIGN=29 | ||
MUL_ASIGN=30 | ||
GT=31 | ||
LT=32 | ||
GTE=33 | ||
LTE=34 | ||
NOTEQUALS=35 | ||
BITAND=36 | ||
BITOR=37 | ||
SIMPLENAME=38 | ||
DQUOTA_STRING=39 | ||
SQUOTA_STRING=40 | ||
DECIMAL_FLOAT_LIT=41 | ||
DECIMAL_EXPONENT=42 | ||
HEX_FLOAT_LIT=43 | ||
HEX_EXPONENT=44 | ||
DEC_LIT=45 | ||
HEX_LIT=46 | ||
OCT_LIT=47 | ||
SPACE=48 | ||
COMMENT=49 | ||
LINE_COMMENT=50 | ||
','=1 | ||
'+'=2 | ||
'-'=3 | ||
'/'=4 | ||
'*'=5 | ||
'%'=6 | ||
'.'=7 | ||
';'=8 | ||
'{'=9 | ||
'}'=10 | ||
'('=11 | ||
')'=12 | ||
'['=13 | ||
']'=14 | ||
'&&'=18 | ||
'||'=19 | ||
'!'=23 | ||
'=='=25 | ||
'='=26 | ||
'+='=27 | ||
'-='=28 | ||
'/='=29 | ||
'*='=30 | ||
'>'=31 | ||
'<'=32 | ||
'>='=33 | ||
'<='=34 | ||
'!='=35 | ||
'&'=36 | ||
'|'=37 | ||
T__0=1 | ||
PLUS=2 | ||
MINUS=3 | ||
DIV=4 | ||
MUL=5 | ||
MOD=6 | ||
DOT=7 | ||
SEMICOLON=8 | ||
LR_BRACE=9 | ||
RR_BRACE=10 | ||
LR_BRACKET=11 | ||
RR_BRACKET=12 | ||
LS_BRACKET=13 | ||
RS_BRACKET=14 | ||
RULE=15 | ||
WHEN=16 | ||
THEN=17 | ||
AND=18 | ||
OR=19 | ||
TRUE=20 | ||
FALSE=21 | ||
NIL_LITERAL=22 | ||
NEGATION=23 | ||
SALIENCE=24 | ||
EQUALS=25 | ||
ASSIGN=26 | ||
PLUS_ASIGN=27 | ||
MINUS_ASIGN=28 | ||
DIV_ASIGN=29 | ||
MUL_ASIGN=30 | ||
GT=31 | ||
LT=32 | ||
GTE=33 | ||
LTE=34 | ||
NOTEQUALS=35 | ||
BITAND=36 | ||
BITOR=37 | ||
SIMPLENAME=38 | ||
DQUOTA_STRING=39 | ||
SQUOTA_STRING=40 | ||
DECIMAL_FLOAT_LIT=41 | ||
DECIMAL_EXPONENT=42 | ||
HEX_FLOAT_LIT=43 | ||
HEX_EXPONENT=44 | ||
DEC_LIT=45 | ||
HEX_LIT=46 | ||
OCT_LIT=47 | ||
SPACE=48 | ||
COMMENT=49 | ||
LINE_COMMENT=50 | ||
','=1 | ||
'+'=2 | ||
'-'=3 | ||
'/'=4 | ||
'*'=5 | ||
'%'=6 | ||
'.'=7 | ||
';'=8 | ||
'{'=9 | ||
'}'=10 | ||
'('=11 | ||
')'=12 | ||
'['=13 | ||
']'=14 | ||
'&&'=18 | ||
'||'=19 | ||
'!'=23 | ||
'=='=25 | ||
'='=26 | ||
'+='=27 | ||
'-='=28 | ||
'/='=29 | ||
'*='=30 | ||
'>'=31 | ||
'<'=32 | ||
'>='=33 | ||
'<='=34 | ||
'!='=35 | ||
'&'=36 | ||
'|'=37 |
Large diffs are not rendered by default.
Oops, something went wrong.
160 changes: 80 additions & 80 deletions
160
antlr/parser/grulev3/grulev3Lexer.tokens
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,80 @@ | ||
T__0=1 | ||
PLUS=2 | ||
MINUS=3 | ||
DIV=4 | ||
MUL=5 | ||
MOD=6 | ||
DOT=7 | ||
SEMICOLON=8 | ||
LR_BRACE=9 | ||
RR_BRACE=10 | ||
LR_BRACKET=11 | ||
RR_BRACKET=12 | ||
LS_BRACKET=13 | ||
RS_BRACKET=14 | ||
RULE=15 | ||
WHEN=16 | ||
THEN=17 | ||
AND=18 | ||
OR=19 | ||
TRUE=20 | ||
FALSE=21 | ||
NIL_LITERAL=22 | ||
NEGATION=23 | ||
SALIENCE=24 | ||
EQUALS=25 | ||
ASSIGN=26 | ||
PLUS_ASIGN=27 | ||
MINUS_ASIGN=28 | ||
DIV_ASIGN=29 | ||
MUL_ASIGN=30 | ||
GT=31 | ||
LT=32 | ||
GTE=33 | ||
LTE=34 | ||
NOTEQUALS=35 | ||
BITAND=36 | ||
BITOR=37 | ||
SIMPLENAME=38 | ||
DQUOTA_STRING=39 | ||
SQUOTA_STRING=40 | ||
DECIMAL_FLOAT_LIT=41 | ||
DECIMAL_EXPONENT=42 | ||
HEX_FLOAT_LIT=43 | ||
HEX_EXPONENT=44 | ||
DEC_LIT=45 | ||
HEX_LIT=46 | ||
OCT_LIT=47 | ||
SPACE=48 | ||
COMMENT=49 | ||
LINE_COMMENT=50 | ||
','=1 | ||
'+'=2 | ||
'-'=3 | ||
'/'=4 | ||
'*'=5 | ||
'%'=6 | ||
'.'=7 | ||
';'=8 | ||
'{'=9 | ||
'}'=10 | ||
'('=11 | ||
')'=12 | ||
'['=13 | ||
']'=14 | ||
'&&'=18 | ||
'||'=19 | ||
'!'=23 | ||
'=='=25 | ||
'='=26 | ||
'+='=27 | ||
'-='=28 | ||
'/='=29 | ||
'*='=30 | ||
'>'=31 | ||
'<'=32 | ||
'>='=33 | ||
'<='=34 | ||
'!='=35 | ||
'&'=36 | ||
'|'=37 | ||
T__0=1 | ||
PLUS=2 | ||
MINUS=3 | ||
DIV=4 | ||
MUL=5 | ||
MOD=6 | ||
DOT=7 | ||
SEMICOLON=8 | ||
LR_BRACE=9 | ||
RR_BRACE=10 | ||
LR_BRACKET=11 | ||
RR_BRACKET=12 | ||
LS_BRACKET=13 | ||
RS_BRACKET=14 | ||
RULE=15 | ||
WHEN=16 | ||
THEN=17 | ||
AND=18 | ||
OR=19 | ||
TRUE=20 | ||
FALSE=21 | ||
NIL_LITERAL=22 | ||
NEGATION=23 | ||
SALIENCE=24 | ||
EQUALS=25 | ||
ASSIGN=26 | ||
PLUS_ASIGN=27 | ||
MINUS_ASIGN=28 | ||
DIV_ASIGN=29 | ||
MUL_ASIGN=30 | ||
GT=31 | ||
LT=32 | ||
GTE=33 | ||
LTE=34 | ||
NOTEQUALS=35 | ||
BITAND=36 | ||
BITOR=37 | ||
SIMPLENAME=38 | ||
DQUOTA_STRING=39 | ||
SQUOTA_STRING=40 | ||
DECIMAL_FLOAT_LIT=41 | ||
DECIMAL_EXPONENT=42 | ||
HEX_FLOAT_LIT=43 | ||
HEX_EXPONENT=44 | ||
DEC_LIT=45 | ||
HEX_LIT=46 | ||
OCT_LIT=47 | ||
SPACE=48 | ||
COMMENT=49 | ||
LINE_COMMENT=50 | ||
','=1 | ||
'+'=2 | ||
'-'=3 | ||
'/'=4 | ||
'*'=5 | ||
'%'=6 | ||
'.'=7 | ||
';'=8 | ||
'{'=9 | ||
'}'=10 | ||
'('=11 | ||
')'=12 | ||
'['=13 | ||
']'=14 | ||
'&&'=18 | ||
'||'=19 | ||
'!'=23 | ||
'=='=25 | ||
'='=26 | ||
'+='=27 | ||
'-='=28 | ||
'/='=29 | ||
'*='=30 | ||
'>'=31 | ||
'<'=32 | ||
'>='=33 | ||
'<='=34 | ||
'!='=35 | ||
'&'=36 | ||
'|'=37 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
579 changes: 293 additions & 286 deletions
579
antlr/parser/grulev3/grulev3_lexer.go
100755 → 100644
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
959 changes: 454 additions & 505 deletions
959
antlr/parser/grulev3/grulev3_parser.go
100755 → 100644
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package examples | ||
|
||
import ( | ||
"fmt" | ||
"github.com/hyperjumptech/grule-rule-engine/ast" | ||
"github.com/hyperjumptech/grule-rule-engine/builder" | ||
"github.com/hyperjumptech/grule-rule-engine/engine" | ||
"github.com/hyperjumptech/grule-rule-engine/pkg" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
"time" | ||
) | ||
|
||
type MyḞact struct { | ||
IntAttribute int64 | ||
StringǍttribute string | ||
BooleanAttribute bool | ||
ḞloatAttribute float64 | ||
TimeAttribute time.Time | ||
WhatToSay string | ||
} | ||
|
||
func (mf *MyḞact) GetẀhatToSay(sentence string) string { | ||
return fmt.Sprintf("Let say \"%s\"", sentence) | ||
} | ||
|
||
func TestUnicodeTutorial(t *testing.T) { | ||
myFact := &MyḞact{ | ||
IntAttribute: 123, | ||
StringǍttribute: "Some string vǍlue", | ||
BooleanAttribute: true, | ||
ḞloatAttribute: 1.234, | ||
TimeAttribute: time.Now(), | ||
} | ||
dataCtx := ast.NewDataContext() | ||
err := dataCtx.Add("MḞ", myFact) | ||
assert.NoError(t, err) | ||
|
||
// Prepare knowledgebase library and load it with our rule. | ||
knowledgeLibrary := ast.NewKnowledgeLibrary() | ||
ruleBuilder := builder.NewRuleBuilder(knowledgeLibrary) | ||
|
||
drls := ` | ||
rule ChĕckValuĕs "Check the default values" salience 10 { | ||
when | ||
MḞ.IntAttribute == 123 && MḞ.StringǍttribute == "Some string vǍlue" | ||
then | ||
MḞ.WhatToSay = MḞ.GetẀhatToSay("HellǑ Grule"); | ||
Retract("ChĕckValuĕs"); | ||
} | ||
` | ||
byteArr := pkg.NewBytesResource([]byte(drls)) | ||
err = ruleBuilder.BuildRuleFromResource("Tutorial", "0.0.1", byteArr) | ||
assert.NoError(t, err) | ||
|
||
knowledgeBase := knowledgeLibrary.NewKnowledgeBaseInstance("Tutorial", "0.0.1") | ||
|
||
engine := engine.NewGruleEngine() | ||
err = engine.Execute(dataCtx, knowledgeBase) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "Let say \"HellǑ Grule\"", myFact.WhatToSay) | ||
println(myFact.WhatToSay) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters