I was working on a parser (nothing id formally announce just yet) today and stumbled across some interesting stuff.
Some of Blizzards script files contain unresolvable references to variables declared in files not included in those parsed.
A normal global variable declaration, you'd think.
Except c_tactTimerFirst is not declared in TactProtAI.galaxy.
There are also no includes in TactProtAI.galaxy.
So where does the variable come from?
Its declared in TriggerLibs/AI.galaxy.
Both TriggerLibs/TacticalAI.galaxy and TriggerLibs/AI.galaxy are included by TriggerLibs/natives.galaxy.
TriggerLibs/TacticalAI.galaxy in turn includes TriggerLibs/TactProtAI.galaxy.
Errors like this one make parsing galaxy with moderately sane code impossible. By extension this also means that Blizzards code for their parser must be an abomination.
P.S.: TriggerLibs/TactTerrAI.galaxy and TriggerLibs/TactZergAI.galaxy suffer from the same error.
P.P.S.: If i ever find a decent Title for this thread, ill change it.
I think they start at a single .galaxy file somewhere and process every "include" command in the order they encounter them. I do something similar in my AI project. Although I agree those includes are sometimes hell to work with.
I was working on a parser (nothing id formally announce just yet) today and stumbled across some interesting stuff. Some of Blizzards script files contain unresolvable references to variables declared in files not included in those parsed.
Practical example: TriggerLibs/TactProtAI.galaxy
Look at line 646:
A normal global variable declaration, you'd think. Except c_tactTimerFirst is not declared in TactProtAI.galaxy. There are also no includes in TactProtAI.galaxy. So where does the variable come from? Its declared in TriggerLibs/AI.galaxy. Both TriggerLibs/TacticalAI.galaxy and TriggerLibs/AI.galaxy are included by TriggerLibs/natives.galaxy. TriggerLibs/TacticalAI.galaxy in turn includes TriggerLibs/TactProtAI.galaxy.
Errors like this one make parsing galaxy with moderately sane code impossible. By extension this also means that Blizzards code for their parser must be an abomination.
P.S.: TriggerLibs/TactTerrAI.galaxy and TriggerLibs/TactZergAI.galaxy suffer from the same error.
P.P.S.: If i ever find a decent Title for this thread, ill change it.
I think they start at a single .galaxy file somewhere and process every "include" command in the order they encounter them. I do something similar in my AI project. Although I agree those includes are sometimes hell to work with.
I gave up on parsing galaxy aeons ago, precisely because of stuff like that - and because I don't want to write yet anther C parser.