Home | Reviews | GUIpedia | Forum | Fun500


SonicBritScript Compiler
Since everyone else is documenting what they are up to I figured I'd jump on the bandwagon. At the moment I'm writing a basic script compiler (so it compiles the code on the fly for the window engine) I've optimized the initial parser routine several times, (trying to doing early optimization instead of late) so that its all using the same variable to keep track of the string code, and using while loops for the checks. This is instead of using a for loop with checks throughout it. The reason for this is when the parser is compiled in assembly it will be much faster, and instead of using states or a complex regex (or alike) to pull out the tokens I'm basically writing code for specific instances, like I have a while loop that looks for white space. [code] while c$" " and c$chr$(8) tmp=tmp+1 c$=mid$(l$,tmp,1) wend [/code] This would get compiled as [code] while0: lodsb cmp al,' ' je while0 cmp al,8 je while0 [/code] (of course it doesn't do this yet, just giving an example)
2009-03-2510:26 PM

SonicBritRe:Script Compiler
With no optimization bx would hold the value for tmp, and would get the value as mov al,[si+bx], then an inc bx but the compiler will know to optimize that out since its dealing with a string, and just getting the next piece. One of my first goals is to have the compiler compile itself, I'm only using a small subset of basic to write the compiler so I wont need to support a lot. I'm still working on the tokenizer at the moment, and then moving onto analyzing each keyword so that each one can be optimized separately. Basically there would be a specific version of functions that handles constants, specific cases etc. For example mid$,which could be made to handle small strings in this case 1 length strings which can be stored in registers rather then using up memory. (sorry for the double post, but it was showing this last part all together which made for difficult reading)
2009-03-2510:32 PM

BrandonRe:Script Compiler
Good thing that I don't have to know what all that means :P
2009-03-266:49 AM

GUIs


2021 Brandon Cornell