<commit_before># json tree for d3 for formulas

FormulaVisitor = require './visitor'

class TreeBuilder extends FormulaVisitor
  visitLiteral: (node) ->
    { name: node.value }
  visitReference: (node) ->
    { name: node.name }
  visitParens: (node) ->
    { name: '(_)', children: [node.formula.visit @] }
  visitInfixExpression: (node) ->
    super node, (a, b) ->
      { name: node.operator, children: [a, b] }
  visitFunctionCall: (node) ->
    { name: "#{node.name}()", children: (param.visit @ for param in node.parameters) }

module.exports = ( formula ) ->
  formula.visit new TreeBuilder()<commit_msg>tree: show string literal with quotes<commit_after># json tree for d3 for formulas

FormulaVisitor = require './visitor'

class TreeBuilder extends FormulaVisitor
  visitLiteral: (node) ->
    { name: node.value }
  visitStringLiteral: (node) ->
    { name: "'#{node.value}'" }
  visitReference: (node) ->
    { name: node.name }
  visitParens: (node) ->
    { name: '(_)', children: [node.formula.visit @] }
  visitInfixExpression: (node) ->
    super node, (a, b) ->
      { name: node.operator, children: [a, b] }
  visitFunctionCall: (node) ->
    { name: "#{node.name}()", children: (param.visit @ for param in node.parameters) }

module.exports = ( formula ) ->
  formula.visit new TreeBuilder()
{'fraction_non_alphanumeric': 0.16210045662100456, 'fraction_numerical': 0.0015220700152207, 'mean_word_length': 3.4880546075085324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3549557', 'n_tokens_mistral': 428, 'n_tokens_neox': 424, 'n_words': 114}