get_parent_call_id {autoharp}R Documentation

Get Node Id of Parent Call


Get the node id of the parent call for a given node.


get_parent_call_id(x, node_id)



A TreeHarp object.


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.

See Also



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)

[Package autoharp version 0.0.10 Index]