katsaii / catspeak-lang

A cross-platform modding language for GameMaker games.
https://www.katsaii.com/catspeak-lang/
MIT License
92 stars 6 forks source link

`else if` throws an error #77

Closed JujuAdams closed 1 year ago

JujuAdams commented 1 year ago

What is the bug? How did it happen?

Executing the following Catspeak script ...

a = 1
if (a == 1) {

} else if (a == 2) {

}

... throws the following error

___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object oCatspeakTest:

Catspeak v3.0.0: in a file at (line 5, column 10) when parsing -- expected opening '{' at the start of 'else' block, got token '(' (0)
 at gml_Script___catspeak_error (line 25) -     show_error(msg, false);
############################################################################################
gml_Script___catspeak_error (line 25)
gml_Script_anon_CatspeakParser_gml_GlobalScript_scr_catspeak_parser_21137_CatspeakParser_gml_GlobalScript_scr_catspeak_parser (line 597) -             __catspeak_error(dbg, " -- ", msg, ", got ", __tokenDebug());
gml_Script_anon_CatspeakParser_gml_GlobalScript_scr_catspeak_parser_7533_CatspeakParser_gml_GlobalScript_scr_catspeak_parser (line 203) -             __ex("expected opening '{' at the start of '", keyword, "' block");
gml_Script_anon_CatspeakParser_gml_GlobalScript_scr_catspeak_parser_3645_CatspeakParser_gml_GlobalScript_scr_catspeak_parser (line 150) -                 __parseStatements("else");
gml_Script_anon_CatspeakParser_gml_GlobalScript_scr_catspeak_parser_2441_CatspeakParser_gml_GlobalScript_scr_catspeak_parser (line 96) -             result = __parseExpression();
gml_Script_anon_CatspeakParser_gml_GlobalScript_scr_catspeak_parser_1931_CatspeakParser_gml_GlobalScript_scr_catspeak_parser (line 63) -         __parseStatement();
gml_Script_anon_CatspeakEnvironment_gml_GlobalScript_scr_catspeak_environment_3622_CatspeakEnvironment_gml_GlobalScript_scr_catspeak_environment (line 97) -             moreToParse = parser.update();
gml_Script_anon_CatspeakEnvironment_gml_GlobalScript_scr_catspeak_environment_4291_CatspeakEnvironment_gml_GlobalScript_scr_catspeak_environment (line 110) -         return Catspeak.parse(buff);
gml_Object_oCatspeakTest_Create_0 (line 23) - var _asg = Catspeak.parseString(@'

What was the expected behaviour?

no crash :(

Version

3.0.0-beta3