Added more tests
This commit is contained in:
parent
b20a79080f
commit
f870a5f1f8
5 changed files with 73 additions and 30 deletions
|
@ -16,27 +16,29 @@ type Operator struct {
|
|||
// Operators defines the operators used in the language.
|
||||
// The number corresponds to the operator priority and can not be zero.
|
||||
var Operators = map[string]*Operator{
|
||||
".": {".", 13, 2},
|
||||
"λ": {"λ", 12, 1},
|
||||
"!": {"!", 11, 1},
|
||||
"*": {"*", 10, 2},
|
||||
"/": {"/", 10, 2},
|
||||
"%": {"%", 10, 2},
|
||||
"+": {"+", 9, 2},
|
||||
"-": {"-", 9, 2},
|
||||
">>": {">>", 8, 2},
|
||||
"<<": {"<<", 8, 2},
|
||||
">": {">", 7, 2},
|
||||
"<": {"<", 7, 2},
|
||||
">=": {">=", 7, 2},
|
||||
"<=": {"<=", 7, 2},
|
||||
"==": {"==", 6, 2},
|
||||
"!=": {"!=", 6, 2},
|
||||
"&": {"&", 5, 2},
|
||||
"^": {"^", 4, 2},
|
||||
"|": {"|", 3, 2},
|
||||
"&&": {"&&", 2, 2},
|
||||
"||": {"||", 1, 2},
|
||||
".": {".", 13, 2},
|
||||
"λ": {"λ", 12, 1},
|
||||
"!": {"!", 11, 1},
|
||||
"*": {"*", 10, 2},
|
||||
"/": {"/", 10, 2},
|
||||
"%": {"%", 10, 2},
|
||||
"+": {"+", 9, 2},
|
||||
"-": {"-", 9, 2},
|
||||
">>": {">>", 8, 2},
|
||||
"<<": {"<<", 8, 2},
|
||||
"&": {"&", 7, 2},
|
||||
"^": {"^", 6, 2},
|
||||
"|": {"|", 5, 2},
|
||||
|
||||
">": {">", 4, 2},
|
||||
"<": {"<", 4, 2},
|
||||
">=": {">=", 4, 2},
|
||||
"<=": {"<=", 4, 2},
|
||||
"==": {"==", 3, 2},
|
||||
"!=": {"!=", 3, 2},
|
||||
"&&": {"&&", 2, 2},
|
||||
"||": {"||", 1, 2},
|
||||
|
||||
"=": {"=", math.MinInt, 2},
|
||||
":=": {":=", math.MinInt, 2},
|
||||
"+=": {"+=", math.MinInt, 2},
|
||||
|
@ -56,7 +58,7 @@ func isComplete(expr *Expression) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
if expr.Token.Kind == token.Operator && len(expr.Children) >= numOperands(expr.Token.Text()) {
|
||||
if expr.Token.Kind == token.Operator && len(expr.Children) == numOperands(expr.Token.Text()) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue