赞
踩
PROCEDURE A;
BEGIN
IF SYM ∈ FIRST(TE’) THEN
BEGIN T;E′ END
ELSE IF SYM ∈ FIRST(BC) THEN
BEGIN B; C END
ELSE IF SYM ∉ FOLLOW(A) THEN
ERROR
END;
PROCEDURE F;
IF SYM=‘i’ THEN
ADVANCE
ELSE
IF SYM=‘(’ THEN
BEGIN
ADVANCE;
E;
IF SYM=‘)’ THEN
ADVANCE
ELSE ERROR
END
ELSE ERROR;
PROCEDURE E;
BEGIN
T;E′
END;
PROCEDURE E′;
IF SYM=‘+’ THEN
BEGIN
ADVANCE;
T;E′
END
PROCEDURE T;
BEGIN
F;T′
END
PROCEDURE T′;
IF SYM=‘*’ THEN
BEGIN
ADVANCE;
F;T′
END;
主程序:
PROGRAM PARSER;
BEGIN
ADVANCE;
E;
IF SYM <>’#’ THEN
ERROR
END;
PROCEDURE E;
BEGIN
T;
WHILE SYM=‘+’ DO
BEGIN
ADVANCE;
T
END
END;
PROCEDURE T;
BEGIN
F;
WHILE SYM=‘*’ DO
BEGIN
ADVANCE;
F
END
END;
PROCEDURE F;
IF SYM=‘i’ THEN
ADVANCE
ELSE
IF SYM=‘(’ THEN
BEGIN
ADVANCE;
E;
IF SYM=‘)’ THEN
ADVANCE
ELSE ERROR
END
ELSE ERROR;
<parser_name>.java
<parser_name>Constants.java
<parser_name>TokenManager.java
ParseException.java
SimpleCharStream.java
Token.java
TokenMgrError.java
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。