dbaumgarten / yodk

Development Kit for Starbase's ingame programming language YOLOL
MIT License
57 stars 16 forks source link

IF statement THEN clause can only handle one assignment #129

Closed JeffStodd closed 1 month ago

JeffStodd commented 1 month ago

During optimization of my code I found an error when "compiling": Parser error at Line: 2, Coloumn: 19: Expected token 'end'(Keyword). Found Token: 'goto2'(ID)

Source: if i < 6 then i++ goto2 end

I then began to test the parser further and found if conditionals are pretty much just broken if they don't have one and only one assignment statement...

Success: if a then b=1 end Failure: if a then b=1 c=2 end Also failure because the parser expects a space after goto: if a then goto2 end

dbaumgarten commented 1 month ago

Hi, I guress you are using the "compile" command, right? That command expects NOLOL-Code as input, which has a slightly different syntax. In Nolol, multiple statemens in an inline-if need to be separated by ;. And there needs to be a space after goto.

Example:

if a then b=1; c=2; d=3 end
goto 1

If you just want to optimize regular yolol-code, use the "optimize" command instead.