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

📄 parse.v

📁 用LEX和YACC实现词法分析和语法分析。剩余部分为C语言编写。
💻 V
📖 第 1 页 / 共 3 页
字号:
#############################################################################
#                     U N R E G I S T E R E D   C O P Y
# 
# You are on day 85 of your 30 day trial period.
# 
# This file was produced by an UNREGISTERED COPY of Parser Generator. It is
# for evaluation purposes only. If you continue to use Parser Generator 30
# days after installation then you are required to purchase a license. For
# more information see the online help or go to the Bumble-Bee Software
# homepage at:
# 
# http://www.bumblebeesoftware.com
# 
# This notice must remain present in the file. It cannot be removed.
#############################################################################

#############################################################################
# parse.v
# YACC verbose file generated from parse.y.
# 
# Date: 06/24/03
# Time: 17:07:53
# 
# AYACC Version: 2.05
#############################################################################


##############################################################################
# Rules
##############################################################################

    0  $accept : program $end

    1  program : dec_list

    2  dec_list : dec_list dec
    3           | dec

    4  dec : var_dec
    5      | fun_dec
    6      | fun_def

    7  id : ID

    8  fid :

    9  var_dec : type_spec id_list SEMI

   10  id_list : id_list COMMA var
   11          | var
   12          | id_list COMMA id ASSIGN simple_exp
   13          | id ASSIGN simple_exp

   14  type_spec : INT
   15            | FLOAT
   16            | CHAR
   17            | VOID

   18  fun_def : type_spec id fid LP params RP comp_stmt
   19          | id fid LP params RP comp_stmt

   20  fun_dec : type_spec id fid LP params RP SEMI
   21          | id fid LP params RP SEMI

   22  params : param_list
   23         |

   24  param_list : param_list COMMA param
   25             | param

   26  param : type_spec
   27        | type_spec id
   28        | type_spec id LSP RSP
   29        | type_spec id LSP simple_exp RSP

   30  comp_stmt : LFP local_dec stmt_list RFP

   31  local_dec : local_dec var_dec
   32            |

   33  stmt_list : stmt_list stmt
   34            |

   35  stmt : exp_stmt
   36       | sele_stmt
   37       | iter_stmt
   38       | return_stmt
   39       | comp_stmt
   40       | CONTINUE SEMI
   41       | BREAK SEMI

   42  exp_stmt : exp SEMI
   43           | SEMI

   44  sele_stmt : IF LP exp RP stmt
   45            | IF LP exp RP stmt ELSE stmt

   46  iter_stmt : WHILE LP exp RP stmt

   47  return_stmt : RETURN SEMI
   48              | RETURN exp SEMI

   49  exp : var ASSIGN exp
   50      | simple_exp

   51  var : id
   52      | id LSP simple_exp RSP

   53  simple_exp : simple_exp OR simple_exp
   54             | simple_exp AND simple_exp
   55             | simple_exp LT simple_exp
   56             | simple_exp LE simple_exp
   57             | simple_exp GT simple_exp
   58             | simple_exp GE simple_exp
   59             | simple_exp EQ simple_exp
   60             | simple_exp NEQ simple_exp
   61             | simple_exp PLUS simple_exp
   62             | simple_exp SUB simple_exp
   63             | simple_exp MUT simple_exp
   64             | simple_exp DIV simple_exp
   65             | factor

   66  factor : LP exp RP
   67         | var
   68         | call
   69         | NUM
   70         | FNUM
   71         | SCHAR
   72         | NOT factor

   73  call : var LP args RP

   74  arg_list : arg_list COMMA exp
   75           | exp

   76  args : arg_list
   77       |


##############################################################################
# States
##############################################################################

state 0
	$accept : . program $end

	INT  shift 1
	CHAR  shift 2
	FLOAT  shift 3
	VOID  shift 4
	ID  shift 5

	program  goto 6
	dec_list  goto 7
	dec  goto 8
	var_dec  goto 9
	fun_dec  goto 10
	fun_def  goto 11
	type_spec  goto 12
	id  goto 13


state 1
	type_spec : INT .  (14)

	.  reduce 14


state 2
	type_spec : CHAR .  (16)

	.  reduce 16


state 3
	type_spec : FLOAT .  (15)

	.  reduce 15


