<commit_before>#include "haxor/hc/node/all.hh"
#include "haxor/hc/compiler.hh"
#include "haxor/hc/pseudo.hh"
#include "haxor/common/hdr.hh"
#include "haxor/common/opcode.hh"
#include <sstream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <stdexcept>

namespace haxor {
  compiler::compiler() : lexer(*this), parser(lexer, *this) {
  }

  void compiler::ensure_its_register(node_base * const arg) {
    if (!arg->is_a(node_type::reg)) {
      std::string error_msg = "Invalid argument, unexpected "
        + type_to_string(arg->get_type())
        + ", expecting "
        + type_to_string(node_type::reg);
      if (arg->has_location()) {
        error_msg += " at " + format_location(arg->get_location());
      }
      throw hc_syntax_error(error_msg);
    }
  }

  void compiler::ensure_its_immediate(node_base * const arg) {
    if (!arg->is_a(node_type::num) && !arg->is_a(node_type::label)) {
      std::string error_msg = "Invalid argument, unexpected "
        + type_to_string(arg->get_type())
        + ", expcting "
        + type_to_string(node_type::num)
        + " or "
        + type_to_string(node_type::label);
      if (arg->has_location()) {
        error_msg += ", at " + format_location(arg->get_location());
      }
      throw std::runtime_error(error_msg);
    }
  }

  void compiler::ensure_its_num(node_base * const arg) {
    if (!arg->is_a(node_type::num)) {
      std::string error_msg = "Invalid argument, unexpected "<commit_msg>raise it as a syntax error so it's nicely displayed<commit_after>#include "haxor/hc/node/all.hh"
#include "haxor/hc/compiler.hh"
#include "haxor/hc/pseudo.hh"
#include "haxor/common/hdr.hh"
#include "haxor/common/opcode.hh"
#include <sstream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <stdexcept>

namespace haxor {
  compiler::compiler() : lexer(*this), parser(lexer, *this) {
  }

  void compiler::ensure_its_register(node_base * const arg) {
    if (!arg->is_a(node_type::reg)) {
      std::string error_msg = "Invalid argument, unexpected "
        + type_to_string(arg->get_type())
        + ", expecting "
        + type_to_string(node_type::reg);
      if (arg->has_location()) {
        error_msg += " at " + format_location(arg->get_location());
      }
      throw hc_syntax_error(error_msg);
    }
  }

  void compiler::ensure_its_immediate(node_base * const arg) {
    if (!arg->is_a(node_type::num) && !arg->is_a(node_type::label)) {
      std::string error_msg = "Invalid argument, unexpected "
        + type_to_string(arg->get_type())
        + ", expcting "
        + type_to_string(node_type::num)
        + " or "
        + type_to_string(node_type::label);
      if (arg->has_location()) {
        error_msg += ", at " + format_location(arg->get_location());
      }
      throw hc_syntax_error(error_msg);
    }
  }

  void compiler::ensure_its_num(node_base * const arg) {
    if (!arg->is_a(node_type::num)) {
      std::string error_msg = "Invalid argument, unexpected "
{'fraction_non_alphanumeric': 0.1561771561771562, 'fraction_numerical': 0.0, 'mean_word_length': 3.497005988023952, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 33, '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': '4705834', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1040, 'n_words': 173}