Skip to contents

The list is plain R data - no classes - ready for jsonlite::toJSON() or any other serialiser. Node types are tagged with their schema name, so declarations and references stay distinguishable.

Usage

ast_to_json(x, data = c("omit", "inline"))

Arguments

x

An AST node.

data

How to treat data payloads: "omit" (the default) leaves them out, on the basis that bulk data belongs in the Parquet store; "inline" embeds them.

Value

A nested list.

Examples

n <- ast_expression("*", ast_symbol("a"), ast_symbol("b"))
str(ast_to_json(n), max.level = 2)
#> List of 5
#>  $ node    : chr "expression"
#>  $ op      : chr "*"
#>  $ lhs     :List of 2
#>   ..$ node: chr "symbol"
#>   ..$ name: chr "a"
#>  $ rhs     :List of 2
#>   ..$ node: chr "symbol"
#>   ..$ name: chr "b"
#>  $ brackets: NULL