Greater than and Less Than
This commit is contained in:
@@ -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 "!=":
|
||||
|
||||
Reference in New Issue
Block a user