obtaining abstract syntax tree #444
-
Hi, I was using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I think of the SyntaxTree / SyntaxNode as the "parse tree" or equivalently "concrete syntax tree" as you mention. The abstract syntax tree is built out of symbols, expressions, statements, etc by the Compilation object. That "tree" is serializable to JSON via the ASTSerializer class but it's done in a kind of ad-hoc / not very generalizable fashion so if you want something other than JSON you need to walk the tree yourself (the ASTVisitor class can be of help here). |
Beta Was this translation helpful? Give feedback.
I think of the SyntaxTree / SyntaxNode as the "parse tree" or equivalently "concrete syntax tree" as you mention. The abstract syntax tree is built out of symbols, expressions, statements, etc by the Compilation object. That "tree" is serializable to JSON via the ASTSerializer class but it's done in a kind of ad-hoc / not very generalizable fashion so if you want something other than JSON you need to walk the tree yourself (the ASTVisitor class can be of help here).