<commit_before># ll-parser (recursive-descent)
# e0 -> e1
# e0 -> e1 + e0
# e0 -> e1 - e0
# e1 -> e2
# e1 -> e2 * e1
# e1 -> e2 / e1
# e2 -> number
# e2 -> function()
# e2 -> function(l0)
# e2 -> constant
# e2 -> ( e0 )
# l0 -> e0
# l0 -> e0 , l0

import math
import random

def calc(expr):
    x = [c for c in expr if not c.isspace()]
    x.append('$')
    x = "".join(x)

    p = [0]

    def require(b):
        if not b:
            raise Exception("parse error, unexpected %r" % peek())
    def nom():
        p[0] = p[0] + 1
    def peek():
        return x[p[0]]

    functions = dict([(name, getattr(math, name)) for name in
                      "acos asin atan atan2 ceil cos cosh degrees exp fabs floor fmod frexp hypot ldexp log log10 modf pow radians sin sinh sqrt tan tanh".split(" ")])
    functions.update(dict(random=random.random, randint=random.randint))

    consts = dict(e=math.e, pi=math.pi)

    def e0():
        v = e1()
        if peek() == '+':
            nom()
            v2 = e0()
            return v + v2
        if peek() == '-':
            nom()
            v2 = e0()
            return v - v2
        return v

    def e1():
        v = e2()
        if peek() == '*':
            nom()
            v2 = e1()
            return v * v2
        if peek() == '/':
            nom()<commit_msg>Put all of the useful functions in python2.4's math package in.<commit_after># ll-parser (recursive-descent)
# e0 -> e1
# e0 -> e1 + e0
# e0 -> e1 - e0
# e1 -> e2
# e1 -> e2 * e1
# e1 -> e2 / e1
# e2 -> number
# e2 -> function()
# e2 -> function(l0)
# e2 -> constant
# e2 -> ( e0 )
# l0 -> e0
# l0 -> e0 , l0

import math
import random

def calc(expr):
    x = [c for c in expr if not c.isspace()]
    x.append('$')
    x = "".join(x)

    p = [0]

    def require(b):
        if not b:
            raise Exception("parse error, unexpected %r" % peek())
    def nom():
        p[0] = p[0] + 1
    def peek():
        return x[p[0]]

    functions = dict([(name, getattr(math, name)) for name in
                      "acos asin atan atan2 ceil cos cosh degrees exp fabs floor fmod frexp hypot ldexp log log10 modf radians sin sinh sqrt tan tanh".split(" ")])
    functions['randint'] = random.randint
    functions['complex'] = complex
    functions['pow'] = lambda x, y: x ** y
    consts = dict(e=math.e, pi=math.pi, i=complex(0, 1), j=complex(0, 1))

    def e0():
        v = e1()
        if peek() == '+':
            nom()
            v2 = e0()
            return v + v2
        if peek() == '-':
            nom()
            v2 = e0()
            return v - v2
        return v

    def e1():
        v = e2()
        if peek() == '*':
            nom()
            v2 = e1()
            return v * v2
        if peek() == '/':
            nom()
{'fraction_non_alphanumeric': 0.16007194244604317, 'fraction_numerical': 0.03741007194244604, 'mean_word_length': 1.572617946345976, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '3117202', 'n_tokens_mistral': 1039, 'n_tokens_neox': 996, 'n_words': 316}