41 symbol_table_t mutable_symbol_table;
42 symbol_table_t immutable_symbol_table(symbol_table_t::symtab_mutability_type::e_immutable);
44 mutable_symbol_table.add_variable(
"x", x);
45 mutable_symbol_table.add_variable(
"y", y);
47 immutable_symbol_table.add_variable(
"z", z);
48 immutable_symbol_table.add_variable(
"w", w);
50 expression_t expression;
51 expression.register_symbol_table(immutable_symbol_table);
52 expression.register_symbol_table(mutable_symbol_table );
56 std::vector<std::string> expressions =
59 "y := y / x + (z / w)",
64 for (
const auto& expression_str : expressions)
67 if (!parser.compile(expression_str, expression))
69 for (std::size_t error_idx = 0; error_idx < parser.error_count(); ++error_idx)
71 const auto error = parser.get_error(error_idx);
72 printf(
"Error: %02d Pos: %02d Type: [%14s] Message: %s\tExpression: %s\n",
73 static_cast<unsigned int>(error_idx),
74 static_cast<unsigned int>(error.token.position),
76 error.diagnostic.c_str(),
77 expression_str.c_str());