ast {lobstr}R Documentation

Display the abstract syntax tree

Description

This is a useful alternative to str() for expression objects.

Usage

ast(x)

Arguments

x

An expression to display. Input is automatically quoted, use ⁠!!⁠ to unquote if you have already captured an expression object.

See Also

Other object inspectors: ref(), sxp()

Examples

# Leaves
ast(1)
ast(x)

# Simple calls
ast(f())
ast(f(x, 1, g(), h(i())))
ast(f()())
ast(f(x)(y))

ast((x + 1))

# Displaying expression already stored in object
x <- quote(a + b + c)
ast(x)
ast(!!x)

# All operations have this same structure
ast(if (TRUE) 3 else 4)
ast(y <- x * 10)
ast(function(x = 1, y = 2) { x + y } )

# Operator precedence
ast(1 * 2 + 3)
ast(!1 + !1)

[Package lobstr version 1.1.2 Index]