Andre,

Your approach seems reasonable. Parsers are a bear... and many written in C make use of lex/yacc tools, which are awful cryptic buggers but can do a lot of the work for you if you can provide a language grammar in BNF form. The push/pop approach is definitely a good idea. Other things to consider would be abstracting your tokenizer out and then feeding tokens to a lexical analysis engine as known constants (rather than the actual textual values), and possibly writing out even on paper some of the grammar expansion rules of the language so that you can carefully map out the possible states. It sounds like a worthy and interesting challenge, good luck!

In the name of trivia, I don't know if you know, but many years ago there was an xTalk compiler- CompileIt! in which you could write externals in augmented HyperTalk (and actually any old code resource if you knew what you were doing - even WDEFs and INITs and other fun Mac stuff like that). Apparently the author, Tom Pittman, wrote the original version of the compiler itself in HyperTalk, although the details are either obscure or I don't remember many of them by now! He also co-authored a book, "The Art of Compiler Design".

And our RunRev friend Ro Nagey even picked up my first commercial software way back when, a CompileIt! externals collection... oh the days of our lives!

- Brian

(+ 1000 1)

this is parsed to the following table:
#lp
+
1000
1
#rp

where #lp and #rp are used for parenthesis identification and thus ilegal to use in the code. I thought to work like this, everytime create_symbol function is called with an #rp value, it will go poping the stack/table and evaluating it till find a #lp entry. This way, when the ) is parsed and #rp is sent to create_symbol, it will first pop '1' and since it's nothing but a number it will put in the stack, then it will pop '1000' and to the same, then it will pop '+' this is a predicate, that evaluate the first to things in the stack, this will execute. and be put in the stack, when reaching a #lp entry, the first thing in the stack will be inserted in the symbol table. Is this clear? Is this a nice approach?

_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to