feat: implement infix arithmetic operators for numbers and string concatenation
Add parser support for +, -, *, / operators with correct precedence (term/factor) and emit method calls. Implement primitive methods for num_plus, num_minus, num_multiply, num_divide, and string_plus. Update VM to pass VM pointer to primitives and add unsupported value for type errors. Include test files for each operator.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
io.write(8 / 2) // expect: 4
|
||||
|
||||
// TODO(bob): Floating point numbers.
|
||||
// TODO(bob): Unsupported RHS types.
|
||||
@@ -0,0 +1,5 @@
|
||||
io.write(5 - 3) // expect: 2
|
||||
io.write(3 - 2 - 1) // expect: 0
|
||||
|
||||
// TODO(bob): Floating point numbers.
|
||||
// TODO(bob): Unsupported RHS types.
|
||||
@@ -0,0 +1,4 @@
|
||||
io.write(5 * 3) // expect: 15
|
||||
|
||||
// TODO(bob): Floating point numbers.
|
||||
// TODO(bob): Unsupported RHS types.
|
||||
@@ -0,0 +1,4 @@
|
||||
io.write(3 + 5 + 2) // expect: 10
|
||||
|
||||
// TODO(bob): Floating point numbers.
|
||||
// TODO(bob): Unsupported RHS types.
|
||||
Reference in New Issue
Block a user