Greater than and Less Than
Some checks failed
Build / build (push) Failing after 1m12s
Test / build (push) Failing after 11m29s

This commit is contained in:
Chuck Smith
2024-03-18 16:17:13 -04:00
parent d454572870
commit b47a39e1b2
11 changed files with 116 additions and 43 deletions

View File

@@ -81,7 +81,7 @@ func (c *Compiler) Compile(node ast.Node) error {
}
case *ast.InfixExpression:
if node.Operator == "<" {
if node.Operator == "<" || node.Operator == "<=" {
err := c.Compile(node.Right)
if err != nil {
return err
@@ -91,7 +91,11 @@ func (c *Compiler) Compile(node ast.Node) error {
if err != nil {
return err
}
c.emit(code.OpGreaterThan)
if node.Operator == "<=" {
c.emit(code.OpGreaterThanEqual)
} else {
c.emit(code.OpGreaterThan)
}
return nil
}
@@ -116,6 +120,8 @@ func (c *Compiler) Compile(node ast.Node) error {
c.emit(code.OpDiv)
case ">":
c.emit(code.OpGreaterThan)
case ">=":
c.emit(code.OpGreaterThanEqual)
case "==":
c.emit(code.OpEqual)
case "!=":