<commit_before>/**
 * Keywords of the core SugarLisp language
 */

var reader = require('sugarlisp-core/reader'),
    sl = require('./sl-types'),
    utils = require('./utils'),
    debug = require('debug')('sugarlisp:core:keywords:debug'),
    trace = require('debug')('sugarlisp:core:keywords:trace');

exports["var"] = function(forms) {
    if (forms.length < 2) {
      forms.error("missing variable name for var?");
    }
    if (forms.length > 3) {
        this.indent += this.indentSize
    }
    this.transpileSubExpressions(forms)
    var generated = sl.generated()
    generated.push(sl.atom("var", {token:forms[0]}));
    generated.push(" ");

    for (var i = 1; i < forms.length; i = i + 2) {
        if (i > 1) {
            generated.push(",\n" + " ".repeat(this.indent))
        }
        var validName = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
        if (!validName.test(sl.valueOf(forms[i]))) {
          sl.lexerOf(forms[i]).error("Invalid character in var name", forms[i]);
        }
        generated.push(forms[i]);
        if(i+1 < forms.length) {
          generated.push([' = ', forms[i + 1]])
        }
    }
    if (forms.length > 3) {
        this.indent -= this.indentSize
    }

    return generated;
}

exports["return"] = function(forms) {
    var generated = sl.generated("return");
    if(forms.length > 1) {
      generated.push(" ");
      generated.push(sl.isList(forms[1]) ? this.transpileExpression(forms[1]) : forms[1]);
    }
    return generated;
}

function handleFuncs(forms) {
    var generated = sl.generated();
    var fName, fArgs, fBody;

    if (forms.length < 2) {
      forms.error("missing arguments:  function declarations require an argument list and function body");
    }<commit_msg>support let and const as aliases for var<commit_after>/**
 * Keywords of the core SugarLisp language
 */

var reader = require('sugarlisp-core/reader'),
    sl = require('./sl-types'),
    utils = require('./utils'),
    debug = require('debug')('sugarlisp:core:keywords:debug'),
    trace = require('debug')('sugarlisp:core:keywords:trace');

exports["var"] = function(forms) {
    if (forms.length < 2) {
      forms.error("missing variable name for " + sl.valueOf(forms[0]) + "?");
    }
    if (forms.length > 3) {
        this.indent += this.indentSize
    }
    this.transpileSubExpressions(forms)
    var generated = sl.generated()
    generated.push(sl.atom("var", {token:forms[0]}));
    generated.push(" ");

    for (var i = 1; i < forms.length; i = i + 2) {
        if (i > 1) {
            generated.push(",\n" + " ".repeat(this.indent))
        }
        var validName = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
        if (!validName.test(sl.valueOf(forms[i]))) {
          sl.lexerOf(forms[i]).error("Invalid character in var name", forms[i]);
        }
        generated.push(forms[i]);
        if(i+1 < forms.length) {
          generated.push([' = ', forms[i + 1]])
        }
    }
    if (forms.length > 3) {
        this.indent -= this.indentSize
    }

    return generated;
}

// we support the es6 keywords "let" and "const"
// (but we simply output "var" in the generated code)
exports["let"] = exports["var"];
exports["const"] = exports["var"];

exports["return"] = function(forms) {
    var generated = sl.generated("return");
    if(forms.length > 1) {
      generated.push(" ");
      generated.push(sl.isList(forms[1]) ? this.transpileExpression(forms[1]) : forms[1]);
    }
    return generated;
}

function handleFuncs(forms) {
    var generated = sl.generated();
    var fName, fArgs, fBody;

    if (forms.length < 2) {
      forms.error("missing arguments:  function declarations require an argument list and function body");
    }
{'fraction_non_alphanumeric': 0.17498643516006512, 'fraction_numerical': 0.009224091155724362, 'mean_word_length': 2.76608784473953, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1627793', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1185, 'n_words': 256}