plot_match: Produce an ast or parse graph of an expression

Description Usage Arguments Value Examples

View source: R/straw.R

Description

Produce an ast or parse graph of an expression

Usage

1
plot_match(g_parse, g_ast, id)

Arguments

g_parse

Parse graph generated by create_parse_graph

g_ast

AST graph generated by create_parse_graph

id

id of ast node to find

Value

A path of vectors in g_parse leading to corresponding ast node

Examples

1
2
3
4
5
6
7
8
9
exp <- parse(text = "if (x) 2 else a$'b'")
g <- create_parse_graph(parse(text = "if (x) 2 else a$'b'"))
plot(g, layout = layout.reingold.tilford)

g_ast <- create_parse_graph(exp, type = "ast")
plot(g_ast, layout = layout.reingold.tilford)

# find code corresponding to `$` call
plot_match(g, g_ast, 8)

machow/straw documentation built on Sept. 9, 2020, 12:40 a.m.