<commit_before>_ = require "underscore"
SourceMap = require "source-map"
SourceNode = SourceMap.SourceNode

SyntaxTree = require "./syntax-tree.js"
SyntaxNode = SyntaxTree.SyntaxNode
strings = require "./strings"

is_instance = [a A | ret ```a instanceof A```]

preambleStr = {
    // preamble if
    "var _else = {identifier: 'else'};"
    "var _if = function(cond1, lambda1, cond2, lambda2) {"
    "    if (arguments.length % 2 !== 0) {"
    "        throw new Error('if called with an odd number of arguments');"
    "    }"
    "    var i = 0;"
    "    for (var i = 0; i < arguments.length; i += 2) {"
    "        var condition = arguments[i];"
    "        if (condition != null && condition !== false) {"
    "            return arguments[i + 1].call(undefined);"
    "        }"
    "    }"
    "};"
    "" // preamble while
    "var _while = function(conditionLambda, bodyLambda) {"
    "    while (conditionLambda.call(undefined)) {"
    "        bodyLambda.call(undefined);"
    "    }"
    "}"
    ""
}.join "\n"

getPreamble = [
    ret new SourceNode null null null preambleStr
]

IDENTIFIER_REGEX = ```/^[_a-zA-Z0-9]+$/```

// Does something like Array::join, but rets a new<commit_msg>use regex in code-gen<commit_after>_ = require "underscore"
SourceMap = require "source-map"
SourceNode = SourceMap.SourceNode

SyntaxTree = require "./syntax-tree.js"
SyntaxNode = SyntaxTree.SyntaxNode
strings = require "./strings"

is_instance = [a A | ret ```a instanceof A```]

preambleStr = {
    // preamble if
    "var _else = {identifier: 'else'};"
    "var _if = function(cond1, lambda1, cond2, lambda2) {"
    "    if (arguments.length % 2 !== 0) {"
    "        throw new Error('if called with an odd number of arguments');"
    "    }"
    "    var i = 0;"
    "    for (var i = 0; i < arguments.length; i += 2) {"
    "        var condition = arguments[i];"
    "        if (condition != null && condition !== false) {"
    "            return arguments[i + 1].call(undefined);"
    "        }"
    "    }"
    "};"
    "" // preamble while
    "var _while = function(conditionLambda, bodyLambda) {"
    "    while (conditionLambda.call(undefined)) {"
    "        bodyLambda.call(undefined);"
    "    }"
    "}"
    ""
}.join "\n"

getPreamble = [
    ret new SourceNode null null null preambleStr
]

IDENTIFIER_REGEX = /^[_a-zA-Z0-9]+$/

// Does something like Array::join, but rets a new
{'fraction_non_alphanumeric': 0.15918536990856194, 'fraction_numerical': 0.00997506234413965, 'mean_word_length': 2.453371592539455, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '710938', 'n_tokens_mistral': 815, 'n_tokens_neox': 778, 'n_words': 204}