Since I'm writing that programmable AI game together with Zadkiel, i need to know the best way to parse a script.....
my general idear was to split the file into lines and the lines int commands, this would speed up the runtime a little bit and give nice DEbug info, I just not so sure aubout how to identifiy the functionname .... maybe some kind of binary tree would be fastest wouldn't it???
Anyone got a better idear???
Posted on 2001-08-03 18:18:59 by theNOP
I would parse the file into a byte-code (no reason it couldn't be machine code) that could be executed by a little virtual machine, but that's just me. :) The virtual machine would just be a blanket around the game engine. Parsing would be slow but concise with good error reporting, and the byte-code would run way too fast! Yes, it's tricky, but fun. :)
Posted on 2001-08-03 19:58:05 by bitRAKE
I'd do the bytecode compilation as well. You do the script parsing,
error catching, etc at compiletime, which makes the job runtime much
easier. In total the job will be a bit harder I guess, but you will get
a more solid game engine, and lots faster too.

I would use x86 machine code for the script, though. That would be
very much work. Like, "script memory" versus "x86 memory".

Writing a little CPU emu for your own hypothetical CPU isn't very hard
to do. I expect a bytecode script engine to be a little harder, if not
for other reasons, then at least because of the script compiler.
Posted on 2001-08-04 06:51:46 by f0dder
ok i found a nice source covering this topic, i think this will be the best way to do it. i think i should even try to make some kind of real executeable aout of it, so it will be a lot more faster
Posted on 2001-08-04 18:49:42 by theNOP
how about making an ada or cobol like script, then the script has to comply even to certain placement rules, much easier to parse :)
Posted on 2001-08-04 20:36:20 by Hiroshimator
NOP, bad idea to create a "real executable" out of it. JIT could be
okay, though, but I'd still (at least start with) a "simple" virtual
machine parsing bytecode.
Posted on 2001-08-04 22:59:46 by f0dder
i got the an id for every function, whic also is its opcode it is linked to the functions name-string, so if i have a file containing the code how do i idntify the function i thought about isolating it as a string and then identyfiing it by some strange combination of binary tree, jumptable and hash table.
I thought about building a jumptable, that's containg one value for about 4-5 chars pointing to the next jumptable, in case the commands -string is ended there is a field in the jump table pointing to a struct with some function data like id, and offset to call!
what do you think about it...
i know that it might use alot of mem (~512MB if 1entry/4chars max of 11 char long func names and26 chars) if everything would be used, but it should be fast as hell or is there a faster way or a way tahts not much slower but uses less mem?
Posted on 2001-08-08 08:40:47 by theNOP