33 const std::string expression_string =
"not(A and B) or C";
35 symbol_table_t symbol_table;
36 symbol_table.create_variable(
"A");
37 symbol_table.create_variable(
"B");
38 symbol_table.create_variable(
"C");
40 expression_t expression;
41 expression.register_symbol_table(symbol_table);
44 parser.
compile(expression_string,expression);
46 printf(
" # | A | B | C | %s\n"
47 "---+---+---+---+-%s\n",
48 expression_string.c_str(),
49 std::string(expression_string.size(),
'-').c_str());
51 for (
int i = 0; i < 8; ++i)
53 symbol_table.get_variable(
"A")->ref() = T((i & 0x01) ? 1 : 0);
54 symbol_table.get_variable(
"B")->ref() = T((i & 0x02) ? 1 : 0);
55 symbol_table.get_variable(
"C")->ref() = T((i & 0x04) ? 1 : 0);
57 const int result =
static_cast<int>(expression.value());
59 printf(
" %d | %d | %d | %d | %d \n",
61 static_cast<int>(symbol_table.get_variable(
"A")->value()),
62 static_cast<int>(symbol_table.get_variable(
"B")->value()),
63 static_cast<int>(symbol_table.get_variable(
"C")->value()),