Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler incorrectly treats string literals with some characters #66

Closed
Tracked by #170 ...
MatiDragon-YT opened this issue Aug 29, 2020 · 15 comments
Closed
Tracked by #170 ...
Labels
priority:p1 High Priority scope:compiler type:bug Something isn't working
Milestone

Comments

@MatiDragon-YT
Copy link
Member

MatiDragon-YT commented Aug 29, 2020

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
Copy link
Collaborator

x87 commented Aug 29, 2020

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 x87 added the discussion Further discussion is requested label Aug 29, 2020
@x87
Copy link
Collaborator

x87 commented Aug 29, 2020

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
Copy link
Member Author

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

@x87 x87 added priority:p2 Medium priority scope:compiler type:bug Something isn't working and removed discussion Further discussion is requested labels Aug 31, 2020
@x87
Copy link
Collaborator

x87 commented Sep 2, 2020

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
Copy link
Member Author

@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
Copy link
Collaborator

x87 commented Sep 3, 2020

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

Absolutely, read my proposal here

@x87
Copy link
Collaborator

x87 commented Oct 23, 2020

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
Copy link
Member Author

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
Copy link
Collaborator

x87 commented Jun 9, 2021

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

@MatiDragon-YT
Copy link
Member Author

MatiDragon-YT commented Jun 9, 2021

@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")

@MatiDragon-YT MatiDragon-YT reopened this Jun 9, 2021
@MatiDragon-YT MatiDragon-YT changed the title Replace spaces in's strings (only within classes) Problems in the members of the classes. Jun 9, 2021
@x87
Copy link
Collaborator

x87 commented Jun 9, 2021

@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
Copy link
Collaborator

x87 commented Jun 10, 2021

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

@x87 x87 changed the title Problems in the members of the classes. Compiler incorrectly treats string literals with some characters Jun 10, 2021
@MatiDragon-YT
Copy link
Member Author

MatiDragon-YT commented Jul 2, 2021

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 x87 added priority:p1 High Priority and removed priority:p2 Medium priority labels Aug 4, 2021
@x87 x87 added this to the Next milestone Aug 4, 2021
@x87 x87 removed this from the 3.8.1 milestone Aug 14, 2022
@x87 x87 mentioned this issue Feb 13, 2023
8 tasks
@x87
Copy link
Collaborator

x87 commented Aug 28, 2023

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

should not delete spaces

@x87 x87 added this to the v4.0.0 milestone Oct 20, 2023
@x87 x87 mentioned this issue Oct 24, 2023
59 tasks
@x87
Copy link
Collaborator

x87 commented Aug 7, 2024

fixed in 4.0.0

@x87 x87 closed this as completed Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p1 High Priority scope:compiler type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants