<commit_before>import Foundation
import Strix2

public struct Calculator {
    private let prattParser: PrattParser<Double>
    private let tokenizer: Parser<Token>
    
    public init() {
        prattParser = PrattParserGenerator().prattParser
        tokenizer = TokenizerGenerator().tokenizer
    }
    
    public func calculate(_ expression: String) throws -> Double {
        return try prattParser.parse(expression, with: tokenizer)
    }
    
    public func callAsFunction(_ expression: String) throws -> Double {
        return try calculate(expression)
    }
}

private struct TokenizerGenerator {
    var tokenizer: Parser<Token> {
        return ws *> .any(of: [number, name, singleOperator, end])<commit_msg>Calculator를 class 타입으로 변경 (thread-unsafe 하다)<commit_after>import Foundation
import Strix2

public class Calculator {
    private let prattParser: PrattParser<Double>
    private let tokenizer: Parser<Token>
    
    public init() {
        prattParser = PrattParserGenerator().prattParser
        tokenizer = TokenizerGenerator().tokenizer
    }
    
    public func calculate(_ expression: String) throws -> Double {
        return try prattParser.parse(expression, with: tokenizer)
    }
    
    public func callAsFunction(_ expression: String) throws -> Double {
        return try calculate(expression)
    }
}

private struct TokenizerGenerator {
    var tokenizer: Parser<Token> {
        return ws *> .any(of: [number, name, singleOperator, end])
{'fraction_non_alphanumeric': 0.08322056833558863, 'fraction_numerical': 0.0013531799729364006, 'mean_word_length': 3.2869565217391306, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '6596712', 'n_tokens_mistral': 410, 'n_tokens_neox': 407, 'n_words': 116}