diff --git a/examples/lang/hysteresis1.mcl b/examples/lang/hysteresis1.mcl index ae643ddd..2eee093c 100644 --- a/examples/lang/hysteresis1.mcl +++ b/examples/lang/hysteresis1.mcl @@ -14,7 +14,7 @@ $threshold = 1.5 # change me if you like $h1 = $theload > $threshold $h2 = $theload{1} > $threshold $h3 = $theload{2} > $threshold -$unload = $h1 || $h2 || $h3 +$unload = $h1 or $h2 or $h3 virt "mgmt1" { uri => "qemu:///session", diff --git a/examples/lang/map-iterator1.mcl b/examples/lang/map-iterator1.mcl index 86165229..362d32a8 100644 --- a/examples/lang/map-iterator1.mcl +++ b/examples/lang/map-iterator1.mcl @@ -9,7 +9,7 @@ $mod0 = math.mod($now, 8) == 0 $mod1 = math.mod($now, 8) == 1 $mod2 = math.mod($now, 8) == 2 $mod3 = math.mod($now, 8) == 3 -$mod = $mod0 || $mod1 || $mod2 || $mod3 +$mod = $mod0 or $mod1 or $mod2 or $mod3 $fn = func($x) { # notable because concrete type is fn(t1) t2, where t1 != t2 len($x) diff --git a/examples/lang/map-iterator2.mcl b/examples/lang/map-iterator2.mcl index 917d24f5..09e7ff46 100644 --- a/examples/lang/map-iterator2.mcl +++ b/examples/lang/map-iterator2.mcl @@ -9,13 +9,13 @@ $mod0 = math.mod($now, 8) == 0 $mod1 = math.mod($now, 8) == 1 $mod2 = math.mod($now, 8) == 2 $mod3 = math.mod($now, 8) == 3 -$moda = $mod0 || $mod1 || $mod2 || $mod3 +$moda = $mod0 or $mod1 or $mod2 or $mod3 $mod4 = math.mod($now, 8) == 4 $mod5 = math.mod($now, 8) == 5 $mod6 = math.mod($now, 8) == 6 $mod7 = math.mod($now, 8) == 7 -$modb = $mod4 || $mod5 || $mod6 || $mod7 +$modb = $mod4 or $mod5 or $mod6 or $mod7 $fn = if $moda { func($x) { # notable because concrete type is fn(t1) t2, where t1 != t2 diff --git a/examples/lang/readonlyfriday.mcl b/examples/lang/readonlyfriday.mcl index 581cfa7b..b43a9f99 100644 --- a/examples/lang/readonlyfriday.mcl +++ b/examples/lang/readonlyfriday.mcl @@ -9,7 +9,7 @@ $s1 = template("Hello! It is now: {{ datetime_print . }}\n", $now) $s2 = if $is_friday { "It's friday!!! (don't break anything, read-only)" } else { - if $day == "saturday" || $day == "sunday" { + if $day == "saturday" or $day == "sunday" { "It's the weekend!" } else { fmt.printf("Unfortunately, it is %s. Go to work!", $day) diff --git a/examples/lang/reverse1.mcl b/examples/lang/reverse1.mcl index 8579ec52..b715cf1e 100644 --- a/examples/lang/reverse1.mcl +++ b/examples/lang/reverse1.mcl @@ -8,7 +8,7 @@ $mod0 = math.mod($now, 8) == 0 $mod1 = math.mod($now, 8) == 1 $mod2 = math.mod($now, 8) == 2 $mod3 = math.mod($now, 8) == 3 -$mod = $mod0 || $mod1 || $mod2 || $mod3 +$mod = $mod0 or $mod1 or $mod2 or $mod3 file "/tmp/mgmt/" { state => $const.res.file.state.exists, diff --git a/examples/lang/reverse2.mcl b/examples/lang/reverse2.mcl index 5e6203e5..fca66776 100644 --- a/examples/lang/reverse2.mcl +++ b/examples/lang/reverse2.mcl @@ -8,7 +8,7 @@ $mod0 = math.mod($now, 8) == 0 $mod1 = math.mod($now, 8) == 1 $mod2 = math.mod($now, 8) == 2 $mod3 = math.mod($now, 8) == 3 -$mod = $mod0 || $mod1 || $mod2 || $mod3 +$mod = $mod0 or $mod1 or $mod2 or $mod3 file "/tmp/mgmt/" { state => $const.res.file.state.exists, diff --git a/examples/lang/reverse3.mcl b/examples/lang/reverse3.mcl index 16b29437..9cb3fe4b 100644 --- a/examples/lang/reverse3.mcl +++ b/examples/lang/reverse3.mcl @@ -8,7 +8,7 @@ $mod0 = math.mod($now, 8) == 0 $mod1 = math.mod($now, 8) == 1 $mod2 = math.mod($now, 8) == 2 $mod3 = math.mod($now, 8) == 3 -$mod = $mod0 || $mod1 || $mod2 || $mod3 +$mod = $mod0 or $mod1 or $mod2 or $mod3 file "/tmp/mgmt/" { state => $const.res.file.state.exists, diff --git a/examples/lang/states0.mcl b/examples/lang/states0.mcl index 1a3a59a1..db856860 100644 --- a/examples/lang/states0.mcl +++ b/examples/lang/states0.mcl @@ -4,7 +4,7 @@ $ns = "estate" $exchanged = world.kvlookup($ns) $state = maplookup($exchanged, $hostname, "default") -if $state == "one" || $state == "default" { +if $state == "one" or $state == "default" { file "/tmp/mgmt/state" { state => $const.res.file.state.exists, diff --git a/lang/funcs/operator_func.go b/lang/funcs/operator_func.go index 018c54c6..3cd69bb5 100644 --- a/lang/funcs/operator_func.go +++ b/lang/funcs/operator_func.go @@ -295,7 +295,7 @@ func init() { // logical and // TODO: is there a way for the engine to have // short-circuit operators, and does it matter? - RegisterOperator("&&", &types.FuncValue{ + RegisterOperator("and", &types.FuncValue{ T: types.NewType("func(a bool, b bool) bool"), V: func(input []types.Value) (types.Value, error) { return &types.BoolValue{ @@ -304,7 +304,7 @@ func init() { }, }) // logical or - RegisterOperator("||", &types.FuncValue{ + RegisterOperator("or", &types.FuncValue{ T: types.NewType("func(a bool, b bool) bool"), V: func(input []types.Value) (types.Value, error) { return &types.BoolValue{ @@ -314,7 +314,7 @@ func init() { }) // logical not (unary operator) - RegisterOperator("!", &types.FuncValue{ + RegisterOperator("not", &types.FuncValue{ T: types.NewType("func(a bool) bool"), V: func(input []types.Value) (types.Value, error) { return &types.BoolValue{ diff --git a/lang/interpret_test/TestAstFunc1/slow_unification0.txtar b/lang/interpret_test/TestAstFunc1/slow_unification0.txtar index adc5a4db..d13216a8 100644 --- a/lang/interpret_test/TestAstFunc1/slow_unification0.txtar +++ b/lang/interpret_test/TestAstFunc1/slow_unification0.txtar @@ -6,7 +6,7 @@ $ns = "estate" $exchanged = world.kvlookup($ns) $state = maplookup($exchanged, $hostname, "default") -if $state == "one" || $state == "default" { +if $state == "one" or $state == "default" { file "/tmp/mgmt/state" { content => "state: one\n", diff --git a/lang/parser/lexer.nex b/lang/parser/lexer.nex index 86f89ba7..5d165c39 100644 --- a/lang/parser/lexer.nex +++ b/lang/parser/lexer.nex @@ -119,17 +119,17 @@ lval.str = yylex.Text() return GTE } -/&&/ { +/and/ { yylex.pos(lval) // our pos lval.str = yylex.Text() return AND } -/\|\|/ { +/or/ { yylex.pos(lval) // our pos lval.str = yylex.Text() return OR } -/!/ { +/not/ { yylex.pos(lval) // our pos lval.str = yylex.Text() return NOT diff --git a/lang/parser/lexparse_test.go b/lang/parser/lexparse_test.go index a1efe256..fde80de4 100644 --- a/lang/parser/lexparse_test.go +++ b/lang/parser/lexparse_test.go @@ -945,7 +945,7 @@ func TestLexParse0(t *testing.T) { Name: funcs.OperatorFuncName, Args: []interfaces.Expr{ &ast.ExprStr{ - V: "!", + V: "not", }, &ast.ExprInt{ V: 3, @@ -966,7 +966,7 @@ func TestLexParse0(t *testing.T) { name: "order of operations with not", code: ` test "t1" { - boolptr => ! 3 > 4, # should parse, but not compile + boolptr => not 3 > 4, # should parse, but not compile } `, fail: false, @@ -988,7 +988,7 @@ func TestLexParse0(t *testing.T) { Name: funcs.OperatorFuncName, Args: []interfaces.Expr{ &ast.ExprStr{ - V: "&&", + V: "and", }, &ast.ExprCall{ Name: funcs.OperatorFuncName, @@ -1018,7 +1018,7 @@ func TestLexParse0(t *testing.T) { name: "order of operations logical", code: ` test "t1" { - boolptr => 7 < 4 && true, # should be false + boolptr => 7 < 4 and true, # should be false } `, fail: false,