--- Raul Miller <[EMAIL PROTECTED]> wrote: > On Nov 11, 2007 7:40 PM, Oleg Kobchenko <[EMAIL PROTECTED]> wrote: > > "The default AST constructed by SableCC matches the > > concrete syntax tree (CST). The parser class can be > > customized through inheritance to modify the AST as > > it is constructed." > > But this customization is another flaw: concrete parser > > should be dependent on AST and not the other way around. > > Could you expand on this point a bit? > > It seems to me that the AST is an instance of the > grammar in question (corresponding to a document) > while the parser is more general (corresponding to > all documents which the grammar can handle). > > I understand the value of understanding an algorithm > in terms of its data, but I am not quite sure I understand > how what you are saying here makes sense.
AST corresponds to the model described by the grammar, while parse tree, the exact grammar productions. AST represents semantics, and is the same for many concrete grammars, it should not care about parens, helper productions (e.g. precedence cascades) or even variations of grammars, e.g. postfix, infix, etc. (+ a b) or (a + b) is the same dyad(add)(sym(a),sym(b)). Whereas parse tree captures the precise details: LPar,RPar,Term,Factor,etc and correspods to productions of concrete grammar. SableCC automatically generates parse-tree classes and then the user is offered to inherit from those classes to create a "higher level" AST. How it should be done, is AST is defined beforehand and independently and then <<used>> by concrete (generated) grammar-specific class hierarchies to build AST instance. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
