<commit_before>{ concat-map }   = require \prelude-ls
root-macro-table = require \./built-in-macros
statementify     = require \./es-statementify

module.exports = (ast) ->

  macro-table = contents : {}, parent : root-macro-table
  statements = ast.content

  type : \Program
  body : statements
    |> concat-map (.compile macro-table)
    |> (.filter (isnt null)) # macro definitions emit nothing, hence this
    |> (.map statementify)
<commit_msg>Comment why initial macro table has extra node<commit_after>{ concat-map }   = require \prelude-ls
root-macro-table = require \./built-in-macros
statementify     = require \./es-statementify

module.exports = (ast) ->

  # Create an extra node on the "linked list" of macro tables so multiple runs
  # of the compiler have somewhere to put any new macro definitions, without
  # changing the underlying root macro table.  This guards multiple compiler
  # invocations from accidentally influencing each other.
  macro-table = contents : {}, parent : root-macro-table

  statements = ast.content

  type : \Program
  body : statements
         |> concat-map (.compile macro-table)
         |> (.filter (isnt null)) # because macro definitions emit null
         |> (.map statementify)

{'fraction_non_alphanumeric': 0.10850202429149798, 'fraction_numerical': 0.0, 'mean_word_length': 3.175675675675676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6767333', 'n_tokens_mistral': 358, 'n_tokens_neox': 334, 'n_words': 120}