lang: parser, funcs: Change the logical operators to OR, AND, NOT

This makes it easier to read for some, and easier to parse for us. This
also frees up more characters to use elsewhere.
This commit is contained in:
James Shubin
2023-10-09 16:41:03 -04:00
parent e8f11286dc
commit 05d570d250
12 changed files with 20 additions and 20 deletions

View File

@@ -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

View File

@@ -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,