CFPEEK |
|
CFPEEK |
Sergey Poznyakoff |
This chapter describes the Scheme functions available for use in
cfpeek
scripts. For an introduction to cfpeek
scripting facility, see Scripts.
Returns ‘#t’ if obj is a valid tree node.
Returns the topmost node that can be traced up from node.
Returns the first node having the same parent and located on the same nesting level as node. I.e. the following always holds true:
(let ((head (grecs-node-head node))) (and (eq? (grecs-node-up node) (grecs-node-up head)) (not (grecs-node-prev? head))))
Returns the last node having the same parent and located on the same nesting level as node. In other words, the following relation is always ‘#t’:
(let ((tail (grecs-node-tail node))) (and (eq? (grecs-node-up node) (grecs-node-up tail)) (not (grecs-node-next? tail))))
Return true if node has a parent node.
Return parent node of node.
Returns ‘#t’ if node has child nodes.
Returns the first child node of node.
Returns ‘#t’ if node is followed by another node on the same nesting level.
Returns the node following node on the same nesting level.
Returns ‘#t’ if node is preceded by another node on the same nesting level.
Returns the node preceding node on the same nesting level.
Returns identifier of the node node.
Returns locus of the node’s identifier. Returned value is a cons whose parts depend on full, which is a boolean value. If full is ‘#f’, which is the default, then returned value is a cons:
(file-name . line-number)
Oherwise, if full is ‘#t’, the function returns the locations where the node begins and ends:
((beg-file-name beg-line beg-column) . (end-file-name end-line end-column))
Returns the full path to the node, converted to a list. Each list element corresponds to a subnode identifier. A subnode which has a tag is represented by a cons, whose car contains the subnode identifier, and cdr its value. For example, the following path:
.foo.bar=x.baz
is represented as
'("foo" ("bar" . "x") "baz")
Returns the full path to the node (a string).
Returns the type of the node. The following constants are defined:
The node is a root node. The following is always ‘#t’:
(and (= (grecs-node-type node) grecs-node-root) (not (grecs-node-up? node)) (not (grecs-node-prev? node)))
The node is a simple statement. The following is always ‘#t’:
(and (= (grecs-node-type node) grecs-node-stmt) (not (grecs-node-down? node)))
The node is a block statement.
Returns ‘#t’ if node has a value.
Returns the value of node.
Returns locus of the node’s value. Returned value is a cons whose parts depend on full, which is a boolean value. If full is ‘#f’, which is the default, then returned value is a cons:
(file-name . line-number)
Oherwise, if full is ‘#t’, the function returns the locations where the node begins and ends:
((beg-file-name beg-line beg-column) . (end-file-name end-line end-column))
Returns source location of the node. Returned value is a cons whose parts depend on full, which is a boolean value. If full is ‘#f’, which is the default, then returned value is a cons:
(file-name . line-number)
Oherwise, if full is ‘#t’, the function returns the locations where the node begins and ends:
((beg-file-name beg-line beg-column) . (end-file-name end-line end-column))
Returns the first node whose path is path. Starts search from node.
Returns the first node whose path matches pattern. The search is started from node.
Node must be a node returned by a previous call to grecs-match-first
or ‘grecs-match-next’. The function returns next node matching the initial pattern, or ‘#f’ if no more matches are found. For example, the following code iterates over all nodes matching pattern:
(define (iterate-nodes root pattern thunk) (do ((node (grecs-match-first root pattern) (grecs-match-next node))) ((not node)) (thunk node)))
This document was generated on January 7, 2021 using makeinfo.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.