小编rfo*_*eck的帖子

C++:字符串和工会野牛

我正在flex和bison中构建一个编译器.问题是使用char *会带来很多问题,所以我试图将所有内容迁移到string.

剩下的唯一问题是有一个union字符串.我知道这不是标准,但通过使用指针应该没有问题.

相关代码:

#include <string>

using namespace std;

//-- SYMBOL SEMANTIC VALUES -----------------------------
%union {
  struct lc{
     string * code;
     string * start;
     string * verdadero;
     string * falso;
     string * next;
  }code;    
}
Run Code Online (Sandbox Code Playgroud)

奇怪的是我收到的错误:

file.ypp:39:6: error: ‘string’ does not name a type
string * start;
file.ypp:40:6: error: ‘string’ does not name a type
string * verdadero;
file.ypp:41:6: error: ‘string’ does not name a type
string * falso;
file.ypp:42:6: error: ‘string’ does not …
Run Code Online (Sandbox Code Playgroud)

c++ string bison unions

5
推荐指数
1
解决办法
3831
查看次数

标签 统计

bison ×1

c++ ×1

string ×1

unions ×1