ast: Display the abstract syntax tree

Description Usage Arguments See Also Examples

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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)

lobstr documentation built on July 3, 2019, 1:05 a.m.