Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [Dltk-dev] AST Discussion

Hi, Mark,

Generalize the ASTNode hierarchy so it better fits all dynamic languages. Various languages have different notions of what an '_expression_' and a 'statement' are. I suggest removing _expression_ and Statement from the ASTNode hierarchy (i.e. flattening the hierchy).

I believe those nodes are mostly unused already, so removing them completely would be a logic step forward. +1.

Modify the ASTVisitor to support the flattened hierarchy, currently it has

visit(_expression_ ..) visit(Statement..) visit(MethodDeclaration... visit(ModuleDeclaration and visit(TypeDeclaration...

change to something like

visitExpression(ASTNode.. visitStatement(ASTNode etc

and each node would have to call the appropriate visit method.

Is there any reason to differentiate statements and expressions at the visitor level? Is anything in DLTK core interested in that information at all?

AST's would probably have to be created from factories so they can be configured for each language (ie whether an type of node is a statement or _expression_).

I believe a somewhat better idea is to provide abstract AST classes, so that concrete language frameworks can derive from them and provide specific language-dependant behaviour/properties, such as whether the node is a statement.

On the other hand, we might finally have some use for Bit1..Bit64 flags. (BTW my request to add another 64 was completely ignored. I still miss them!)

Anyway, the method of AST node creation is up to the language framework, so this does not really matter for the design of DLTK core.


Andrey.


Back to the top