2009/1/28 Slava Pestov <[email protected]>: > One thing I noticed about your code is that you're using stack > shufflers in a few places where you could use combinators. [...] > Also, generally words should not leave their inputs on the stack, with > only a few exceptions (like tuple setters that are generated for you). > So get-instruction should be ( vm -- insn ) and not ( vm -- vm insn ).
Yes, I could do with improving the style. I'm trying to tidy things up as I go along, looking at various bits of code and trying to pick up style hints as I do. Thanks for the comments - they help with that. Leaving the vm on the stack was an experiment - in C, I'd probably have used a global variable, but I didn't want to add a variable lookup to something as critical as the VM. By keeping the vm around, I save some dups, but probably lose because I need more stack shuffling. I'll rewrite and compare the 2 versions (not that I doubt you, I'd just like to get a feel for the difference!) > Do you intend to add support for building syntax trees to your implementation? Ultimately, yes, I think so. But I suspect that's a bit advanced for me just yet. I've now more or less got everything I need to build VM instruction sequences by hand. Next step is probably to implement constructors and operators for instruction sequences - match-string, match-any, that type of thing, then operators like ordered choice, concatenation, etc. The Lua implementation does a lot of optimisations when building instruction sequences from primitives and operators, I'd like to code them up first. Once I have that, I need to look at including captures (to extract matched parts of the string) so I can go beyond simply "it matched". With all of this in place, I've got a full matching engine, and I will probably then look at an input syntax, maybe something like Chris Double's EBNF<...>. That should keep me busy for a while! Paul. ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
