TweeZcodeCompiler / twee_zcode_compiler

compiler project at FU Berlin
MIT License
3 stars 0 forks source link

If issues #97

Closed lhochstetter closed 9 years ago

lhochstetter commented 9 years ago

Hey everyone, while testing Danni's displaycompile branch I used following testfile

::Start

Die glorreiche Addition von zwei Zahlen über Set, Print, Display und If Else

$a = <<set $a = 10>><<print $a>>
$b = <<set $b = 22>><<print $b>>
<<display "ADD">>
::ADD
<<if $a >= 0>>
$a = <<print $a>> <<set $a = $a-1>>
$b = <<print $b>> <<set $b = $b+1>>
<<display "ADD">>
<<else if $a is 0>>
FERITG!
<<endif>>

The compiler did not compile this file stating there was an unclosed if condition - twee however did compile this file and executed it as expected ... there seems to be an issue with the if recognition.

lhochstetter commented 9 years ago

Same issue with the iftest file

::Start
(set $var to 3)
<<set $var to 3>>

(print $var)
<<print $var>>

(if $var is 2) FALSE (else if $var is 3) true (else) FALSE (endif)
<<if $var is 2>> FALSE <<else if $var is 3>> true <<else>> FALSE <<endif>>

(print $var)
<<print $var>>

!!!SIMPLE IF!!!
(if $var is 2) FALSE (endif)
<<if $var is 2>> FALSE <<endif>>

(print $var)
<<print $var>>

!!!IF WITH ELSE!!!
(if $var is 3) true (else) FALSE (endif)
<<if $var is 3>> true <<else>> FALSE <<endif>>

!!!IF WITH ELSE2!!!
(if $var is 2) FALSE (else) true (endif)
<<if $var is 2>> FALSE <<else>> true <<endif>>

(print $var)
<<print $var>>

!!!IF WITH ELSE IF!!!
(if $var is 3) true (else if $var is 2) FALSE (endif)
<<if $var is 3>> true <<else if $var is 2>> FALSE <<endif>>

(print $var)
<<print $var>>

!!!NESTED IF!!!

<<if $var is 3>>
    <<if $var is 3>>
        <<if $var is 2>>FALSE <<else if $var is 3>> elseiftruesetvar-15 (set $var to -15) <<set $var to -15>> (print $var) <<print $var>> <<else>>FALSE<<endif>>
        <<if $var is -15>>true<<else>>FALSE<<endif>>
        <<if $var is -13>>FALSE<<else>>true<<endif>>
        <<if $var is -14>>FALSE<<else>><<set $var to 15>><<endif>>
        <<if $var is 15>>true<<else>>FALSE<<endif>>
        <<if $var is 13>>FALSE<<else>>true<<endif>>
        <<if $var is 14>>FALSE<<else>><<set $var to 3>><<endif>>
    <<else>>true<<endif>>
<<endif>>

(print $var)
<<print $var>>
ottne commented 9 years ago

Fixed by 6737cc6ff7b700137b0f82627692832b2f435e47.