⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 y_output

📁 一个编译器的实现
💻
📖 第 1 页 / 共 2 页
字号:
    0  $accept : program $end

    1  program : MAIN LP RP LB stmt_seq RB

    2  stmt_seq : stmt_seq stmt
    3           |

    4  stmt : if_stmt
    5       | while_stmt
    6       | exp_stmt
    7       | decl_stmt
    8       | BREAK SEMI
    9       | error

   10  if_stmt : IF LP exp RP LB stmt_seq RB
   11          | IF LP exp RP LB stmt_seq RB ELSE LB stmt_seq RB

   12  while_stmt : WHILE LP exp RP LB stmt_seq RB

   13  exp_stmt : gen_exp SEMI
   14           | SEMI

   15  decl_stmt : type var_list SEMI

   16  var_list : var_list COMMA var
   17           | var

   18  type : RINT
   19       | RFLOAT
   20       | RCHAR

   21  gen_exp : var ASSIGN gen_exp
   22          | exp

   23  exp : exp AND comp_exp
   24      | exp OR comp_exp
   25      | comp_exp

   26  comp_exp : comp_exp LT simple_exp
   27           | comp_exp MT simple_exp
   28           | comp_exp LE simple_exp
   29           | comp_exp ME simple_exp
   30           | comp_exp EQ simple_exp
   31           | comp_exp NE simple_exp
   32           | simple_exp

   33  simple_exp : simple_exp PLUS term
   34             | simple_exp MINUS term
   35             | term

   36  term : term TIMES factor
   37       | term OVER factor
   38       | factor

   39  factor : LP gen_exp RP
   40         | INT
   41         | FLOAT
   42         | CHAR
   43         | var
   44         | NOT factor
   45         | error

   46  var :
   47      | ID

   48  $$1 :

   49  var : ID $$1 LS gen_exp RS


state 0
	$accept : . program $end

	MAIN  shift 1

	program goto 2


state 1
	program : MAIN . LP RP LB stmt_seq RB

	LP  shift 3


state 2
	$accept : program . $end  (0)

	$end  accept


state 3
	program : MAIN LP . RP LB stmt_seq RB

	RP  shift 4


state 4
	program : MAIN LP RP . LB stmt_seq RB

	LB  shift 5


state 5
	program : MAIN LP RP LB . stmt_seq RB
	stmt_seq : .  (3)

	.  reduce 3

	stmt_seq goto 6


6: shift-reduce conflict (shift 21, reduce 46) on SEMI
state 6
	program : MAIN LP RP LB stmt_seq . RB
	stmt_seq : stmt_seq . stmt
	var : .  (46)

	error  shift 7
	IF  shift 8
	WHILE  shift 9
	BREAK  shift 10
	RINT  shift 11
	RFLOAT  shift 12
	RCHAR  shift 13
	ID  shift 14
	FLOAT  shift 15
	INT  shift 16
	CHAR  shift 17
	NOT  shift 18
	LP  shift 19
	RB  shift 20
	SEMI  shift 21
	.  reduce 46

	stmt goto 22
	if_stmt goto 23
	while_stmt goto 24
	exp_stmt goto 25
	decl_stmt goto 26
	exp goto 27
	gen_exp goto 28
	type goto 29
	var goto 30
	comp_exp goto 31
	simple_exp goto 32
	term goto 33
	factor goto 34


7: reduce-reduce conflict (reduce 9, reduce 45) on EQ
7: reduce-reduce conflict (reduce 9, reduce 45) on NE
7: reduce-reduce conflict (reduce 9, reduce 45) on LT
7: reduce-reduce conflict (reduce 9, reduce 45) on MT
7: reduce-reduce conflict (reduce 9, reduce 45) on LE
7: reduce-reduce conflict (reduce 9, reduce 45) on ME
7: reduce-reduce conflict (reduce 9, reduce 45) on PLUS
7: reduce-reduce conflict (reduce 9, reduce 45) on MINUS
7: reduce-reduce conflict (reduce 9, reduce 45) on TIMES
7: reduce-reduce conflict (reduce 9, reduce 45) on OVER
7: reduce-reduce conflict (reduce 9, reduce 45) on AND
7: reduce-reduce conflict (reduce 9, reduce 45) on OR
7: reduce-reduce conflict (reduce 9, reduce 45) on SEMI
state 7
	stmt : error .  (9)
	factor : error .  (45)

	.  reduce 9


state 8
	if_stmt : IF . LP exp RP LB stmt_seq RB
	if_stmt : IF . LP exp RP LB stmt_seq RB ELSE LB stmt_seq RB

	LP  shift 35


state 9
	while_stmt : WHILE . LP exp RP LB stmt_seq RB

	LP  shift 36


state 10
	stmt : BREAK . SEMI

	SEMI  shift 37


state 11
	type : RINT .  (18)

	.  reduce 18


state 12
	type : RFLOAT .  (19)

	.  reduce 19


state 13
	type : RCHAR .  (20)

	.  reduce 20


state 14
	var : ID .  (47)
	var : ID . $$1 LS gen_exp RS
	$$1 : .  (48)

	LS  reduce 48
	.  reduce 47

	$$1 goto 38


state 15
	factor : FLOAT .  (41)

	.  reduce 41


state 16
	factor : INT .  (40)

	.  reduce 40


state 17
	factor : CHAR .  (42)

	.  reduce 42


state 18
	factor : NOT . factor
	var : .  (46)

	error  shift 39
	ID  shift 14
	FLOAT  shift 15
	INT  shift 16
	CHAR  shift 17
	NOT  shift 18
	LP  shift 19
	.  reduce 46

	var goto 40
	factor goto 41


