- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的野牛语法有问题,它给我转移/减少错误,我已经为运算符定义了优先级。
我知道这是由 expr 规则的“expr binop expr”位引起的。这是我的野牛文件,以及我得到的输出。任何帮助将不胜感激。
%token ID KEYWORD INTCON FLOATCON TYPE STRING
%token IF WHILE FOR VOID RETURN
%token AND_OP OR_OP EQ_OP NEQ_OP LEQ_OP GEQ_OP
%left OR_OP
%left AND_OP
%nonassoc '<' LEQ_OP '>' GEQ_OP EQ_OP NEQ_OP
%left '+' '-'
%left '/' '*'
%right '!'
%%
expr : unop expr
| expr binop expr
| ID
| ID '[' expr ']'
| ID '(' expr_list ')'
| ID '(' ')'
| '(' expr ')'
| INTCON
| FLOATCON
;
expr_list : expr
| expr_list ',' expr
;
unop : '!' ;
binop : AND_OP | OR_OP | EQ_OP | NEQ_OP | '+' | '-' | '*' | '/' | LEQ_OP | '<' | GEQ_OP | '>' ;
Terminals unused in grammar
KEYWORD
TYPE
STRING
IF
WHILE
FOR
VOID
RETURN
State 25 conflicts: 12 shift/reduce
State 31 conflicts: 12 shift/reduce
Grammar
0 $accept: expr $end
1 expr: unop expr
2 | expr binop expr
3 | ID
4 | ID '[' expr ']'
5 | ID '(' expr_list ')'
6 | ID '(' ')'
7 | '(' expr ')'
8 | INTCON
9 | FLOATCON
10 expr_list: expr
11 | expr_list ',' expr
12 unop: '!'
13 binop: AND_OP
14 | OR_OP
15 | EQ_OP
16 | NEQ_OP
17 | '+'
18 | '-'
19 | '*'
20 | '/'
21 | LEQ_OP
22 | '<'
23 | GEQ_OP
24 | '>'
Terminals, with rules where they appear
$end (0) 0
'!' (33) 12
'(' (40) 5 6 7
')' (41) 5 6 7
'*' (42) 19
'+' (43) 17
',' (44) 11
'-' (45) 18
'/' (47) 20
'<' (60) 22
'>' (62) 24
'[' (91) 4
']' (93) 4
error (256)
ID (258) 3 4 5 6
KEYWORD (259)
INTCON (260) 8
FLOATCON (261) 9
TYPE (262)
STRING (263)
IF (264)
WHILE (265)
FOR (266)
VOID (267)
RETURN (268)
AND_OP (269) 13
OR_OP (270) 14
EQ_OP (271) 15
NEQ_OP (272) 16
LEQ_OP (273) 21
GEQ_OP (274) 23
Nonterminals, with rules where they appear
$accept (32)
on left: 0
expr (33)
on left: 1 2 3 4 5 6 7 8 9, on right: 0 1 2 4 7 10 11
expr_list (34)
on left: 10 11, on right: 5 11
unop (35)
on left: 12, on right: 1
binop (36)
on left: 13 14 15 16 17 18 19 20 21 22 23 24, on right: 2
state 0
0 $accept: . expr $end
1 expr: . unop expr
2 | . expr binop expr
3 | . ID
4 | . ID '[' expr ']'
5 | . ID '(' expr_list ')'
6 | . ID '(' ')'
7 | . '(' expr ')'
8 | . INTCON
9 | . FLOATCON
12 unop: . '!'
ID shift, and go to state 1
INTCON shift, and go to state 2
FLOATCON shift, and go to state 3
'!' shift, and go to state 4
'(' shift, and go to state 5
expr go to state 6
unop go to state 7
state 1
3 expr: ID . [$end, AND_OP, OR_OP, EQ_OP, NEQ_OP, LEQ_OP, GEQ_OP, '<', '>', '+', '-', '/', '*', ']', ')', ',']
4 | ID . '[' expr ']'
5 | ID . '(' expr_list ')'
6 | ID . '(' ')'
'(' shift, and go to state 8
'[' shift, and go to state 9
$default reduce using rule 3 (expr)
state 2
8 expr: INTCON .
$default reduce using rule 8 (expr)
state 3
9 expr: FLOATCON .
$default reduce using rule 9 (expr)
state 4
12 unop: '!' .
$default reduce using rule 12 (unop)
state 5
1 expr: . unop expr
2 | . expr binop expr
3 | . ID
4 | . ID '[' expr ']'
5 | . ID '(' expr_list ')'
6 | . ID '(' ')'
7 | . '(' expr ')'
7 | '(' . expr ')'
8 | . INTCON
9 | . FLOATCON
12 unop: . '!'
ID shift, and go to state 1
INTCON shift, and go to state 2
FLOATCON shift, and go to state 3
'!' shift, and go to state 4
'(' shift, and go to state 5
expr go to state 10
unop go to state 7
state 6
0 $accept: expr . $end
2 expr: expr . binop expr
13 binop: . AND_OP
14 | . OR_OP
15 | . EQ_OP
16 | . NEQ_OP
17 | . '+'
18 | . '-'
19 | . '*'
20 | . '/'
21 | . LEQ_OP
22 | . '<'
23 | . GEQ_OP
24 | . '>'
$end shift, and go to state 11
AND_OP shift, and go to state 12
OR_OP shift, and go to state 13
EQ_OP shift, and go to state 14
NEQ_OP shift, and go to state 15
LEQ_OP shift, and go to state 16
GEQ_OP shift, and go to state 17
'<' shift, and go to state 18
'>' shift, and go to state 19
'+' shift, and go to state 20
'-' shift, and go to state 21
'/' shift, and go to state 22
'*' shift, and go to state 23
binop go to state 24
state 7
1 expr: . unop expr
1 | unop . expr
2 | . expr binop expr
3 | . ID
4 | . ID '[' expr ']'
5 | . ID '(' expr_list ')'
6 | . ID '(' ')'
7 | . '(' expr ')'
8 | . INTCON
9 | . FLOATCON
12 unop: . '!'
ID shift, and go to state 1
INTCON shift, and go to state 2
FLOATCON shift, and go to state 3
'!' shift, and go to state 4
'(' shift, and go to state 5
expr go to state 25
unop go to state 7
state 8
1 expr: . unop expr
2 | . expr binop expr
3 | . ID
4 | . ID '[' expr ']'
5 | . ID '(' expr_list ')'
5 | ID '(' . expr_list ')'
6 | . ID '(' ')'
6 | ID '(' . ')'
7 | . '(' expr ')'
8 | . INTCON
9 | . FLOATCON
10 expr_list: . expr
11 | . expr_list ',' expr
12 unop: . '!'
ID shift, and go to state 1
INTCON shift, and go to state 2
FLOATCON shift, and go to state 3
'!' shift, and go to state 4
'(' shift, and go to state 5
')' shift, and go to state 26
expr go to state 27
expr_list go to state 28
unop go to state 7
state 9
1 expr: . unop expr
2 | . expr binop expr
3 | . ID
4 | . ID '[' expr ']'
4 | ID '[' . expr ']'
5 | . ID '(' expr_list ')'
6 | . ID '(' ')'
7 | . '(' expr ')'
8 | . INTCON
9 | . FLOATCON
12 unop: . '!'
ID shift, and go to state 1
INTCON shift, and go to state 2
FLOATCON shift, and go to state 3
'!' shift, and go to state 4
'(' shift, and go to state 5
expr go to state 29
unop go to state 7
state 10
2 expr: expr . binop expr
7 | '(' expr . ')'
13 binop: . AND_OP
14 | . OR_OP
15 | . EQ_OP
16 | . NEQ_OP
17 | . '+'
18 | . '-'
19 | . '*'
20 | . '/'
21 | . LEQ_OP
22 | . '<'
23 | . GEQ_OP
24 | . '>'
AND_OP shift, and go to state 12
OR_OP shift, and go to state 13
EQ_OP shift, and go to state 14
NEQ_OP shift, and go to state 15
LEQ_OP shift, and go to state 16
GEQ_OP shift, and go to state 17
'<' shift, and go to state 18
'>' shift, and go to state 19
'+' shift, and go to state 20
'-' shift, and go to state 21
'/' shift, and go to state 22
'*' shift, and go to state 23
')' shift, and go to state 30
binop go to state 24
state 11
0 $accept: expr $end .
$default accept
state 12
13 binop: AND_OP .
$default reduce using rule 13 (binop)
state 13
14 binop: OR_OP .
$default reduce using rule 14 (binop)
state 14
15 binop: EQ_OP .
$default reduce using rule 15 (binop)
state 15
16 binop: NEQ_OP .
$default reduce using rule 16 (binop)
state 16
21 binop: LEQ_OP .
$default reduce using rule 21 (binop)
state 17
23 binop: GEQ_OP .
$default reduce using rule 23 (binop)
state 18
22 binop: '<' .
$default reduce using rule 22 (binop)
state 19
24 binop: '>' .
$default reduce using rule 24 (binop)
state 20
17 binop: '+' .
$default reduce using rule 17 (binop)
state 21
18 binop: '-' .
$default reduce using rule 18 (binop)
state 22
20 binop: '/' .
$default reduce using rule 20 (binop)
state 23
19 binop: '*' .
$default reduce using rule 19 (binop)
state 24
1 expr: . unop expr
2 | . expr binop expr
2 | expr binop . expr
3 | . ID
4 | . ID '[' expr ']'
5 | . ID '(' expr_list ')'
6 | . ID '(' ')'
7 | . '(' expr ')'
8 | . INTCON
9 | . FLOATCON
12 unop: . '!'
ID shift, and go to state 1
INTCON shift, and go to state 2
FLOATCON shift, and go to state 3
'!' shift, and go to state 4
'(' shift, and go to state 5
expr go to state 31
unop go to state 7
state 25
1 expr: unop expr . [$end, AND_OP, OR_OP, EQ_OP, NEQ_OP, LEQ_OP, GEQ_OP, '<', '>', '+', '-', '/', '*', ']', ')', ',']
2 | expr . binop expr
13 binop: . AND_OP
14 | . OR_OP
15 | . EQ_OP
16 | . NEQ_OP
17 | . '+'
18 | . '-'
19 | . '*'
20 | . '/'
21 | . LEQ_OP
22 | . '<'
23 | . GEQ_OP
24 | . '>'
AND_OP shift, and go to state 12
OR_OP shift, and go to state 13
EQ_OP shift, and go to state 14
NEQ_OP shift, and go to state 15
LEQ_OP shift, and go to state 16
GEQ_OP shift, and go to state 17
'<' shift, and go to state 18
'>' shift, and go to state 19
'+' shift, and go to state 20
'-' shift, and go to state 21
'/' shift, and go to state 22
'*' shift, and go to state 23
AND_OP [reduce using rule 1 (expr)]
OR_OP [reduce using rule 1 (expr)]
EQ_OP [reduce using rule 1 (expr)]
NEQ_OP [reduce using rule 1 (expr)]
LEQ_OP [reduce using rule 1 (expr)]
GEQ_OP [reduce using rule 1 (expr)]
'<' [reduce using rule 1 (expr)]
'>' [reduce using rule 1 (expr)]
'+' [reduce using rule 1 (expr)]
'-' [reduce using rule 1 (expr)]
'/' [reduce using rule 1 (expr)]
'*' [reduce using rule 1 (expr)]
$default reduce using rule 1 (expr)
binop go to state 24
state 26
6 expr: ID '(' ')' .
$default reduce using rule 6 (expr)
state 27
2 expr: expr . binop expr
10 expr_list: expr . [')', ',']
13 binop: . AND_OP
14 | . OR_OP
15 | . EQ_OP
16 | . NEQ_OP
17 | . '+'
18 | . '-'
19 | . '*'
20 | . '/'
21 | . LEQ_OP
22 | . '<'
23 | . GEQ_OP
24 | . '>'
AND_OP shift, and go to state 12
OR_OP shift, and go to state 13
EQ_OP shift, and go to state 14
NEQ_OP shift, and go to state 15
LEQ_OP shift, and go to state 16
GEQ_OP shift, and go to state 17
'<' shift, and go to state 18
'>' shift, and go to state 19
'+' shift, and go to state 20
'-' shift, and go to state 21
'/' shift, and go to state 22
'*' shift, and go to state 23
$default reduce using rule 10 (expr_list)
binop go to state 24
state 28
5 expr: ID '(' expr_list . ')'
11 expr_list: expr_list . ',' expr
')' shift, and go to state 32
',' shift, and go to state 33
state 29
2 expr: expr . binop expr
4 | ID '[' expr . ']'
13 binop: . AND_OP
14 | . OR_OP
15 | . EQ_OP
16 | . NEQ_OP
17 | . '+'
18 | . '-'
19 | . '*'
20 | . '/'
21 | . LEQ_OP
22 | . '<'
23 | . GEQ_OP
24 | . '>'
AND_OP shift, and go to state 12
OR_OP shift, and go to state 13
EQ_OP shift, and go to state 14
NEQ_OP shift, and go to state 15
LEQ_OP shift, and go to state 16
GEQ_OP shift, and go to state 17
'<' shift, and go to state 18
'>' shift, and go to state 19
'+' shift, and go to state 20
'-' shift, and go to state 21
'/' shift, and go to state 22
'*' shift, and go to state 23
']' shift, and go to state 34
binop go to state 24
state 30
7 expr: '(' expr ')' .
$default reduce using rule 7 (expr)
state 31
2 expr: expr . binop expr
2 | expr binop expr . [$end, AND_OP, OR_OP, EQ_OP, NEQ_OP, LEQ_OP, GEQ_OP, '<', '>', '+', '-', '/', '*', ']', ')', ',']
13 binop: . AND_OP
14 | . OR_OP
15 | . EQ_OP
16 | . NEQ_OP
17 | . '+'
18 | . '-'
19 | . '*'
20 | . '/'
21 | . LEQ_OP
22 | . '<'
23 | . GEQ_OP
24 | . '>'
AND_OP shift, and go to state 12
OR_OP shift, and go to state 13
EQ_OP shift, and go to state 14
NEQ_OP shift, and go to state 15
LEQ_OP shift, and go to state 16
GEQ_OP shift, and go to state 17
'<' shift, and go to state 18
'>' shift, and go to state 19
'+' shift, and go to state 20
'-' shift, and go to state 21
'/' shift, and go to state 22
'*' shift, and go to state 23
AND_OP [reduce using rule 2 (expr)]
OR_OP [reduce using rule 2 (expr)]
EQ_OP [reduce using rule 2 (expr)]
NEQ_OP [reduce using rule 2 (expr)]
LEQ_OP [reduce using rule 2 (expr)]
GEQ_OP [reduce using rule 2 (expr)]
'<' [reduce using rule 2 (expr)]
'>' [reduce using rule 2 (expr)]
'+' [reduce using rule 2 (expr)]
'-' [reduce using rule 2 (expr)]
'/' [reduce using rule 2 (expr)]
'*' [reduce using rule 2 (expr)]
$default reduce using rule 2 (expr)
binop go to state 24
state 32
5 expr: ID '(' expr_list ')' .
5 expr: ID '(' expr_list ')' .
$default reduce using rule 5 (expr)
state 33
1 expr: . unop expr
2 | . expr binop expr
3 | . ID
4 | . ID '[' expr ']'
5 | . ID '(' expr_list ')'
6 | . ID '(' ')'
7 | . '(' expr ')'
8 | . INTCON
9 | . FLOATCON
11 expr_list: expr_list ',' . expr
12 unop: . '!'
ID shift, and go to state 1
INTCON shift, and go to state 2
FLOATCON shift, and go to state 3
'!' shift, and go to state 4
'(' shift, and go to state 5
expr go to state 35
unop go to state 7
state 34
4 expr: ID '[' expr ']' .
$default reduce using rule 4 (expr)
state 35
2 expr: expr . binop expr
11 expr_list: expr_list ',' expr . [')', ',']
13 binop: . AND_OP
14 | . OR_OP
15 | . EQ_OP
16 | . NEQ_OP
17 | . '+'
18 | . '-'
19 | . '*'
20 | . '/'
21 | . LEQ_OP
22 | . '<'
23 | . GEQ_OP
24 | . '>'
AND_OP shift, and go to state 12
OR_OP shift, and go to state 13
EQ_OP shift, and go to state 14
NEQ_OP shift, and go to state 15
LEQ_OP shift, and go to state 16
GEQ_OP shift, and go to state 17
'<' shift, and go to state 18
'>' shift, and go to state 19
'+' shift, and go to state 20
'-' shift, and go to state 21
'/' shift, and go to state 22
'*' shift, and go to state 23
$default reduce using rule 11 (expr_list)
binop go to state 24
%token ID KEYWORD INTCON FLOATCON TYPE STRING
%token IF WHILE FOR VOID RETURN
%token AND_OP OR_OP EQ_OP NEQ_OP LEQ_OP GEQ_OP
%left "||"
%left "&&"
%nonassoc '<' "<=" '>' ">=" "==" "!="
%left '+' '-'
%left '/' '*'
%right '!'
%%
expr : ID
| ID '[' expr ']'
| ID '(' expr_list ')'
| ID '(' ')'
| '(' expr ')'
| INTCON
| FLOATCON
| '!' expr
| '-' expr
| expr '+' expr
| expr '-' expr
| expr '/' expr
| expr '*' expr
| expr '<' expr
| expr '>' expr
| expr "<=" expr
| expr ">=" expr
| expr "==" expr
| expr "!=" expr
| expr "&&" expr
| expr "||" expr
;
expr_list : expr
| expr_list ',' expr
;
%%
最佳答案
仅当产生式直接包含在优先级声明中指定的终结符时,优先级才有效。
换句话说,您不能使用 expr: expr binop expr
因为优先关系不能帮助野牛决定是否移动减少的binop
非终端或减少expr
在解析堆栈的顶部。 Bison 要知道里面的终端是什么binop
是,但它不再知道了。 (这就是为什么减少被称为“减少”。)
为了使它工作,你必须完整地写出产品:
expr: expr '+' expr
| expr '-' expr
| expr '*' expr
|...
关于类 C 语言的 Bison Shift/减少错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19085340/
我是 Bison 解析的新手,我无法理解它是如何工作的。我有以下语法,其中我保留了最低限度的语法来突出问题。 %left '~' %left '+' %token T_VARIABLE %% star
我链接了 2 个映射器和 1 个缩减器。是否可以将中间输出(链中每个映射器的 o/p)写入 HDFS?我尝试为每个设置 OutputPath,但它似乎不起作用。现在,我不确定是否可以完成。有什么建议吗
我正在编写一些代码来管理自定义磁盘文件结构并将其同步到未连接的系统。我的要求之一是能够在实际生成同步内容之前估计同步的大小。作为一个简单的解决方案,我整理了一个包含完整路径文件名的 map ,作为高效
我来自一个 SQL 世界,其中查找由多个对象属性(published = TRUE 或 user_id = X)完成,并且有 任何地方都没有加入 (因为 1:1 缓存层)。文档数据库似乎很适合我的数据
在 R 中,我有一个整数向量。从这个向量中,我想随机减少每个整数元素的值,以获得向量的总和,即初始总和的百分比。 在这个例子中,我想将向量“x”减少到向量“y”,其中每个元素都被随机减少以获得等于初始
我发现自己遇到过几次我有一个 reducer /组合 fn 的情况,如下所示: def combiner(a: String, b: String): Either[String, String]
Ubuntu 12.04 nginx 1.2.4 avconv版本 avconv version 0.8.10-4:0.8.10-0ubuntu0.12.04.1, Copyright (c) 200
我是 R 编程语言的新手。我有一个包含 2 列(ID 和 Num)的数据集,如下所示: ID Num 3 8 3 12 4 15 4 18 4
我正在使用高阶函数将函数应用于向量中的每个元素并将结果作为标量值返回。 假设我有: v = c(0, 1, 2, 3, 4, 5, 6, 7, 8) 我想计算以左边 5 个整数为中心的所有这些整数的总
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
这个问题在这里已经有了答案: How to write the dataframes in a list to a single csv file (2 个回答) 5年前关闭。 我正在尝试使用 Red
刚开始学习CUDA编程,对归约有些迷茫。 我知道与共享内存相比,全局内存有很多访问延迟,但我可以使用全局内存来(至少)模拟类似于共享内存的行为吗? 例如,我想对长度恰好为 BLOCK_SIZE * T
我经常使用OptiPNG或pngcrush减小PNG图像的文件大小。 我希望能够从.NET应用程序中以编程方式执行此类操作。我正在动态生成要发送到移动设备的PNG,因此我想减小文件大小。 图像质量很重
减少和减少让您在序列上累积状态。 序列中的每个元素都会修改累积的状态,直到 到达序列的末尾。 在无限列表上调用reduce 或reductions 有什么含义? (def c (cycle [0]))
这与R: use the newly generated data in the previous row有关 我意识到我面临的实际问题比我在上面的线程中给出的示例要复杂一些 - 似乎我必须将 3 个
有什么办法可以减少.ttf字体的大小?即如果我们要删除一些我们不使用的glyps。 最佳答案 使用Google Web Fonts,您可以限制字符集,例如: //fonts.googleapis.co
我需要在iOS中制作一个应用程序,在她的工作过程中发出类似“哔”的声音。 我已经使用MPMusicPlayerController实现了与背景ipod的交互。 问题: 由于来自ipod的音乐音量很大,
我有一个嵌套 map m,如下所示: m = Map("电子邮件"-> "a@b.com", "背景"-> Map("语言"-> "英语")) 我有一个数组arr = Array("backgroun
有什么原因为什么不应该转发map / reduce函数中收到的可写内容? 我的意思是-每个map / reduce函数都有一个可写的键/值,并可能发出一个键/值对。如果我想执行一些过滤,我应该只发出接
假设我有一个数据列表 val data = listOf("F 1", "D 2", "U 1", "D 3", "F 10") 我想执行每个元素的给定逻辑。 我必须在外部添加 var acc2 =
我是一名优秀的程序员,十分优秀!