Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';无法通过%define指令上的简单Bison语法文件语法错误_C_Bison - Fatal编程技术网

Can';无法通过%define指令上的简单Bison语法文件语法错误

Can';无法通过%define指令上的简单Bison语法文件语法错误,c,bison,C,Bison,我正在使用Bison 2.4.1和Flex 2.5.35创建一个语言解析器。然而,我被野牛困住了,它已经给了我3个小时相同的错误,我不明白为什么 我有一个野牛语法文件mylang.y: %{ #include <stdio.h> #include <stdlib.h> #include <glib/gtree.h> #include <glib/gnode.h> #include "ast.h" %} %code requires { struc

我正在使用Bison 2.4.1和Flex 2.5.35创建一个语言解析器。然而,我被野牛困住了,它已经给了我3个小时相同的错误,我不明白为什么

我有一个野牛语法文件
mylang.y

%{
#include <stdio.h>
#include <stdlib.h>
#include <glib/gtree.h>
#include <glib/gnode.h>
#include "ast.h"
%}

%code requires {
struct my_value {
  enum {
    is_int, 
    is_str
  } kind;
  union {
    int ival;
    char *sval;
  } u;
};
}
%define api.value.type {struct my_value}

%token KEYWORD
%token <u.sval> ID
%token <y.ival> NUM
...
%%
... 
// Rules following, but still defining no action at all.
%%
// Nothing more
我得到这个错误:

mylang.y:20.24-40:语法错误,意外{…}

错误中报告的行是
%define
指令所在的行。 我不明白如何度过这一关。我做错了什么? 多谢各位

我正在使用Bison 2.4.1和Flex 2.5.35创建一个语言解析器

您尝试使用的功能已添加到Bison 3.0中

历史:在Bison 3.0中引入。仅在2.3b中作为stype为Java引入


您可以下载Bison 3.0。

我假设您的Bison版本是3+,对吗?我添加了关于问题中所有内容的信息,很抱歉在等待之前没有报告,,,我认为2.4.1是最新版本…所以问题是我使用的是过时的Bison版本???我确实在CentOS上使用yum repo安装了Bison。。。我想我得到了最新的:(安装了3.0。谢谢:)
bison  -vd --report=state,itemset --graph  mylang.y