state 19
	factor : LP . gen_exp RP
	var : .  (46)

	error  shift 39
	ID  shift 14
	FLOAT  shift 15
	INT  shift 16
	CHAR  shift 17
	NOT  shift 18
	LP  shift 19
	.  reduce 46

	exp goto 27
	gen_exp goto 42
	var goto 30
	comp_exp goto 31
	simple_exp goto 32
	term goto 33
	factor goto 34


state 20
	program : MAIN LP RP LB stmt_seq RB .  (1)

	.  reduce 1


state 21
	exp_stmt : SEMI .  (14)

	.  reduce 14


state 22
	stmt_seq : stmt_seq stmt .  (2)

	.  reduce 2


state 23
	stmt : if_stmt .  (4)

	.  reduce 4


state 24
	stmt : while_stmt .  (5)

	.  reduce 5


state 25
	stmt : exp_stmt .  (6)

	.  reduce 6


state 26
	stmt : decl_stmt .  (7)

	.  reduce 7


state 27
	gen_exp : exp .  (22)
	exp : exp . AND comp_exp
	exp : exp . OR comp_exp

	AND  shift 43
	OR  shift 44
	.  reduce 22


state 28
	exp_stmt : gen_exp . SEMI

	SEMI  shift 45


state 29
	decl_stmt : type . var_list SEMI
	var : .  (46)

	ID  shift 14
	.  reduce 46

	var_list goto 46
	var goto 47


state 30
	gen_exp : var . ASSIGN gen_exp
	factor : var .  (43)

	ASSIGN  shift 48
	.  reduce 43


state 31
	exp : comp_exp .  (25)
	comp_exp : comp_exp . LT simple_exp
	comp_exp : comp_exp . MT simple_exp
	comp_exp : comp_exp . LE simple_exp
	comp_exp : comp_exp . ME simple_exp
	comp_exp : comp_exp . EQ simple_exp
	comp_exp : comp_exp . NE simple_exp

	EQ  shift 49
	NE  shift 50
	LT  shift 51
	MT  shift 52
	LE  shift 53
	ME  shift 54
	.  reduce 25


state 32
	comp_exp : simple_exp .  (32)
	simple_exp : simple_exp . PLUS term
	simple_exp : simple_exp . MINUS term

	PLUS  shift 55
	MINUS  shift 56
	.  reduce 32


state 33
	simple_exp : term .  (35)
	term : term . TIMES factor
	term : term . OVER factor

	TIMES  shift 57
	OVER  shift 58
	.  reduce 35


state 34
	term : factor .  (38)

	.  reduce 38


state 35
	if_stmt : IF LP . exp RP LB stmt_seq RB
	if_stmt : IF LP . exp RP LB stmt_seq RB ELSE LB stmt_seq RB
	var : .  (46)

	error  shift 39
	ID  shift 14
	FLOAT  shift 15
	INT  shift 16
	CHAR  shift 17
	NOT  shift 18
	LP  shift 19
	.  reduce 46

	exp goto 59
	var goto 40
	comp_exp goto 31
	simple_exp goto 32
	term goto 33
	factor goto 34


state 36
	while_stmt : WHILE LP . exp RP LB stmt_seq RB
	var : .  (46)

	error  shift 39
	ID  shift 14
	FLOAT  shift 15
	INT  shift 16
	CHAR  shift 17
	NOT  shift 18
	LP  shift 19
	.  reduce 46

	exp goto 60
	var goto 40
	comp_exp goto 31
	simple_exp goto 32
	term goto 33
	factor goto 34


state 37
	stmt : BREAK SEMI .  (8)

	.  reduce 8


state 38
	var : ID $$1 . LS gen_exp RS

	LS  shift 61


state 39
	factor : error .  (45)

	.  reduce 45


state 40
	factor : var .  (43)

	.  reduce 43


state 41
	factor : NOT factor .  (44)

	.  reduce 44


state 42
	factor : LP gen_exp . RP

	RP  shift 62


state 43
	exp : exp AND . comp_exp
	var : .  (46)

	error  shift 39
	ID  shift 14
	FLOAT  shift 15
	INT  shift 16
	CHAR  shift 17
	NOT  shift 18
	LP  shift 19
	.  reduce 46

	var goto 40
	comp_exp goto 63
	simple_exp goto 32
	term goto 33
	factor goto 34


state 44
	exp : exp OR . comp_exp
	var : .  (46)

	error  shift 39
	ID  shift 14
	FLOAT  shift 15
	INT  shift 16
	CHAR  shift 17
	NOT  shift 18
	LP  shift 19
	.  reduce 46

	var goto 40
	comp_exp goto 64
	simple_exp goto 32
	term goto 33
	factor goto 34


state 45
	exp_stmt : gen_exp SEMI .  (13)

	.  reduce 13


state 46
	decl_stmt : type var_list . SEMI
	var_list : var_list . COMMA var

	SEMI  shift 65
	COMMA  shift 66


state 47
	var_list : var .  (17)

	.  reduce 17


state 48
	gen_exp : var ASSIGN . gen_exp
	var : .  (46)

	error  shift 39
	ID  shift 14
	FLOAT  shift 15
	INT  shift 16
	CHAR  shift 17
	NOT  shift 18
	LP  shift 19
	.  reduce 46

	exp goto 27
	gen_exp goto 67
	var goto 30
	comp_exp goto 31
	simple_exp goto 32
	term goto 33
	factor goto 34


state 49
	comp_exp : comp_exp EQ . simple_exp
	var : .  (46)

	error  shift 39
	ID  shift 14
	FLOAT  shift 15
	INT  shift 16
	CHAR  shift 17
	NOT  shift 18
	LP  shift 19
	.  reduce 46

	var goto 40
	simple_exp goto 68
	term goto 33
	factor goto 34


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -