<commit_before>#!/usr/bin/env node

import CheddarScope from '../interpreter/core/env/scope';

import colors from 'colors';

import HelperCaret from '../helpers/caret';

import cheddar from '../interpreter/exec';
import tokenizer from '../tokenizer/tok';

import stdlib from '../stdlib/stdlib';

const DRAW_ERROR = (text, type) => console.error(type.red.bold + ": ".dim + text.toString());

module.exports = function(input, args) {
    let GLOBAL_SCOPE = new CheddarScope(null);
    GLOBAL_SCOPE.Scope = new Map(stdlib);

    let Tokenizer = new tokenizer(input, 0);
    let Result = Tokenizer.exec();

    if (!(Result instanceof tokenizer)) {
        DRAW_ERROR(Result, "Syntax Error");
        // Draw error pointer
        console.error(HelperCaret(input, Tokenizer.Index, true));
        return;
    }


    let Executor = new cheddar(Result, GLOBAL_SCOPE);
    let Output = Executor.exec(args);

    if (typeof Output === "string") {
        DRAW_ERROR(Output, "Runtime Error");
    }

    return Output;
};<commit_msg>cli [interfacing]: Reveals stdlib to process<commit_after>#!/usr/bin/env node

import CheddarScope from '../interpreter/core/env/scope';

import colors from 'colors';

import HelperCaret from '../helpers/caret';

import cheddar from '../interpreter/exec';
import tokenizer from '../tokenizer/tok';

import stdlib from '../stdlib/stdlib';

const DRAW_ERROR = (text, type) => console.error(type.red.bold + ": ".dim + text.toString());

let execcheddar = function(input, args) {
    let GLOBAL_SCOPE = new CheddarScope(null);
    GLOBAL_SCOPE.Scope = new Map(stdlib);

    let Tokenizer = new tokenizer(input, 0);
    let Result = Tokenizer.exec();

    if (!(Result instanceof tokenizer)) {
        DRAW_ERROR(Result, "Syntax Error");
        // Draw error pointer
        console.error(HelperCaret(input, Tokenizer.Index, true));
        return;
    }


    let Executor = new cheddar(Result, GLOBAL_SCOPE);
    let Output = Executor.exec(args);

    if (typeof Output === "string") {
        DRAW_ERROR(Output, "Runtime Error");
    }

    return Output;
};

execcheddar.stdlib = require('../stdlib/api');
module.exports = execcheddar;
{'fraction_non_alphanumeric': 0.14351851851851852, 'fraction_numerical': 0.000925925925925926, 'mean_word_length': 3.4012219959266803, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '6491625', 'n_tokens_mistral': 704, 'n_tokens_neox': 674, 'n_words': 174}