我正在尝试使用 boost 的精神气解析器创建解析器。它正在解析包含三种类型值的字符串。常量、变量或函数。这些函数可以相互嵌套。测试字符串是f(a, b) = f(g(z, x), g(x, h(x)), c),其中a-e是常量,f-r是函数,s-z是变量。我成功创建了一个可以正确解析表达式的规则。当我将解析规则的函数更改为语法时出现了问题. 有几个错误我可以修复。我几乎掌握了解析表达式的语法,并将其转换为我创建的抽象语法树。但是,我收到了关于包含在 boost 库中的文件的这个错误,我无法弄清楚它来自哪里,因为我不理解编译器消息。我正在按照网站上的示例使用员工示例将数据从解析器放入结构:http : //www.boost.org/doc/libs/1_41_0/libs/spirit/example/qi/employee。 cp
主程序
#include "Parser.h"
#include "Term.h"
#include <boost/spirit/include/qi.hpp>
#include <string>
#include <iostream>
#include <list>
using std::string;
using std::cout;
using std::endl;
int main()
{
cout << "Unification Algorithm" << endl << endl;
string phrase = "f(a, b) = f(g(z, x), g(x, h(x)), c)";
string::const_iterator itr = phrase.begin();
string::const_iterator last = phrase.end();
cout << phrase << …Run Code Online (Sandbox Code Playgroud)