コード例 #1
0
ファイル: parse.js プロジェクト: buzzdecafe/expression-parser
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});
};
コード例 #2
0
ファイル: parse.js プロジェクト: buzzdecafe/expression-parser
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
  };
};