summaryrefslogtreecommitdiff
path: root/colm/tree.cpp
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2009-03-01 02:42:25 +0000
committerAdrian Thurston <thurston@complang.org>2009-03-01 02:42:25 +0000
commitf067b4e5d7039c37e6cfb199d442862c0819b889 (patch)
treee7fb0ce1ce3456b4d839dbc6dab7f73afef546de /colm/tree.cpp
parent208a0090dd0f6c12776eeb032f4f06f25f630a79 (diff)
downloadcolm-f067b4e5d7039c37e6cfb199d442862c0819b889.tar.gz
Include captured attributes in constructor patterns and add them to the
construced tree at runtime.
Diffstat (limited to 'colm/tree.cpp')
-rw-r--r--colm/tree.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/colm/tree.cpp b/colm/tree.cpp
index 42bcec9b..434a34f6 100644
--- a/colm/tree.cpp
+++ b/colm/tree.cpp
@@ -259,6 +259,19 @@ Tree *construct_replacement_tree( Tree **bindings, Program *prg, long pat )
tree->child = kid_list_concat( attrs,
kid_list_concat( ignore, child ) );
+
+ for ( int i = 0; i < lelInfo[tree->id].numCaptureAttr; i++ ) {
+ long ci = pat+1+i;
+ CaptureAttr *ca = prg->rtd->captureAttr + lelInfo[tree->id].captureAttr + i;
+ Tree *attr = prg->treePool.allocate();
+ attr->id = nodes[ci].id;
+ attr->refs = 1;
+ attr->tokdata = nodes[ci].length == 0 ? 0 :
+ string_alloc_const( prg,
+ nodes[ci].data, nodes[ci].length );
+
+ set_attr( tree, ca->offset, attr );
+ }
}
return tree;