Description Usage Arguments Details Value See Also Examples
View source: R/tree_routines.R
Get the node id of the parent call for a given node.
1 | get_parent_call_id(x, node_id)
|
x |
A TreeHarp object. |
node_id |
The id of the node whose parent call is to be found. An integer value. |
When we need to go up the parse tree to obtain the function that
called this node, we use this function. It is similar to get_parent_id
,
except that that function only returns the immediate parent.
It is not useful to call this function when the TreeHarp object is not constructed from a language object.
Perhaps this function is necessary only because of the way language objects are represented by the autoharp: formal arguments are included in the tree representation. When we wish to find the calling function, we have to walk up the branches till we reach a function call.
An integer corresponding to the node id of the calling function.
1 2 3 4 5 6 7 | ex3 <- quote(x <- f(y = g(3, 4), z=1L))
t1 <- TreeHarp(ex3, TRUE)
# get the function that calls g:
get_parent_call_id(t1, 6)
#contrast with this:
get_parent_id(t1, 6)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.