More with the ScriptEngine class
Exporting the AST to XML
You can easily export an Abstract Syntax Tree to XML format by invoking the ExportXml static method of the ScriptEngine class.
Simply do as follows:
| C# | |
|---|---|
That functionality is specially helpful for debugging purpose. You can use it to ensure that the parsed script has the expected logical structure.
Regenerating the source code
The ScriptEngine class has a GenerateCode static method than can be used to regenerate the source of a script given its AST (as an instance of the AddyScript.Ast.Program class). The generated source code is so nicely formatted than the "Reformat code" functionality of the AddyScript Graphical Editor (asgui) fully relies on the ScriptEngine.GenerateCode method.
Here is an example of how to use it:
| C# | |
|---|---|