state 4
	type_spec : VOID .  (17)

	.  reduce 17


state 5
	id : ID .  (7)

	.  reduce 7


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

	$end  accept


state 7
	program : dec_list .  (1)
	dec_list : dec_list . dec

	INT  shift 1
	CHAR  shift 2
	FLOAT  shift 3
	VOID  shift 4
	ID  shift 5
	.  reduce 1

	dec  goto 14
	var_dec  goto 9
	fun_dec  goto 10
	fun_def  goto 11
	type_spec  goto 12
	id  goto 13


state 8
	dec_list : dec .  (3)

	.  reduce 3


state 9
	dec : var_dec .  (4)

	.  reduce 4


state 10
	dec : fun_dec .  (5)

	.  reduce 5


state 11
	dec : fun_def .  (6)

	.  reduce 6


state 12
	var_dec : type_spec . id_list SEMI
	fun_def : type_spec . id fid LP params RP comp_stmt
	fun_dec : type_spec . id fid LP params RP SEMI

	ID  shift 5

	var  goto 15
	id_list  goto 16
	id  goto 17


state 13
	fun_def : id . fid LP params RP comp_stmt
	fun_dec : id . fid LP params RP SEMI
	fid : .  (8)

	.  reduce 8

	fid  goto 18


state 14
	dec_list : dec_list dec .  (2)

	.  reduce 2


state 15
	id_list : var .  (11)

	.  reduce 11


state 16
	var_dec : type_spec id_list . SEMI
	id_list : id_list . COMMA var
	id_list : id_list . COMMA id ASSIGN simple_exp

	SEMI  shift 19
	COMMA  shift 20


state 17
	id_list : id . ASSIGN simple_exp
	fun_def : type_spec id . fid LP params RP comp_stmt
	fun_dec : type_spec id . fid LP params RP SEMI
	var : id .  (51)
	var : id . LSP simple_exp RSP
	fid : .  (8)

	ASSIGN  shift 21
	LSP  shift 22
	LP  reduce 8
	.  reduce 51

	fid  goto 23


state 18
	fun_def : id fid . LP params RP comp_stmt
	fun_dec : id fid . LP params RP SEMI

	LP  shift 24


state 19
	var_dec : type_spec id_list SEMI .  (9)

	.  reduce 9


state 20
	id_list : id_list COMMA . var
	id_list : id_list COMMA . id ASSIGN simple_exp

	ID  shift 5

	var  goto 25
	id  goto 26


state 21
	id_list : id ASSIGN . simple_exp

	ID  shift 5
	NUM  shift 27
	FNUM  shift 28
	SCHAR  shift 29
	NOT  shift 30
	LP  shift 31

	var  goto 32
	simple_exp  goto 33
	factor  goto 34
	call  goto 35
	id  goto 36


state 22
	var : id LSP . simple_exp RSP

	ID  shift 5
	NUM  shift 27
	FNUM  shift 28
	SCHAR  shift 29
	NOT  shift 30
	LP  shift 31

	var  goto 32
	simple_exp  goto 37
	factor  goto 34
	call  goto 35
	id  goto 36


state 23
	fun_def : type_spec id fid . LP params RP comp_stmt
	fun_dec : type_spec id fid . LP params RP SEMI

	LP  shift 38


state 24
	fun_def : id fid LP . params RP comp_stmt
	fun_dec : id fid LP . params RP SEMI
	params : .  (23)

	INT  shift 1
	CHAR  shift 2
	FLOAT  shift 3
	VOID  shift 4
	.  reduce 23

	params  goto 39
	param_list  goto 40
	param  goto 41
	type_spec  goto 42


state 25
	id_list : id_list COMMA var .  (10)

	.  reduce 10


state 26
	id_list : id_list COMMA id . ASSIGN simple_exp
	var : id .  (51)
	var : id . LSP simple_exp RSP

	ASSIGN  shift 43
	LSP  shift 22
	.  reduce 51


state 27
	factor : NUM .  (69)

	.  reduce 69


state 28
	factor : FNUM .  (70)

	.  reduce 70


state 29
	factor : SCHAR .  (71)

	.  reduce 71


