<commit_before># -*- coding: utf-8 -*-

from compiler import *
from renderer import *

r = renderer()

class generator(object):

    ast = None

    def __init__(self, template):
        self.template = template
        self.tokenizer()

    def tokenizer(self):
        token = compiler(self.template)
        self.ast = token.tokenize()

    def render(self, scope):
        html = ''
        
        for ast in self.ast:
            if ast['type'] == 'HTML':
                html += ast['value']
            elif ast['type'] == 'VAREXP':
                renderResult = r.renderVariable(ast, scope)
                if isinstance(renderResult, str):
                    html += renderResult
                else:
                    raise RuntimeError('Unknown renderer error in render variable expression')
            elif ast['type'] == 'IFEXP':
                renderResult = r.renderIfExpression(ast, scope)
                if isinstance(renderResult, str):
                    html += renderResult
                else:
                    raise RuntimeError('Unknown renderer error in render variable expression')
            elif ast['type'] == 'FOREXP':
                renderResult = r.renderForExpression(ast, scope)
                if isinstance(renderResult, str):
                    html += renderResult
                else:
                    raise RuntimeError('Unknown renderer error in render variable expression')

        return html<commit_msg>update: update ast renderer error messages<commit_after># -*- coding: utf-8 -*-

from compiler import *
from renderer import *

r = renderer()

class generator(object):

    ast = None

    def __init__(self, template):
        self.template = template
        self.tokenizer()

    def tokenizer(self):
        token = compiler(self.template)
        self.ast = token.tokenize()

    def render(self, scope):
        html = ''

        for ast in self.ast:
            if ast['type'] == 'HTML':
                html += ast['value']
            elif ast['type'] == 'VAREXP':
                renderResult = r.renderVariable(ast, scope)
                if isinstance(renderResult, str):
                    html += renderResult
                else:
                    raise RuntimeError('Unknown renderer error in render variable-expression')
            elif ast['type'] == 'IFEXP':
                renderResult = r.renderIfExpression(ast, scope)
                if isinstance(renderResult, str):
                    html += renderResult
                else:
                    raise RuntimeError('Unknown renderer error in render if-expression')
            elif ast['type'] == 'FOREXP':
                renderResult = r.renderForExpression(ast, scope)
                if isinstance(renderResult, str):
                    html += renderResult
                else:
                    raise RuntimeError('Unknown renderer error in render for-expression')

        return html
{'fraction_non_alphanumeric': 0.09694915254237288, 'fraction_numerical': 0.0006779661016949153, 'mean_word_length': 1.6681735985533455, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2841662', 'n_tokens_mistral': 724, 'n_tokens_neox': 674, 'n_words': 205}