文件名称:operator-precedence-parser
-
所属分类:
- 标签属性:
- 上传时间:2015-10-29
-
文件大小:1.76kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
1、给出文法如下:
G[E]
E->T|E+T
T->F|T*F
F->i(E)
可以构造算符优先表如下:
+ * ( ) i
+
*
(
)
i
2、计算机中表示上述优先关系,优先关系的机内存放方式有两种1)直接存放,2)为优先关系建立优先函数,这里由学生自己选择一种方式;
3、给出算符优先分析算法如下:
k:=1 S[k]:=‘#’
REPEAT
把下一个输入符号读进a中;
IF S[k]∈VT THEN j:=k ELSE j:=k-1
WHILE S[j] a DO
BEGIN
REPEAT
Q:=S[j]
IF S[j-1]∈VT THEN j:=j-1 ELSE j:=j-2
UNTIL S[j] Q
把S[j+1]…S[k]归约为某个N;
k:=j+1
S[k]:=N
END OF WHILE
IF S[j] a OR S[j] a THEN
BEGIN
k:=k+1 S[k]:=a
END
ELSE ERROR
UNTIL a=‘#’
4、根据给出算法,利用适当的数据结构实现算符优先分析程序;-1 gives grammar as follows: E [E] E-> T | E+ T T-> F | T* F F-> i (E)
Operator priority table can be constructed as follows:+* () i
+
*
(
)
i
2, the computer indicated above priority, preferential relations machine memory put in two ways 1) Direct storage, 2) as a priority relationship building priority function, here by the students themselves choose a way
3, gives the operator precedence analysis algorithm is as follows:
k: = 1 S [k]: = #
REPEAT read the next input symbol into a medium IF S [k] ∈VT THEN j: = k ELSE j: = k-1 WHILE S [j] a DO BEGIN REPEAT Q: = S [j] IF S [j-1] ∈VT THEN j: = j-1 ELSE j: = j-2 UNTIL S [j] Q to S [j+ 1] ... S [k] is about a normalization N k: = j+1 S [k]: = N END OF WHILE
IF S [j] a OR S [j] a THEN BEGIN k: = k+ 1 S [k]: = a END ELSE ERROR UNTIL a = #
4, according to the given algorithm, using the appropriate data structure to achieve operator priority analysis program
G[E]
E->T|E+T
T->F|T*F
F->i(E)
可以构造算符优先表如下:
+ * ( ) i
+
*
(
)
i
2、计算机中表示上述优先关系,优先关系的机内存放方式有两种1)直接存放,2)为优先关系建立优先函数,这里由学生自己选择一种方式;
3、给出算符优先分析算法如下:
k:=1 S[k]:=‘#’
REPEAT
把下一个输入符号读进a中;
IF S[k]∈VT THEN j:=k ELSE j:=k-1
WHILE S[j] a DO
BEGIN
REPEAT
Q:=S[j]
IF S[j-1]∈VT THEN j:=j-1 ELSE j:=j-2
UNTIL S[j] Q
把S[j+1]…S[k]归约为某个N;
k:=j+1
S[k]:=N
END OF WHILE
IF S[j] a OR S[j] a THEN
BEGIN
k:=k+1 S[k]:=a
END
ELSE ERROR
UNTIL a=‘#’
4、根据给出算法,利用适当的数据结构实现算符优先分析程序;-1 gives grammar as follows: E [E] E-> T | E+ T T-> F | T* F F-> i (E)
Operator priority table can be constructed as follows:+* () i
+
*
(
)
i
2, the computer indicated above priority, preferential relations machine memory put in two ways 1) Direct storage, 2) as a priority relationship building priority function, here by the students themselves choose a way
3, gives the operator precedence analysis algorithm is as follows:
k: = 1 S [k]: = #
REPEAT read the next input symbol into a medium IF S [k] ∈VT THEN j: = k ELSE j: = k-1 WHILE S [j] a DO BEGIN REPEAT Q: = S [j] IF S [j-1] ∈VT THEN j: = j-1 ELSE j: = j-2 UNTIL S [j] Q to S [j+ 1] ... S [k] is about a normalization N k: = j+1 S [k]: = N END OF WHILE
IF S [j] a OR S [j] a THEN BEGIN k: = k+ 1 S [k]: = a END ELSE ERROR UNTIL a = #
4, according to the given algorithm, using the appropriate data structure to achieve operator priority analysis program
(系统自动生成,下载前可以参看下载内容)
下载文件列表
operator precedence parser.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.