98e903e7a0
bison, keeping full compatibility with our previous yacc implementation. Also bring the ability to create reentrant parser This fix bin/140309 [1] PR: bin/140309 [1] Submitted by: Philippe Pepiot <ksh@philpep.org> [1] Approved by: des (mentor) MFC after: 1 month
558 lines
11 KiB
Plaintext
558 lines
11 KiB
Plaintext
0 $accept : list $end
|
||
|
||
1 list :
|
||
2 | list stat '\n'
|
||
3 | list error '\n'
|
||
|
||
4 stat : expr
|
||
5 | LETTER '=' expr
|
||
|
||
6 expr : '(' expr ')'
|
||
7 | expr "ADD" expr
|
||
8 | expr "SUB" expr
|
||
9 | expr "MUL" expr
|
||
10 | expr "DIV" expr
|
||
11 | expr "MOD" expr
|
||
12 | expr "AND" expr
|
||
13 | expr '|' expr
|
||
14 | "SUB" expr
|
||
15 | LETTER
|
||
16 | number
|
||
|
||
17 number : DIGIT
|
||
18 | number DIGIT
|
||
|
||
state 0
|
||
$accept : . list $end (0)
|
||
list : . (1)
|
||
|
||
. reduce 1
|
||
|
||
list goto 1
|
||
|
||
|
||
state 1
|
||
$accept : list . $end (0)
|
||
list : list . stat '\n' (2)
|
||
list : list . error '\n' (3)
|
||
|
||
$end accept
|
||
error shift 2
|
||
"SUB" shift 3
|
||
DIGIT shift 4
|
||
LETTER shift 5
|
||
'(' shift 6
|
||
. error
|
||
|
||
stat goto 7
|
||
expr goto 8
|
||
number goto 9
|
||
|
||
|
||
state 2
|
||
list : list error . '\n' (3)
|
||
|
||
'\n' shift 10
|
||
. error
|
||
|
||
|
||
state 3
|
||
expr : "SUB" . expr (14)
|
||
|
||
"SUB" shift 3
|
||
DIGIT shift 4
|
||
LETTER shift 11
|
||
'(' shift 6
|
||
. error
|
||
|
||
expr goto 12
|
||
number goto 9
|
||
|
||
|
||
state 4
|
||
number : DIGIT . (17)
|
||
|
||
. reduce 17
|
||
|
||
|
||
state 5
|
||
stat : LETTER . '=' expr (5)
|
||
expr : LETTER . (15)
|
||
|
||
'=' shift 13
|
||
"ADD" reduce 15
|
||
"SUB" reduce 15
|
||
"MUL" reduce 15
|
||
"DIV" reduce 15
|
||
"MOD" reduce 15
|
||
"AND" reduce 15
|
||
'|' reduce 15
|
||
'\n' reduce 15
|
||
|
||
|
||
state 6
|
||
expr : '(' . expr ')' (6)
|
||
|
||
"SUB" shift 3
|
||
DIGIT shift 4
|
||
LETTER shift 11
|
||
'(' shift 6
|
||
. error
|
||
|
||
expr goto 14
|
||
number goto 9
|
||
|
||
|
||
state 7
|
||
list : list stat . '\n' (2)
|
||
|
||
'\n' shift 15
|
||
. error
|
||
|
||
|
||
state 8
|
||
stat : expr . (4)
|
||
expr : expr . "ADD" expr (7)
|
||
expr : expr . "SUB" expr (8)
|
||
expr : expr . "MUL" expr (9)
|
||
expr : expr . "DIV" expr (10)
|
||
expr : expr . "MOD" expr (11)
|
||
expr : expr . "AND" expr (12)
|
||
expr : expr . '|' expr (13)
|
||
|
||
"ADD" shift 16
|
||
"SUB" shift 17
|
||
"MUL" shift 18
|
||
"DIV" shift 19
|
||
"MOD" shift 20
|
||
"AND" shift 21
|
||
'|' shift 22
|
||
'\n' reduce 4
|
||
|
||
|
||
state 9
|
||
expr : number . (16)
|
||
number : number . DIGIT (18)
|
||
|
||
DIGIT shift 23
|
||
"ADD" reduce 16
|
||
"SUB" reduce 16
|
||
"MUL" reduce 16
|
||
"DIV" reduce 16
|
||
"MOD" reduce 16
|
||
"AND" reduce 16
|
||
'|' reduce 16
|
||
'\n' reduce 16
|
||
')' reduce 16
|
||
|
||
|
||
state 10
|
||
list : list error '\n' . (3)
|
||
|
||
. reduce 3
|
||
|
||
|
||
state 11
|
||
expr : LETTER . (15)
|
||
|
||
. reduce 15
|
||
|
||
|
||
12: shift/reduce conflict (shift 16, reduce 14) on "ADD"
|
||
12: shift/reduce conflict (shift 17, reduce 14) on "SUB"
|
||
12: shift/reduce conflict (shift 18, reduce 14) on "MUL"
|
||
12: shift/reduce conflict (shift 19, reduce 14) on "DIV"
|
||
12: shift/reduce conflict (shift 20, reduce 14) on "MOD"
|
||
12: shift/reduce conflict (shift 21, reduce 14) on "AND"
|
||
state 12
|
||
expr : expr . "ADD" expr (7)
|
||
expr : expr . "SUB" expr (8)
|
||
expr : expr . "MUL" expr (9)
|
||
expr : expr . "DIV" expr (10)
|
||
expr : expr . "MOD" expr (11)
|
||
expr : expr . "AND" expr (12)
|
||
expr : expr . '|' expr (13)
|
||
expr : "SUB" expr . (14)
|
||
|
||
"ADD" shift 16
|
||
"SUB" shift 17
|
||
"MUL" shift 18
|
||
"DIV" shift 19
|
||
"MOD" shift 20
|
||
"AND" shift 21
|
||
'|' reduce 14
|
||
'\n' reduce 14
|
||
')' reduce 14
|
||
|
||
|
||
state 13
|
||
stat : LETTER '=' . expr (5)
|
||
|
||
"SUB" shift 3
|
||
DIGIT shift 4
|
||
LETTER shift 11
|
||
'(' shift 6
|
||
. error
|
||
|
||
expr goto 24
|
||
number goto 9
|
||
|
||
|
||
state 14
|
||
expr : '(' expr . ')' (6)
|
||
expr : expr . "ADD" expr (7)
|
||
expr : expr . "SUB" expr (8)
|
||
expr : expr . "MUL" expr (9)
|
||
expr : expr . "DIV" expr (10)
|
||
expr : expr . "MOD" expr (11)
|
||
expr : expr . "AND" expr (12)
|
||
expr : expr . '|' expr (13)
|
||
|
||
"ADD" shift 16
|
||
"SUB" shift 17
|
||
"MUL" shift 18
|
||
"DIV" shift 19
|
||
"MOD" shift 20
|
||
"AND" shift 21
|
||
'|' shift 22
|
||
')' shift 25
|
||
. error
|
||
|
||
|
||
state 15
|
||
list : list stat '\n' . (2)
|
||
|
||
. reduce 2
|
||
|
||
|
||
state 16
|
||
expr : expr "ADD" . expr (7)
|
||
|
||
"SUB" shift 3
|
||
DIGIT shift 4
|
||
LETTER shift 11
|
||
'(' shift 6
|
||
. error
|
||
|
||
expr goto 26
|
||
number goto 9
|
||
|
||
|
||
state 17
|
||
expr : expr "SUB" . expr (8)
|
||
|
||
"SUB" shift 3
|
||
DIGIT shift 4
|
||
LETTER shift 11
|
||
'(' shift 6
|
||
. error
|
||
|
||
expr goto 27
|
||
number goto 9
|
||
|
||
|
||
state 18
|
||
expr : expr "MUL" . expr (9)
|
||
|
||
"SUB" shift 3
|
||
DIGIT shift 4
|
||
LETTER shift 11
|
||
'(' shift 6
|
||
. error
|
||
|
||
expr goto 28
|
||
number goto 9
|
||
|
||
|
||
state 19
|
||
expr : expr "DIV" . expr (10)
|
||
|
||
"SUB" shift 3
|
||
DIGIT shift 4
|
||
LETTER shift 11
|
||
'(' shift 6
|
||
. error
|
||
|
||
expr goto 29
|
||
number goto 9
|
||
|
||
|
||
state 20
|
||
expr : expr "MOD" . expr (11)
|
||
|
||
"SUB" shift 3
|
||
DIGIT shift 4
|
||
LETTER shift 11
|
||
'(' shift 6
|
||
. error
|
||
|
||
expr goto 30
|
||
number goto 9
|
||
|
||
|
||
state 21
|
||
expr : expr "AND" . expr (12)
|
||
|
||
"SUB" shift 3
|
||
DIGIT shift 4
|
||
LETTER shift 11
|
||
'(' shift 6
|
||
. error
|
||
|
||
expr goto 31
|
||
number goto 9
|
||
|
||
|
||
state 22
|
||
expr : expr '|' . expr (13)
|
||
|
||
"SUB" shift 3
|
||
DIGIT shift 4
|
||
LETTER shift 11
|
||
'(' shift 6
|
||
. error
|
||
|
||
expr goto 32
|
||
number goto 9
|
||
|
||
|
||
state 23
|
||
number : number DIGIT . (18)
|
||
|
||
. reduce 18
|
||
|
||
|
||
state 24
|
||
stat : LETTER '=' expr . (5)
|
||
expr : expr . "ADD" expr (7)
|
||
expr : expr . "SUB" expr (8)
|
||
expr : expr . "MUL" expr (9)
|
||
expr : expr . "DIV" expr (10)
|
||
expr : expr . "MOD" expr (11)
|
||
expr : expr . "AND" expr (12)
|
||
expr : expr . '|' expr (13)
|
||
|
||
"ADD" shift 16
|
||
"SUB" shift 17
|
||
"MUL" shift 18
|
||
"DIV" shift 19
|
||
"MOD" shift 20
|
||
"AND" shift 21
|
||
'|' shift 22
|
||
'\n' reduce 5
|
||
|
||
|
||
state 25
|
||
expr : '(' expr ')' . (6)
|
||
|
||
. reduce 6
|
||
|
||
|
||
26: shift/reduce conflict (shift 16, reduce 7) on "ADD"
|
||
26: shift/reduce conflict (shift 17, reduce 7) on "SUB"
|
||
26: shift/reduce conflict (shift 18, reduce 7) on "MUL"
|
||
26: shift/reduce conflict (shift 19, reduce 7) on "DIV"
|
||
26: shift/reduce conflict (shift 20, reduce 7) on "MOD"
|
||
26: shift/reduce conflict (shift 21, reduce 7) on "AND"
|
||
26: shift/reduce conflict (shift 22, reduce 7) on '|'
|
||
state 26
|
||
expr : expr . "ADD" expr (7)
|
||
expr : expr "ADD" expr . (7)
|
||
expr : expr . "SUB" expr (8)
|
||
expr : expr . "MUL" expr (9)
|
||
expr : expr . "DIV" expr (10)
|
||
expr : expr . "MOD" expr (11)
|
||
expr : expr . "AND" expr (12)
|
||
expr : expr . '|' expr (13)
|
||
|
||
"ADD" shift 16
|
||
"SUB" shift 17
|
||
"MUL" shift 18
|
||
"DIV" shift 19
|
||
"MOD" shift 20
|
||
"AND" shift 21
|
||
'|' shift 22
|
||
'\n' reduce 7
|
||
')' reduce 7
|
||
|
||
|
||
27: shift/reduce conflict (shift 16, reduce 8) on "ADD"
|
||
27: shift/reduce conflict (shift 17, reduce 8) on "SUB"
|
||
27: shift/reduce conflict (shift 18, reduce 8) on "MUL"
|
||
27: shift/reduce conflict (shift 19, reduce 8) on "DIV"
|
||
27: shift/reduce conflict (shift 20, reduce 8) on "MOD"
|
||
27: shift/reduce conflict (shift 21, reduce 8) on "AND"
|
||
27: shift/reduce conflict (shift 22, reduce 8) on '|'
|
||
state 27
|
||
expr : expr . "ADD" expr (7)
|
||
expr : expr . "SUB" expr (8)
|
||
expr : expr "SUB" expr . (8)
|
||
expr : expr . "MUL" expr (9)
|
||
expr : expr . "DIV" expr (10)
|
||
expr : expr . "MOD" expr (11)
|
||
expr : expr . "AND" expr (12)
|
||
expr : expr . '|' expr (13)
|
||
|
||
"ADD" shift 16
|
||
"SUB" shift 17
|
||
"MUL" shift 18
|
||
"DIV" shift 19
|
||
"MOD" shift 20
|
||
"AND" shift 21
|
||
'|' shift 22
|
||
'\n' reduce 8
|
||
')' reduce 8
|
||
|
||
|
||
28: shift/reduce conflict (shift 16, reduce 9) on "ADD"
|
||
28: shift/reduce conflict (shift 17, reduce 9) on "SUB"
|
||
28: shift/reduce conflict (shift 18, reduce 9) on "MUL"
|
||
28: shift/reduce conflict (shift 19, reduce 9) on "DIV"
|
||
28: shift/reduce conflict (shift 20, reduce 9) on "MOD"
|
||
28: shift/reduce conflict (shift 21, reduce 9) on "AND"
|
||
28: shift/reduce conflict (shift 22, reduce 9) on '|'
|
||
state 28
|
||
expr : expr . "ADD" expr (7)
|
||
expr : expr . "SUB" expr (8)
|
||
expr : expr . "MUL" expr (9)
|
||
expr : expr "MUL" expr . (9)
|
||
expr : expr . "DIV" expr (10)
|
||
expr : expr . "MOD" expr (11)
|
||
expr : expr . "AND" expr (12)
|
||
expr : expr . '|' expr (13)
|
||
|
||
"ADD" shift 16
|
||
"SUB" shift 17
|
||
"MUL" shift 18
|
||
"DIV" shift 19
|
||
"MOD" shift 20
|
||
"AND" shift 21
|
||
'|' shift 22
|
||
'\n' reduce 9
|
||
')' reduce 9
|
||
|
||
|
||
29: shift/reduce conflict (shift 16, reduce 10) on "ADD"
|
||
29: shift/reduce conflict (shift 17, reduce 10) on "SUB"
|
||
29: shift/reduce conflict (shift 18, reduce 10) on "MUL"
|
||
29: shift/reduce conflict (shift 19, reduce 10) on "DIV"
|
||
29: shift/reduce conflict (shift 20, reduce 10) on "MOD"
|
||
29: shift/reduce conflict (shift 21, reduce 10) on "AND"
|
||
29: shift/reduce conflict (shift 22, reduce 10) on '|'
|
||
state 29
|
||
expr : expr . "ADD" expr (7)
|
||
expr : expr . "SUB" expr (8)
|
||
expr : expr . "MUL" expr (9)
|
||
expr : expr . "DIV" expr (10)
|
||
expr : expr "DIV" expr . (10)
|
||
expr : expr . "MOD" expr (11)
|
||
expr : expr . "AND" expr (12)
|
||
expr : expr . '|' expr (13)
|
||
|
||
"ADD" shift 16
|
||
"SUB" shift 17
|
||
"MUL" shift 18
|
||
"DIV" shift 19
|
||
"MOD" shift 20
|
||
"AND" shift 21
|
||
'|' shift 22
|
||
'\n' reduce 10
|
||
')' reduce 10
|
||
|
||
|
||
30: shift/reduce conflict (shift 16, reduce 11) on "ADD"
|
||
30: shift/reduce conflict (shift 17, reduce 11) on "SUB"
|
||
30: shift/reduce conflict (shift 18, reduce 11) on "MUL"
|
||
30: shift/reduce conflict (shift 19, reduce 11) on "DIV"
|
||
30: shift/reduce conflict (shift 20, reduce 11) on "MOD"
|
||
30: shift/reduce conflict (shift 21, reduce 11) on "AND"
|
||
30: shift/reduce conflict (shift 22, reduce 11) on '|'
|
||
state 30
|
||
expr : expr . "ADD" expr (7)
|
||
expr : expr . "SUB" expr (8)
|
||
expr : expr . "MUL" expr (9)
|
||
expr : expr . "DIV" expr (10)
|
||
expr : expr . "MOD" expr (11)
|
||
expr : expr "MOD" expr . (11)
|
||
expr : expr . "AND" expr (12)
|
||
expr : expr . '|' expr (13)
|
||
|
||
"ADD" shift 16
|
||
"SUB" shift 17
|
||
"MUL" shift 18
|
||
"DIV" shift 19
|
||
"MOD" shift 20
|
||
"AND" shift 21
|
||
'|' shift 22
|
||
'\n' reduce 11
|
||
')' reduce 11
|
||
|
||
|
||
31: shift/reduce conflict (shift 16, reduce 12) on "ADD"
|
||
31: shift/reduce conflict (shift 17, reduce 12) on "SUB"
|
||
31: shift/reduce conflict (shift 18, reduce 12) on "MUL"
|
||
31: shift/reduce conflict (shift 19, reduce 12) on "DIV"
|
||
31: shift/reduce conflict (shift 20, reduce 12) on "MOD"
|
||
31: shift/reduce conflict (shift 21, reduce 12) on "AND"
|
||
31: shift/reduce conflict (shift 22, reduce 12) on '|'
|
||
state 31
|
||
expr : expr . "ADD" expr (7)
|
||
expr : expr . "SUB" expr (8)
|
||
expr : expr . "MUL" expr (9)
|
||
expr : expr . "DIV" expr (10)
|
||
expr : expr . "MOD" expr (11)
|
||
expr : expr . "AND" expr (12)
|
||
expr : expr "AND" expr . (12)
|
||
expr : expr . '|' expr (13)
|
||
|
||
"ADD" shift 16
|
||
"SUB" shift 17
|
||
"MUL" shift 18
|
||
"DIV" shift 19
|
||
"MOD" shift 20
|
||
"AND" shift 21
|
||
'|' shift 22
|
||
'\n' reduce 12
|
||
')' reduce 12
|
||
|
||
|
||
32: shift/reduce conflict (shift 16, reduce 13) on "ADD"
|
||
32: shift/reduce conflict (shift 17, reduce 13) on "SUB"
|
||
32: shift/reduce conflict (shift 18, reduce 13) on "MUL"
|
||
32: shift/reduce conflict (shift 19, reduce 13) on "DIV"
|
||
32: shift/reduce conflict (shift 20, reduce 13) on "MOD"
|
||
32: shift/reduce conflict (shift 21, reduce 13) on "AND"
|
||
state 32
|
||
expr : expr . "ADD" expr (7)
|
||
expr : expr . "SUB" expr (8)
|
||
expr : expr . "MUL" expr (9)
|
||
expr : expr . "DIV" expr (10)
|
||
expr : expr . "MOD" expr (11)
|
||
expr : expr . "AND" expr (12)
|
||
expr : expr . '|' expr (13)
|
||
expr : expr '|' expr . (13)
|
||
|
||
"ADD" shift 16
|
||
"SUB" shift 17
|
||
"MUL" shift 18
|
||
"DIV" shift 19
|
||
"MOD" shift 20
|
||
"AND" shift 21
|
||
'|' reduce 13
|
||
'\n' reduce 13
|
||
')' reduce 13
|
||
|
||
|
||
State 12 contains 6 shift/reduce conflicts.
|
||
State 26 contains 7 shift/reduce conflicts.
|
||
State 27 contains 7 shift/reduce conflicts.
|
||
State 28 contains 7 shift/reduce conflicts.
|
||
State 29 contains 7 shift/reduce conflicts.
|
||
State 30 contains 7 shift/reduce conflicts.
|
||
State 31 contains 7 shift/reduce conflicts.
|
||
State 32 contains 6 shift/reduce conflicts.
|
||
|
||
|
||
28 terminals, 5 nonterminals
|
||
19 grammar rules, 33 states
|