Skip to content

Compiler incorrectly treats string literals with some characters #66

Closed

Description

@MatiDragon-YT

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...

Activity

  1. x87 commented on Aug 29, 2020

    @x87
    Collaborator

    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.

  2. added
    discussion
    on Aug 29, 2020
  3. x87 commented on Aug 29, 2020

    @x87
    Collaborator

    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?

  4. MatiDragon-YT commented on Aug 31, 2020

    @MatiDragon-YT
    MemberAuthor

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

  5. added
    priority:p2
    type:bug
    and removed
    discussion
    on Aug 31, 2020
  6. x87 commented on Sep 2, 2020

    @x87
    Collaborator

    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

  7. MatiDragon-YT commented on Sep 3, 2020

    @MatiDragon-YT
    MemberAuthor

    @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
    

    😀

  8. x87 commented on Sep 3, 2020

    @x87
    Collaborator

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

    Absolutely, read my proposal here

  9. x87 commented on Oct 23, 2020

    @x87
    Collaborator

    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)
    
  10. MatiDragon-YT commented on Oct 24, 2020

    @MatiDragon-YT
    MemberAuthor

    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
    
  11. 4 remaining items

  12. MatiDragon-YT commented on Jun 9, 2021

    @MatiDragon-YT
    MemberAuthor

    @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")
  13. changed the title [-]Replace spaces in's strings (only within classes)[/-] [+]Problems in the members of the classes.[/+] on Jun 9, 2021
  14. x87 commented on Jun 9, 2021

    @x87
    Collaborator

    @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.

  15. x87 commented on Jun 10, 2021

    @x87
    Collaborator

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

  16. changed the title [-]Problems in the members of the classes.[/-] [+]Compiler incorrectly treats string literals with some characters[/+] on Jun 10, 2021
  17. MatiDragon-YT commented on Jul 2, 2021

    @MatiDragon-YT
    MemberAuthor

    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)

  18. added
    priority:p1
    and removed
    priority:p2
    on Aug 4, 2021
  19. added this to the Next milestone on Aug 4, 2021
  20. removed this from the 3.8.1 milestone on Aug 14, 2022
  21. x87 commented on Aug 28, 2023

    @x87
    Collaborator

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

    should not delete spaces

  22. added this to the v4.0.0 milestone on Oct 20, 2023
  23. x87 commented on Aug 7, 2024

    @x87
    Collaborator

    fixed in 4.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:p1scope:compilertype:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions