sfall icon indicating copy to clipboard operation
sfall copied to clipboard

Empty statements not working?

Open burner1024 opened this issue 3 years ago • 26 comments

empty statements in blocks are allowed: This is just a convenience to save scripters a bit of memory. Some of the macros in the fallout headers include their own semicolons while others do not. With the original compiler you had to remember which was which, and if you got it wrong the script would not compile. Now it's always safe to include your own semicolon, even if the macro already had its own.

Trying with 4.2.8.1:

$ cat 1.ssl
#define my_macro display_msg("foo");

procedure start begin
  my_macro;
end
$ wine ~/bin/compile.exe -p -n -l -O2 -q 1.ssl -o 1.int
Compiling 1.ssl
[Error] <1.ssl>:5:4: expecting ';'.

*** THERE WERE ERRORS (1 of them) ***

Tried some earlier 4.x versions, also no go.

burner1024 avatar Jan 04 '21 21:01 burner1024

Removing the semicolon from one of them should work. I tried the sslc as old as 3.3, and it still gives the same error.

NovaRain avatar Jan 04 '21 23:01 NovaRain

Sure, but the point is exactly not having to remove the semicolon. If the readme is wrong and it never worked, then consider it a feature request.

burner1024 avatar Jan 04 '21 23:01 burner1024

All macro definitions are written without ; at the end. Consider this a syntax rule.

FakelsHub avatar Jan 04 '21 23:01 FakelsHub

I agree, this looks like a bug. Either we should add this feature or remove this message from the docs.

phobos2077 avatar Jan 04 '21 23:01 phobos2077

The first mention of this "feature" is in 2.11, but even the compile.exe from 2.11 doesn't work with the example.

NovaRain avatar Jan 04 '21 23:01 NovaRain

Is it a big problem to allow this?

burner1024 avatar Jan 05 '21 00:01 burner1024

Is it a big problem to allow this?

I don't think so. Just a matter of tweaking the parser a bit.

phobos2077 avatar Jan 05 '21 00:01 phobos2077

Just a matter of tweaking the parser a bit.

Предлагаю вам этим и заняться. :) У меня от кода того парсера голова пухнет, все очень там запутано. в общем си код там говно, и отлаживать его еще тот АД.

FakelsHub avatar Jan 05 '21 01:01 FakelsHub

Did some quick comparison. The major change from sslc 2.9 to 2.11 is including the mcpp preprocessor, but I failed to notice if Timeslip added extra handling for semicolon.

NovaRain avatar Jan 05 '21 01:01 NovaRain

У меня от кода того парсера голова пухнет, все очень там запутано. в общем си код там говно, и отлаживать его еще тот АД.

Я лет 5 на него не смотрел, но помню что именно парсер там супер-простой. Если нужно небольшое изменение внести - это элементарно. А вот новые фичи которые требуют много изменений - уже сложновато.

phobos2077 avatar Jan 05 '21 12:01 phobos2077

А там парсер рукописный (и где он вообще)? Обычно если парсер в виде какой-то грамматики, то вносить изменения не сложно, что мелкие, что средней тяжести.

Mingun avatar Jan 05 '21 19:01 Mingun

А там парсер рукописный (и где он вообще)?

parse.c Кажется это просто забыли вставить или заменить все вызовы на это https://github.com/FakelsHub/int-sslc/blob/fd413466afd60b8c2a35cf748f1788267372d193/sslc/parse.c#L1617

FakelsHub avatar Jan 05 '21 20:01 FakelsHub

@NovaRain you can try replacing the second argument of the function parseStatementInternal(p, 1); to 0 and see how the compiler will work. I have doubts that this didn't work well, so it was eventually disabled.

FakelsHub avatar Jan 11 '21 07:01 FakelsHub

@NovaRain you can try replacing the second argument of the function parseStatementInternal(p, 1); to 0 and see how the compiler will work. I have doubts that this didn't work well, so it was eventually disabled.

No good, for a code like this:

   for (i = 0; i < 9; i++) begin // line 447
   // do something
   end

The compiler will complain [Error] <gl_0keytest.ssl>:447:17: Expected ';' (the i in i < 9).

NovaRain avatar Jan 11 '21 07:01 NovaRain

The exception for parseWhile

FakelsHub avatar Jan 11 '21 08:01 FakelsHub

The exception for parseWhile

OK, I replaced the parseStatement(p); in parseBlock() and parseIf() with parseStatementNoSemicolon(p) but not parseWhile(). Both the example script and the one using for loop pass the compilation, and the decompiled results seem normal.

Not sure if parseStatementNoSemicolon(p) should only be used for parseBlock() thought.

NovaRain avatar Jan 11 '21 08:01 NovaRain

Whatever you guys change, don't forget to test by re-compiling ALL original scripts (with RP scripts as well for good measure) and making sure it still works.

phobos2077 avatar Jan 11 '21 20:01 phobos2077

I would not use the method of optional semicolon characters, and would remove this description from the documentation. Ps. semicolon characters can be used as helper with parsing the code.

FakelsHub avatar Jan 13 '21 03:01 FakelsHub

Problem is, some defines must have a semicolon, while others must not. And as of now you have to remember which is which all the time.

burner1024 avatar Jan 13 '21 13:01 burner1024

С этого момента ты должен установить нормальную IDE для разработки и не париться с запоминанием.

Как вариант сделать отдельную опцию компилятора, и тогда вся боль ляжет на того кто будет компилироваться без точки с запятой. :-)

FakelsHub avatar Jan 13 '21 14:01 FakelsHub

А по факту нужно делать совсем другую функцию, которая бы убирала двойной сивол ; Но легче это сделать в скрипт редакторе чем в этом компиляторе.

FakelsHub avatar Jan 13 '21 14:01 FakelsHub

Какую это нормальную IDE? Ну даже если будет подсказка, дефайны бывают в сотни строк. Это каждый раз надо мотать смотреть. Я не вижу в чем разницу сделать опцию и сделать без опции, код ведь тот же самый?

burner1024 avatar Jan 13 '21 15:01 burner1024

Какую это нормальную IDE? Ну даже если будет подсказка, дефайны бывают в сотни строк. Это каждый раз надо мотать смотреть.

ну по факту никакой IDE для нашего дела не существует (есть какая-то там универсально-настраиваемая Eclipse) кроме Sfall Script Editor, который подчеркнет вашу ошибку, покажет или перейдет к макросу.

Я не вижу в чем разницу сделать опцию и сделать без опции, код ведь тот же самый?

с опцией это во первых страховка. к примеру Sfall Script Editor при парсинге кода скрипта определяет конец функции/макроса по этому символу.

FakelsHub avatar Jan 13 '21 16:01 FakelsHub

ну по факту никакой IDE для нашего дела не существует

Ну вот

к примеру Sfall Script Editor при парсинге кода скрипта определяет конец функции/макроса по этому символу.

... а значит если в макросе нет и не предолагается ";", то SSE вскрякнет. Так это в нем косяк, а не страховка.

burner1024 avatar Jan 13 '21 17:01 burner1024

Так это в нем косяк, а не страховка.

причем тут "в нем косяк", точка запятой это часть синтаксиса SSL. поди напиши разработчикам питона, что там их отступы к черту не нужны, тебя отправят к царю))) так и здесь. страховка нужна от косяков компилятора, которые вы будете искать) как пользователи данной фичи

FakelsHub avatar Jan 13 '21 17:01 FakelsHub

Я вообще не понимаю, что ты имеешь ввиду. С опцией так с опцией, если хоть как-то будет компилироваться пустой statement, это будет отлично.

burner1024 avatar Jan 13 '21 18:01 burner1024