Compiler weirdness
Anyone, please look at the below code. Its a fragment of a bigger project which I have studied and studied but find no reason for the syntax error indicated below.
DEFINE_FUNCTION INITIALIZE_STRUCTURES()
{
STACK_VAR INTEGER i;
STACK_VAR INTEGER i2;
i2 = 0; // <<<<<<<<<< IF I REMOVE OR COMMENT THIS POINTLESS LINE OUT, I GET A SYNTAX ERROR ?? TDIMMERS[1].ID = DIMMER_LAMP_1; TDIMMERS[2].ID = DIMMER_LAMP_2; // <<< SYNTAX ERROR INDICATED FOR THIS LINE HERE ?? TDIMMERS[3].ID = DIMMER_LAMP_3; TDIMMERS[4].ID = DIMMER_LAMP_4; TDIMMERS[5].ID = DIMMER_5;
}
0
Comments
Remove the semicolon after the stack variable declarations
DEFINE_TYPE STRUCTURE lightingDevices { INTEGER ID CHAR Name[30] } DEFINE_CONSTANT VOLATILE INTEGER nMaxLightingDimmers = 30; VOLATILE INTEGER DIMMER_LAMP_1 = 1; VOLATILE INTEGER DIMMER_LAMP_2 = 2; VOLATILE INTEGER DIMMER_LAMP_3 = 3; VOLATILE INTEGER DIMMER_LAMP_4 = 4; VOLATILE INTEGER DIMMER_LAMP_5 = 5; DEFINE_VARIABLE lightingDevices TDIMMERS[nMaxLightingDimmers] DEFINE_FUNCTION INITIALIZE_STRUCTURES() { STACK_VAR INTEGER i STACK_VAR INTEGER i2 TDIMMERS[1].ID = DIMMER_LAMP_1; TDIMMERS[2].ID = DIMMER_LAMP_2; // <<< SYNTAX ERROR INDICATED FOR THIS LINE HERE ?? TDIMMERS[3].ID = DIMMER_LAMP_3; TDIMMERS[4].ID = DIMMER_LAMP_4; TDIMMERS[5].ID = DIMMER_LAMP_5; }Syntax errors are usually pretty hard to track down because the compiler usually flags the wrong line. I'd try looking somewhere above that function to see if anything looks unterminated. I tried duplicating your code and this file compiles without error:
PROGRAM_NAME='Compiler Main' DEFINE_CONSTANT DIMMER_LAMP_1 = 1 DIMMER_LAMP_2 = 2 DIMMER_LAMP_3 = 3 DIMMER_LAMP_4 = 4 DIMMER_LAMP_5 = 5 DEFINE_TYPE STRUCTURE TDIMMER { INTEGER ID } DEFINE_VARIABLE VOLATILE TDIMMER TDIMMERS[5] DEFINE_FUNCTION InitializeStructures () { STACK_VAR INTEGER i STACK_VAR INTEGER i2 TDIMMERS[1].ID = DIMMER_LAMP_1 TDIMMERS[2].ID = DIMMER_LAMP_2 TDIMMERS[3].ID = DIMMER_LAMP_3 TDIMMERS[4].ID = DIMMER_LAMP_4 TDIMMERS[5].ID = DIMMER_LAMP_5 } DEFINE_START InitializeStructures()Semicolons are allowed at function stack_vars....
define_function CHAR[20] CreateFaderString(integer nModuleID, integer nParamType, integer nParam1, integer nParam2) { stack_var char sFinalString[20]; // der finale String mit Anfangsbytes, checksumme und Daten stack_var integer nChksumValue; // Summe der 2 Startbytes und der Databytes stack_var char sChkSumBytes[2]; // Summe auf 2 Bytes umgerechnet stack_var char sData[8]; // Datenbytes stack_var integer nX; // Zähler FOR() Schleife // Die Control Daten zusamensetzen, gleich ins passende Format sData = "IntegerToBytes(nModuleID,1), IntegerToBytes(nParamType,1), IntegerToBytes(nParam1,1), IntegerToBytes(nParam2,1)"; //further stuff to follow }works fine, just wrote this an hour ago....
Also tried again with the original code, compiles well for me:
define_type struct dimmers { integer id } define_constant integer DIMMER_LAMP_1 = 1; integer DIMMER_LAMP_2 = 2; integer DIMMER_LAMP_3 = 3; integer DIMMER_LAMP_4 = 4; integer DIMMER_5 = 5; define_variable dimmers TDIMMERS[5]; DEFINE_FUNCTION INITIALIZE_STRUCTURES() { STACK_VAR INTEGER i; STACK_VAR INTEGER i2; i2 = 0; // <<<<<<<<<< IF I REMOVE OR COMMENT THIS POINTLESS LINE OUT, I GET A SYNTAX ERROR ?? TDIMMERS[1].ID = DIMMER_LAMP_1; TDIMMERS[2].ID = DIMMER_LAMP_2; // <<< SYNTAX ERROR INDICATED FOR THIS LINE HERE ?? TDIMMERS[3].ID = DIMMER_LAMP_3; TDIMMERS[4].ID = DIMMER_LAMP_4; TDIMMERS[5].ID = DIMMER_5; }By whatever reason, sometimes invisible, not allowed characters find the way into the sourcecode file, and the compiler gets in trouble with that, reporting a syntax error that "visibly doesn't exist". Finding them is hard, sometimes only possible by a hex editor....
I also can remember that there are also some combinations of code elements that the compiler interprets as syntax errors, though by language are ok.