BoxAST
// Parse source code and return as struct (default)
ast = boxAST( source = "x = 1 + 2" );
println( ast.ASTType ); // Outputs: BoxAssignment
// Parse source code and return as JSON
json = boxAST( source = "function add(a, b) { return a + b; }", returnType = "json" );
println( json ); // Outputs: JSON representation of the AST
// Parse source code and return as text
text = boxAST( source = "if (x > 5) { println('yes'); }", returnType = "text" );
println( text ); // Outputs: Human-readable text representation
// Parse a file
ast = boxAST( filepath = "src/MyClass.bx" );
// Use as a member function on a string
source = "a = [1, 2, 3]";
ast = source.toAST(); // Returns AST as struct
ast = source.toAST( returnType = "json" ); // Returns AST as JSON string
// Parse CFML/ColdFusion syntax
ast = boxAST( source = "cfset x = 1", sourceType = "cfscript" );
// Parse template syntax
ast = boxAST( source = "#now()#", sourceType = "template" );
Method Signature
Arguments
Argument
Type
Required
Description
Default
Examples
Related
Last updated
Was this helpful?
