Prevent ELIF or ELSE after an ELSE

Fixes #749
This commit is contained in:
Rangi
2021-02-24 21:19:08 -05:00
committed by Eldred Habert
parent dd892d61d8
commit d4028fff10
12 changed files with 163 additions and 45 deletions

View File

@@ -0,0 +1,18 @@
if 0
println "zero"
else
println "one"
if 1
println "A"
else
println "B"
elif 2
println "C"
else
println "D"
endc
elif 2
println "two"
else
println "three"
endc

View File

@@ -0,0 +1,2 @@
FATAL: elif-after-else.asm(14):
Found ELIF after an ELSE block

View File

@@ -0,0 +1,2 @@
one
A

View File

@@ -0,0 +1,2 @@
FATAL: multiple-else.asm(11):
Found ELSE after an ELSE block

View File

@@ -0,0 +1,17 @@
mac: MACRO
if (\1) < 10
println "small \1"
elif (\1) > 100
println "large \1"
elif (\1) / 0 == 42 ; only evaluated if the "large" condition was taken
println "division by zero!?"
elif syntax! error?
println "X_X"
else
println "unreachable"
endc
ENDM
mac 2 + 2
mac STRLEN("abcdef")
mac 101

View File

@@ -0,0 +1,2 @@
FATAL: skip-elif-condition.asm(17) -> skip-elif-condition.asm::mac(6):
Division by zero

View File

@@ -0,0 +1,3 @@
small 2 + 2
small STRLEN("abcdef")
large 101