New games every week!
JSE - Day Three - Rewritten Parser
Blog
24th March 2021
The scripting engine takes one step forward, and half-a-dozen back.
-=-=- Currently the scripting engine is completely broken!! I spent most of yesterday working on a new version of the parser. It's about 50% complete, but is at least managing to understand strings and brackets in a better way than the previous RegEx edition did. Parsing using RegEx is all well and good when the content is an expected style, but I'd like my scripting engine to have a teensy bit more leeway when it comes to putting things in specific places. For example, I'd like the following two lines of code to work perfectly well. 1. DrawText(100,100,"Print 'This' Text. (Tada!)") and 2 DrawText 100,100,'Print "This" Text, too.'+" (OK!)"; Doing it via RegEx proved almost impossible. The brackets and quotemarks got in the way of it grabbing the right bits in the right order, and everything got horribly mangled along the way. To be fair, I'm still an amateur when it comes to RegEx, and maybe a more experienced RegExpert might be able to figure it out.. But I sure as hell couldn't!! Instead, then, I rewrote everything in an oldskool manner. A for loop, going through the string from left to right, plucking out elements, and understanding the string in the correct way. I've yet to piece together the end result, back into the engine, but for now it is at least managing to correctly figure out which bits are in brackets and quotes and the result should be much easier for me to manage. I now need to decide on what each piece is. Variable, Number, Command, etc. Then I can pop all of that back into the script, and hopefully it should work. ...! Hopefully. Views 135, Upvotes 13
Daily Blog
,
Jse
New games every week!
|