state 30
	factor : NOT . factor

	ID  shift 5
	NUM  shift 27
	FNUM  shift 28
	SCHAR  shift 29
	NOT  shift 30
	LP  shift 31

	var  goto 32
	factor  goto 44
	call  goto 35
	id  goto 36


state 31
	factor : LP . exp RP

	ID  shift 5
	NUM  shift 27
	FNUM  shift 28
	SCHAR  shift 29
	NOT  shift 30
	LP  shift 31

	exp  goto 45
	var  goto 46
	simple_exp  goto 47
	factor  goto 34
	call  goto 35
	id  goto 36


state 32
	factor : var .  (67)
	call : var . LP args RP

	LP  shift 48
	.  reduce 67


state 33
	id_list : id ASSIGN simple_exp .  (13)
	simple_exp : simple_exp . OR simple_exp
	simple_exp : simple_exp . AND simple_exp
	simple_exp : simple_exp . LT simple_exp
	simple_exp : simple_exp . LE simple_exp
	simple_exp : simple_exp . GT simple_exp
	simple_exp : simple_exp . GE simple_exp
	simple_exp : simple_exp . EQ simple_exp
	simple_exp : simple_exp . NEQ simple_exp
	simple_exp : simple_exp . PLUS simple_exp
	simple_exp : simple_exp . SUB simple_exp
	simple_exp : simple_exp . MUT simple_exp
	simple_exp : simple_exp . DIV simple_exp

	PLUS  shift 49
	SUB  shift 50
	MUT  shift 51
	DIV  shift 52
	LT  shift 53
	LE  shift 54
	GT  shift 55
	GE  shift 56
	EQ  shift 57
	NEQ  shift 58
	AND  shift 59
	OR  shift 60
	.  reduce 13


state 34
	simple_exp : factor .  (65)

	.  reduce 65


state 35
	factor : call .  (68)

	.  reduce 68


state 36
	var : id .  (51)
	var : id . LSP simple_exp RSP

	LSP  shift 22
	.  reduce 51


state 37
	var : id LSP simple_exp . RSP
	simple_exp : simple_exp . OR simple_exp
	simple_exp : simple_exp . AND simple_exp
	simple_exp : simple_exp . LT simple_exp
	simple_exp : simple_exp . LE simple_exp
	simple_exp : simple_exp . GT simple_exp
	simple_exp : simple_exp . GE simple_exp
	simple_exp : simple_exp . EQ simple_exp
	simple_exp : simple_exp . NEQ simple_exp
	simple_exp : simple_exp . PLUS simple_exp
	simple_exp : simple_exp . SUB simple_exp
	simple_exp : simple_exp . MUT simple_exp
	simple_exp : simple_exp . DIV simple_exp

	PLUS  shift 49
	SUB  shift 50
	MUT  shift 51
	DIV  shift 52
	LT  shift 53
	LE  shift 54
	GT  shift 55
	GE  shift 56
	EQ  shift 57
	NEQ  shift 58
	AND  shift 59
	OR  shift 60
	RSP  shift 61


state 38
	fun_def : type_spec id fid LP . params RP comp_stmt
	fun_dec : type_spec id fid LP . params RP SEMI
	params : .  (23)

	INT  shift 1
	CHAR  shift 2
	FLOAT  shift 3
	VOID  shift 4
	.  reduce 23

	params  goto 62
	param_list  goto 40
	param  goto 41
	type_spec  goto 42


state 39
	fun_def : id fid LP params . RP comp_stmt
	fun_dec : id fid LP params . RP SEMI

	RP  shift 63


state 40
	params : param_list .  (22)
	param_list : param_list . COMMA param

	COMMA  shift 64
	.  reduce 22


state 41
	param_list : param .  (25)

	.  reduce 25


state 42
	param : type_spec .  (26)
	param : type_spec . id
	param : type_spec . id LSP RSP
	param : type_spec . id LSP simple_exp RSP

	ID  shift 5
	.  reduce 26

	id  goto 65


state 43
	id_list : id_list COMMA id ASSIGN . simple_exp

	ID  shift 5
	NUM  shift 27
	FNUM  shift 28
	SCHAR  shift 29
	NOT  shift 30
	LP  shift 31

	var  goto 32
	simple_exp  goto 66
	factor  goto 34
	call  goto 35
	id  goto 36

⌨️ 快捷键说明

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