Added a comment for a future implementation of greater/less than comparisons and reverted old behavior

This commit is contained in:
nocturn9x 2021-02-27 17:40:50 +01:00
parent a4ef124d3f
commit d82e8ed2b0
3 changed files with 10 additions and 5 deletions

Binary file not shown.

View File

@ -310,6 +310,11 @@ proc binary(self: Compiler, canAssign: bool) =
of TokenType.DEQ:
self.emitByte(OpCode.Equal)
of TokenType.GT:
# To allow for chaining of greater/less comparisons in the future (without doing
# weird stuff such as allowing false with the greater/less than operators)
# we need to move their logic in another function. This will
# also allow for a sort of short-circuiting control flow like
# for logical ands and ors, because why not?
self.emitByte(OpCode.Greater)
of TokenType.GE:
self.emitByte(OpCode.GreaterOrEqual)

View File

@ -31,12 +31,14 @@ import jale/plugin/defaults
import jale/plugin/history
import jale/plugin/editor_history
proc getLineEditor: LineEditor =
result = newLineEditor()
result.prompt = "=> "
result.populateDefaults() # setup default keybindings
let hist = result.plugHistory() # create history object
result.bindHistory(hist) # set default history keybindings
result.populateDefaults() # setup default keybindings
let hist = result.plugHistory() # create history object
result.bindHistory(hist) # set default history keybindings
proc repl(bytecodeVM: VM) =
var bytecodeVM = bytecodeVM
@ -58,8 +60,6 @@ proc repl(bytecodeVM: VM) =
continue
elif source == "//exit" or source == "// exit":
echo "Goodbye!"
echo JAPL_VERSION_STRING
echo nimDetails
break
elif source != "":
discard bytecodeVM.interpret(source, "stdin")