Add if statements, unary minus, and fix GC safe points
- Lexer: recognize 'if' as keyword (TOK_IF) - Parser: add NODE_IF with if_statement union, parse if/cond/body, handle unary minus in parse_term as 0 - expr - Eval: add NODE_IF evaluation, move GC to NODE_BLOCK level to avoid destroying temporary values during sub-expression evaluation
This commit is contained in:
4
projects/if.j
Normal file
4
projects/if.j
Normal file
@@ -0,0 +1,4 @@
|
||||
x = 20
|
||||
if x < 10:
|
||||
print x
|
||||
print -300
|
||||
@@ -1,4 +1,4 @@
|
||||
x = 0
|
||||
while x < 100000000:
|
||||
while x < 10000000:
|
||||
x = x + 1
|
||||
print x
|
||||
|
||||
Reference in New Issue
Block a user