void parse_StatementList() { /* <StatementList> -> <Statement> <StatementList_dash> */ printf("Enter StatementList\n"); parse_Statement(); parse_StatementList_dash(); printf("Exit StatementList\n"); }
void parse_StatementList_dash() { printf("Enter StatementList_dash\n"); if (nextToken == T_SEMIC) { nextToken = getToken(); parse_Statement(); parse_StatementList_dash(); } }
void parse_Block() { /* <Block> -> <ConstDeclList> <VarDeclList> <FuncDeclList> <Statement> */ printf("Enter Block\n"); parse_ConstDeclList(); parse_VarDeclList(); parse_FuncDeclList(); parse_Statement(); printf("Exit Block\n"); }
void parse_StatementList_dash() { /* <StatementList_dash> -> T_SEMIC <Statement> <StatementList_dash> | ε */ printf("Enter StatementList_dash\n"); if (nextToken == T_SEMIC) { nextToken = getToken(); parse_Statement(); parse_StatementList_dash(); } printf("Exit StatementList_dash\n"); }
void parse_Statement() { printf("Enter Statement\n"); if (nextToken == T_ID) { /* 代入文 */ nextToken = getToken(); if (nextToken != T_COLEQ) pl0parse_error("not :="); nextToken = getToken(); parse_Expression(); } else if (nextToken == T_BEGIN) { /* begn ~ end */ nextToken = getToken(); parse_StatementList(); if (nextToken != T_END) pl0parse_error("not end"); nextToken = getToken(); } else if (nextToken == T_IF) { /* if then */ nextToken = getToken(); parse_Condition(); if (nextToken != T_THEN) pl0parse_error("not then"); nextToken = getToken(); parse_Statement(); } else if (nextToken == T_WHILE) { /* while do */ nextToken = getToken(); parse_Condition(); if (nextToken != T_DO) pl0parse_error("not do"); nextToken = getToken(); parse_Statement(); } else if (nextToken == T_RETURN) { /* return */ nextToken = getToken(); parse_Expression(); } else if (nextToken == T_WRITE) { /* write */ nextToken = getToken(); parse_Expression(); } else if (nextToken == T_WRITELN) { /* writeln */ /* writeln の処理 */ nextToken = getToken(); } else { } }
void parse_Statement() { printf("Enter Statement\n"); if (nextToken == T_ID) { /* 代入文 */ nextToken = getToken(); if (nextToken != T_COLEQ) pl0_error(yytext, line_no, ":=がない"); nextToken = getToken(); parse_Expression(); } else if (nextToken == T_BEGIN) { /* begn ~ end */ nextToken = getToken(); parse_StatementList(); if (nextToken != T_END) pl0_error(yytext, line_no, "endがない"); nextToken = getToken(); } else if (nextToken == T_IF) { /* if then */ nextToken = getToken(); parse_Condition(); if (nextToken != T_THEN) pl0_error(yytext, line_no, "thenがない"); nextToken = getToken(); parse_Statement(); } else if (nextToken == T_WHILE) { /* while do */ nextToken = getToken(); parse_Condition(); if (nextToken != T_DO) pl0_error(yytext, line_no, "doがない"); nextToken = getToken(); parse_Statement(); } else if (nextToken == T_RETURN) { /* return */ nextToken = getToken(); parse_Expression(); } else if (nextToken == T_WRITE) { /* write */ nextToken = getToken(); parse_Expression(); } else if (nextToken == T_WRITELN) { /* writeln */ /* writeln の処理 */ nextToken = getToken(); } printf("Exit Statement\n"); }
void parse_StatementList() { printf("Enter StatementList\n"); parse_Statement(); parse_StatementList_dash(); }
void parse_Block() { printf("Enter Block\n"); parse_Decl(); parse_Statement(); }