[RBMetacode] AST generation
Status: Planning
Brought to you by:
jstrout
From: Thomas T. <tt...@te...> - 2008-03-04 17:48:41
|
Folks, I've checked in Jonathan's Morphe2, which is a quite well working parser generator. I've made a grammar for it which is not fully tested yet but tries to deal with some language quirks of RB in a smarter way (e.g. Jon, Mars and Aaron had not understood the concept of a "designator" (this is how I call it in the grammar, I remember that compiler designers have another word for it but I forgot) and that's why there's the confusion in the compiler about what's an expression and why one can pass a class property "x" to a ByRef parm, but not "me.x". Anyhow. I am not a good designer either, which many see when they look at my rather convoluted code to read project files (my "RB Prj Tools") versus the lean code by Seth or by Joe Ranieri. I'm more of a "detail" person :) So, I encourage you to look at Morphe2 and the two RB grammars I and Jon made for it in early 2006 (inside TTsRBParser and TTsASTParser). TTsRBParser was my first attempt to use Morphe2 to simply parse RB source code. It generates a rather symbolic "tree". If you run the project you'll see it printed in the log windows. TTsASTParser was then based on Jon's attempt to create an AST. IIRC, I tried to modify his grammar based on my own understanding how the grammar should look. The actions in the grammar to create all those Classes is basically from Jon, I just made some modifications to their hierarchy etc. I must say that I have no experience with ASTs, I only know I what I need in the end: A tree that recreates the source in a way where identifier references become objects that point to the declaration of such identifiers, so that one can modify the identifier's declaration and have it affect all references automatically. That will help understanding all relationships in the source code for refactoring, searching etc. I have my doubts that the current attempt in TTsASTParser is the right way to do that. Can someone have a look at it and comment on this? Since you others need a tree as well, what's your goals? Do you agree with the requirements I defined above? How do you plan to go about it? Thomas |