sannybuilder / dev

Sanny Builder Bug Tracker and Roadmap development
https://sannybuilder.com
48 stars 0 forks source link

Compiler incorrectly treats string literals with some characters #66

Closed MatiDragon-YT closed 1 month ago

MatiDragon-YT commented 4 years ago

In the past I remembered that the IDE compiled the strings, but eliminating the spaces, and now it does not compile them directly. So you asked me. Wasn't it better to replace the spaces with another character? It was there when I started to investigate the archive .SCM, and I noticed that the spaces were replaced by the underscores when decompiling. So, could the same function be done for compilation of the scripts, and thus avoid this problem?

GXT.addDynamic("EXA", "Hello Word")

--------- ⬇ when compiling ---------

0ADF: "EXA" "Hello_Word"

--------- ⬇ when decompiling-------

GXT.addDynamic("EXA", "Hello_Word")

and another thing ... since the F11 does not have any function in the editor, other than deleting the field of the Opcodes Finder. Could you assign it to open the offline help file (.chm)? yes? please...

x87 commented 4 years ago

Compiler can't replace spaces with underscores as this changes the content and may break the logic this string is for. "Hello world" and "Hello_world" are two different string literals.

Can you provide a real code that does not compile? Spaces in string literals should not cause compilation issues.

x87 commented 4 years ago

I see that using "extended" params in classes may cause compilation issue:

e.g. this code works

Player.SetClothes(0@,"a c","ddddd    ddd",0)

but this does not

Player.SetClothes(0@,"a c","ddddd    ddd",Torso)

Is this the same issue that you experience?

MatiDragon-YT commented 4 years ago

YES!!! I thought it was for something else...

x87 commented 4 years ago

and another thing ... since the F11 does not have any function in the editor, other than deleting the field of the Opcodes Finder. Could you assign it to open the offline help file (.chm)? yes? please...

you can use User tools to achieve this:

chm-image

MatiDragon-YT commented 4 years ago

@x87 Yes I know... after sending the proposal I had remembered that program. I configured it, I tested it, it worked, and finally, I forgot to edit the footer of the message... sorry... but there was also something else he wanted to say to you and he didn't remember it. But... now I do remember. You know that the new gosub function that you implemented is tasty, delicious, exquisite, capable of delighting you and making you feel an orgasm and everything, but... do you think you can do something similar with it opcode 0AB1?

AnimObj() // if this is a gosub.

AnimObjTo($obj, x, y, z) // this can be the same as 
//0AB1: call_scm_func @AnimObjTo 4 $obj x y z

😀

x87 commented 4 years ago

do you think you can do something similar with it opcode 0AB1?

Absolutely, read my proposal here

x87 commented 3 years ago

Related issue: compiler replaces comma in string literals with whitespace:

Player.SetClothes(0@,"a c","ddd,dd    ddd",0)

after decompilation becomes

Player.SetClothes(0@, "A C", "DDD DD DDD", 0)
MatiDragon-YT commented 3 years ago

But the comma(,), is already registered to be visible within the game.

font2

How about this idea .. if 1 space is detected, compile it with the space, but if it is more than 2 spaces, compile with the underscores, and when decompiling, we replace these characters with spaces, BUT ONLY IF they have a space before, otherwise the underscores will be kept..

GXT.Create("ac20","ddd,dd  dd__ddd") // e.g. 1
Player.SetClothes(0@,"a c","ddd,dd   ddd",0) // e.g. 2

--------- ⬇ when compiling ---------

GXT.Create("ac20","ddd,dd _dd__ddd") // e.g. 1
Player.SetClothes(0@,"a c","ddd,dd __ddd",0) // e.g. 2

--------- ⬇ when decompiling-------

GXT.Create("ac20","ddd,dd  dd__ddd") // e.g. 1
Player.SetClothes(0@,"a c","ddd,dd   ddd",0) // e.g. 2
x87 commented 3 years ago

@MatiDragon-YT why closing this issue? it has not been resolved yet.

MatiDragon-YT commented 3 years ago

@x87 forgive me. It is that in 3.8.0.0 I had as if I saw that the compiler respected the spaces, but I saw it wrong. In fact it was about to reopen the theme. I also found some problems IN THE CLASSES

The IDE interprets commas (,) as a Space and when there are 2 or more Spaces, these are compiled as 1 only.

Exam.ple("a, b    c d") // compiled to "a b c d"
XXXX: "a, b    c d") // compiled to "a, b c d"

The equality/assignment symbol (=) can't be included at Strings.

Exam.ple("abcd", "hi = hola") // error
XXXX: "abcd" "hi = hola") // nice

When the IDE comes across an OPCODE that contains a function like REST / CALLBACK (XXXX=-1,[...]), the opcode class goes crazy. The IDE copies and pastes the last value entered in the opcode, until the 35 spaces it allows are completed. That is to say that from this:

Memory.CallFunction(0@, 1@, 2@, 3@)

becomes this:

Memory.CallFunction(0@, 1@, 2@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@, 3@)

There are times when it does not copy the last value, but 2 values at the same time. You could include a parameter like % r to represent a REST / CALLBACK and prevent that error

; example
CallFunction, 0AA5,0,0, ("address% i" "numParams% i" "pop% r")
x87 commented 3 years ago

@MatiDragon-YT it happens as internally sanny unwraps -1 to the maximum allowed number of parameters in this game. you can also notice the same number is displayed as expected number of parameters for this opcode in the bottom panel.

to handle this behavior arguments type has been added in Sanny Builder Library. Classes are meant to understand that arguments is a variable set and act accordingly. So far it does not happen.

x87 commented 3 years ago

@MatiDragon-YT I think the second issue you described warrants its own ticket. Let's keep this one for string parsing.

MatiDragon-YT commented 3 years ago

Depending on how an OP is configured in the classes.db file, the STRING type values will be compiled in one way or another:

Text.AddLabel("Hello", "     Word !") 
stringVar = String.Format("%d * %d %c", 4, 10, charSame)
String.Scan(stringVar, "%d * %d", numParams, 1@, 2@)
Text.PrintHelpString("Performing addition...")

//to

Text.AddLabel("Hello", " Word !")
String.Format(3@v, "%d*%d", 4, 10)
String.Scan(3@v, "%d * %d", 0@, 1@, 2@)
Text.PrintHelpString("Performing addition...")

I share my classes.db and others so you can check it out. (sa.zip just for SB 3.8.0 alpha 4)

x87 commented 1 year ago

0@ = Player.Money("this is some string")

should not delete spaces

x87 commented 1 month ago

fixed in 4.0.0