If you try this sort of inheritance, I'd recommend writing down the
formal grammar before you start writing classes.  Don't try to define
the grammar through the inheritance hierarchy; it's too easy to
accidentally build a hierarchy that can't be translated into a
single-pass-parsable grammar...

I usually skip the inheritance and make everything an instance of the
same class, e.g.

class ASTNode(object): ...

class Stmt(ASTNode): ...
class Expr(ASTNode): ...
class UnaryExpr(ASTNode): ...
class BinaryExpr(ASTNode): ...

or you could dynamically generate classes with inheritance based on a
grammar definition

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to