Fix grammar around variadic function calls

Reporter: JoshDreamland  |  Status: open  |  Last Modified: September 17, 2016, 12:04:57 AM

Because 'V' is used to denote variadic functions, but then 'n' is substituted in for later code simplicity, 'V' needs to be treated like 'n' when determining token separation. This change lets cprime donate an alternate interpretation of c, the token marker character, so this can be detected.
RobertBColton  
This resolves at least the issue that crept up in #1019 so far.

if z>=other.z3+other.z
 ds_list_add(list,other.z3+other.z)

Now correctly parses to:

    if(enigma::varaccess_z(int(self))>= enigma::varaccess_z3(int(other))+ enigma::varaccess_z(int(other)))
      ds_list_add(enigma::varaccess_list(int(self)), (enigma::varargs(), enigma::varaccess_z3(int(other))+ enigma::varaccess_z(int(other))));

However choose(1,2,3); in a script in an empty game throws an exception up to LGM but does not crash.

Copying constant names [0]
SYNTAX CHECKING AND PRIMARY PARSING:
1 Scripts:
choose ( 1 , 2 , 3 ) Second pass...
Thread-14:
java.lang.Error: Invalid memory access
        at com.sun.jna.Native.invokeInt(Native Method)
        at com.sun.jna.Function.invoke(Function.java:383)
        at com.sun.jna.Function.invoke(Function.java:315)
        at com.sun.jna.Library$Handler.invoke(Library.java:212)
        at com.sun.proxy.$Proxy0.compileEGMf(Unknown Source)
        at org.enigma.EnigmaRunner$CompilerThread.run(EnigmaRunner.java:663)

Also #214 is still an issue:

show_message(choose(a,b,c));
C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h:39:43: error: 'a' was not declared in this scope
   show_message(choose((enigma::varargs(), a, b, c)));
                                           ^
C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h:39:46: error: 'b' was not declared in this scope
   show_message(choose((enigma::varargs(), a, b, c)));
                                              ^
C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h:39:49: error: 'c' was not declared in this scope
   show_message(choose((enigma::varargs(), a, b, c)));
                                                 ^

RobertBColton  

show_message(string(choose(1,2,3)));

Becomes;

show_message(toString(choose((enigma::varargs(), 1, 2, 3))));
show_message(string(choose(a,b,c)));

Becomes:

show_message(toString(choose((enigma::varargs(), enigma::varaccess_a(int(self)), enigma::varaccess_b(int(self)), enigma::varaccess_c(int(self))))));
show_message(string(show_message(string(a))));

Becomes:

show_message(toString(show_message(toString(enigma::varaccess_a(int(self))))));

So.... LOOKS LIKE YOU FIXED IT!!!! But choose(1,2,3); is still crashing all by its little self. I also need to test other games.

  • FPS Example: Compiles and runs fine as always.
  • Animation Platform Example (DarkAceZ gave it to me): Compiles and runs great, also lacking the graphics problems it had before oddly enough.
  • Project Mario: Working great!
  • AI Tutorial: Cool beans!
  • Game of Life: Pi in the sky!
  • Destructible blocks: Good to go!
  • Platform engine from EDC: now compiles again so what crept up in #1019 is definitely gone.

Please sign in to post comments, or you can view this issue on GitHub.