示例#1
0
void parse_FuncDecl() {
  /* <FuncDecl> -> T_FUNC T_ID T_LPAR <FuncDeclIdList> T_RPAR <Block> T_SEMIC */
  printf("Enter FuncDecl\n");
  /* T_FUNC では何もしない。次のトークンを読む */
  nextToken = getToken();
  if (nextToken != T_ID) pl0_error(yytext, line_no, "関数名でない");
  nextToken = getToken();
  if (nextToken != T_LPAR) pl0_error(yytext, line_no, "(でない");
  nextToken = getToken();
  parse_FuncDeclIdList();
  if (nextToken != T_RPAR) pl0_error(yytext, line_no, ")でない");
  nextToken = getToken();
  parse_Block();
  if (nextToken != T_SEMIC) pl0_error(yytext, line_no, ";でない");
  nextToken = getToken();
  printf("Exit  FuncDecl\n");
}
示例#2
0
void parse_FuncDecl() {
  printf("Enter FuncDecl\n");
  /* T_FUNC では何もしない。次のトークンを読む */
  nextToken = getToken();
  if (nextToken != T_ID) pl0parse_error("not ID");

  /* 関数名の関数名テーブルへの追加 */
  if (addTable(yytext) == -1) {
    pl0parse_error("already defined ID");
  } else {
    printf("Add FuncNameTable\n");
  }
  
  nextToken = getToken();
  if (nextToken != T_LPAR) pl0parse_error("not (");
  nextToken = getToken();
  parse_FuncDeclIdList();
  if (nextToken != T_RPAR) pl0parse_error("not )");
  nextToken = getToken();
  parse_Block();
  if (nextToken != T_SEMIC) pl0parse_error("not semic");
  nextToken = getToken();
}