var pullRoot = function(tokens) { var template = ''; if (lex.check(tokens[0], {token: 'space'})) { template = tokens.shift().repr + template; } template += R.repeatN('#', tokens.length || 0).join(''); return astNode('expr', tokens, {template: template}); };
var astNode = function(nodeType, children, options) { children = children || []; options = options || {}; var template = options.template || R.repeatN('#', children.length).join(''); delete options.template; return { id: options.id || undefined, type: 'ASTNode', node: nodeType, template: template, children: children, options: options }; };