/* <stmt> --> id:=<expr>; <stmt> --> read(<idlist>); <stmt> --> write(<idlist>); <stmt> --> if(<idlist>){<stmtlist>}{else(<idlist>){<stmtlist>}}; <stmt> --> while(<idlist>){<stmtlist>}; */ void statement() { if(next_token == ID) { match(ID); match(ASSIGNOP); expression(); match(SEMICOLON); } else if(next_token == READ) { match(READ); match(LPAREN); id_list(); match(RPAREN); match(SEMICOLON); } else if(next_token == WRITE) { match(WRITE); match(LPAREN); id_list(); match(RPAREN); match(SEMICOLON); } else if(next_token == IF) { match(IF); match(LPAREN); bool(); match(RPAREN); match(LCURL); statement_list(); match(RCURL); if(next_token == ELSE) { match(ELSE); match(LCURL); statement_list(); match(RCURL); } } else if(next_token == WHILE) { match(WHILE); match(LPAREN); bool(); match(RPAREN); match(LCURL); statement_list(); match(RCURL); } else syntax_error(); }
int compound_statement(void) { match(LCURLY); if( statement_list() ) { } else if( declaration_list() ) { if( statement_list() ) { } } else { abort(); } match(RCURLY); }
TreeNode * if_stmt(void)//if_stmt -> IF '(' expression ')' '{'statement_list'}' [ELSE '{'statement_list'}'] { TreeNode * t = newStmtNode(IfK); match(IF);match(LPAREN); if (t!=NULL) t->child[0] = exp(); match(RPAREN);match(LBRACE); if (t!=NULL) t->child[1] = statement_list(); //match(RBRACE); if (token==ELSE) { match(ELSE);match(LBRACE); if (t!=NULL) t->child[2] = statement_list(); //match(RBRACE); } return t; }
//<compound_stat>::={<statement_list>} int compound_stat(){ //复合语句函数 int es = 0; fscanf(fp, "%s %s\n", &token, &token1); printf("%s %s\n", token, token1); es = statement_list(); return(es); }
/* <program> --> main{<stmtlist>}*/ void program() { match(MAIN); match(LCURL); statement_list(); match(RCURL); }
void dprime() { if(strcmp(token.c_str(),"else") == 0) { getToken("dprime"); if(strcmp(token.c_str(),"{") == 0) { getToken("dprime"); statement_list(); if(strcmp(token.c_str(),"}") == 0) { getToken("dprime"); } else { printf("Error at dprime }\n"); exit(1); } } else { printf("Error at dprime {\n"); exit(1); } } else return; }
//program::={<declaration_list><statement_list>} int program() { int es = 0, i; fscanf(fp, "%s %s\n", token, token1); printf("%s %s\n", token, token1); if (strcmp(token, "{"))//判断是否'{' { es = 1; return(es); } fscanf(fp, "%s %s\n", &token, &token1); printf("%s %s\n", token, token1); es = declaration_list(); if (es > 0) return(es); printf(" 符号表\n"); printf(" 名字 地址\n"); for (i = 0; i<vartablep; i++) printf(" %s %d\n", vartable[i].name, vartable[i].address); es = statement_list(); if (es>0) return(es); if (strcmp(token, "}"))//判断是否'}' { es = 2; return(es); } fprintf(fout, " STOP\n");//产生停止指令 return(es); }
void statement_list() { int incoming=statement(); if(incoming == 1) statement_list(); else return; }
TreeNode * parse(void) { TreeNode * t; token = getToken(); t = statement_list(); if (token!=ENDFILE) syntaxError("Code ends before file\n"); return t; }
opt_statements(){ /* opt_statements -> statement_list | epsilon */ statement_list(); }
void program(void){ /*<program> ::= BEGIN <statement list> END*/ match(BEGIN); statement_list(); match(END); finish(); }
int statement_list(void) { if( statement() ) { } else if( statement_list() ) { statement(); } else { abort(); } }
double Parser(Node_t* LinkedList){ Node_t *current = LinkedList; global_current = current; double result = statement_list(); return result; }
TreeNode * while_stmt(void) //while_stmt -> WHILE '(' expression ')' '{'statement_list'}' { TreeNode * t = newStmtNode(WhileK); match(WHILE); match(LPAREN); if(t!=NULL) t->child[0] = exp(); match(RPAREN); match(LBRACE); if(t!=NULL) t->child[1] = statement_list(); //match(RBRACE); return t; }
void Program() { if(strcmp(token.c_str(),"main") == 0) { getToken("Program"); if(strcmp(token.c_str(),"(") == 0) { getToken("Program"); if(strcmp(token.c_str(),")") == 0) { getToken("Program"); if(strcmp(token.c_str(),"{") == 0) { getToken("Program"); declaration(); statement_list(); if(strcmp(token.c_str(),"}") == 0) { printf("Parse complete\n"); exit(0); } else { printf("Error atB\n"); exit(1); } } else { printf("Error at\n"); exit(1); } } else { printf("Error at\n"); exit(1); } } else { printf("Error at\n"); exit(1); } } else { printf("Error at\n"); exit(1); } }
TreeNode * for_stmt(void) //for_stmt -> FOR '('expression';'expression';'expression')''{'statement_list'}' { TreeNode * t = newStmtNode(ForK); match(FOR); match(LPAREN); if(t!=NULL) t->child[0] = assign_list(); match(SEMI); if(t!=NULL) t->child[1] = exp(); match(SEMI); if(t!=NULL) t->child[2] = assign_list(); match(RPAREN); match(LBRACE); if(t!=NULL) t->child[3]=statement_list(); //match(RBRACE); return t; }
int decision_stat() { if(strcmp(token.c_str(),"if") == 0) { getToken("decision_stat"); if(strcmp(token.c_str(),"(") == 0) { getToken("decision_stat"); expr(); if(strcmp(token.c_str(),")") == 0) { getToken("decision_stat"); if(strcmp(token.c_str(),"{") == 0) { getToken("decision_stat"); statement_list(); if(strcmp(token.c_str(),"}") == 0) { getToken("decision_stat"); dprime(); return 1; } else { printf("Error at }\n"); exit(1); } } else { printf("Error at {\n"); exit(1); } } else { printf("Error at )\n"); exit(1); } } else { printf("Error at (\n"); exit(1); } } else return 0; }
/* EBNF: compound-stmt -> "{"local-declarations statement-list"}" */ static TreeNode * compound_stmt (void) { TreeNode * t = NULL; while (token == COMMENT) unexpectedTokenHandling(); if (token == CLPAREN) /* "{" */ { t = newStmtNode (ComK); match (CLPAREN); if (t != NULL) { t->child[0] = local_declarations(); t->child[1] = statement_list(); } match (CRPAREN); } else unexpectedTokenHandling(); return t; }
static program_node *program(void){ program_node *pn = newProgramNode(); if(match(TOKEN_IFKEY, NO_CONSUME) || match(TOKEN_WHILEKEY, NO_CONSUME) || match(TOKEN_FORKEY, NO_CONSUME) || match(TOKEN_TYPEKEY, NO_CONSUME) || match(TOKEN_SCOL, NO_CONSUME) || match(TOKEN_IDENTIFIER, NO_CONSUME)){ if((pn->sln = statement_list()) != error){ if((pn->eof = match(TOKEN_EOF, CONSUME)) != NULL) return pn; } } fprintf(stderr, "error on line %d: Unexpected token %s\n", global_tlist->value->line_number, global_tlist->value->value); freeProgram(pn); return NULL; }
int program() { int valid; if(c->token_number == BEGIN) { //fprintf(of_d.temp1, "Token number %d\tToken type %s\t\tActual %s\n", c->token_number, c->token_type, c->buffer); //fprintf(of_d.temp1,"\nPROGRAM LINE: BEGIN\n\n\n"); //fprintf(of_d.listing_file, "1:\t%s\n", c->buffer); advance(); valid=statement_list(); if (valid > 0) { if(c->token_number == END) { //valid program grammar //fprintf(of_d.temp1, "Token number %d\tToken type %s\t\tActual %s\n", c->token_number, c->token_type, c->buffer); //fprintf(of_d.temp1,"\nPROGRAM LINE: END\n\n\n"); //fprintf(of_d.listing_file, "%d:\t%s\n", valid, c->buffer); return 1; } else { printf("Missing END\n"); return 0; } } else { printf("Invalid grammar detected\n"); return 0; } } else { printf("Missing BEGIN\n"); return 0; } }
static void compound_stmt() { ListHead *t = NULL; /* match { */ match( TOK_LBRACKET ); while(token==TOK_INT||token==TOK_CHAR ||token==TOK_PINT||token==TOK_PCHAR) { t = local_var_declaration(token); insert_local_var(t,&offset,&(current_function->u.f.auto_head)); offset.current_level++; offset.current_block++; } current_function->u.f.total_offset = offset.local_total_offset; statement_list(); /* match } */ match(TOK_RBRACKET); offset.current_level--; }
static stmt_lst_node *statement_list(void){ stmt_lst_node *sln = newStmtLstNode(); if(match(TOKEN_IFKEY, NO_CONSUME) || match(TOKEN_WHILEKEY, NO_CONSUME) || match(TOKEN_FORKEY, NO_CONSUME) || match(TOKEN_TYPEKEY, NO_CONSUME) || match(TOKEN_SCOL, NO_CONSUME) || match(TOKEN_LCUR, NO_CONSUME) || match(TOKEN_INSTRUCTION,NO_CONSUME) || match(TOKEN_IDENTIFIER, NO_CONSUME)){ if((sln->stmtn = statement()) != NULL) if((sln->sln = statement_list()) != error) return sln; } else if(match(TOKEN_EOF, NO_CONSUME) || match(TOKEN_RCUR,NO_CONSUME)){ freeStmtLst(sln); return NULL; } freeStmtLst(sln); return error; }
static stmt_node *statement(void){ stmt_node *stmtn = newStmtNode(); if(match(TOKEN_IDENTIFIER, NO_CONSUME) || match(TOKEN_SCOL, NO_CONSUME)){ if((stmtn->assn = assignment()) != NULL) return stmtn; } else if(match(TOKEN_TYPEKEY, NO_CONSUME)){ if((stmtn->decn = declaration()) != NULL) return stmtn; } else if(match(TOKEN_IFKEY, NO_CONSUME)){ if((stmtn->ifn = if_()) != NULL) return stmtn; } else if(match(TOKEN_WHILEKEY,NO_CONSUME)){ if((stmtn->whilen = while_()) != NULL) return stmtn; } else if(match(TOKEN_FORKEY, NO_CONSUME)){ if((stmtn->forn = for_()) != NULL) return stmtn; } else if((stmtn->lCur = match(TOKEN_LCUR, CONSUME)) != NULL){ if((stmtn->sln = statement_list()) != error) if((stmtn->rCur = match(TOKEN_RCUR, CONSUME)) != NULL) return stmtn; } else if((stmtn->ins = match(TOKEN_INSTRUCTION, CONSUME)) != NULL) return stmtn; freeStmt(stmtn); return NULL; }
int looping_stat() { if(strcmp(token.c_str(),"while") == 0) { getToken("looping_stat"); if(strcmp(token.c_str(),"(") == 0) { getToken("looping_stat"); expr(); if(strcmp(token.c_str(),")") == 0) { getToken("looping_stat"); if(strcmp(token.c_str(),"{") == 0) { getToken("looping_stat"); statement_list(); if(strcmp(token.c_str(),"}") == 0) { getToken("looping_stat"); return 1; } else { printf("Error } expected\n"); exit(1); } } else { printf("Error { expected\n"); exit(1); } } else { printf("Error ) expected\n"); exit(1); } } else { printf("Error ( expected\n"); exit(1); } } else if(strcmp(token.c_str(),"for") == 0) { getToken("looping_stat"); if(strcmp(token.c_str(),"(") == 0) { getToken("looping_stat"); assign_stat(); if(strcmp(token.c_str(),";") == 0) { getToken("looping_stat"); expr(); if(strcmp(token.c_str(),";") == 0) { getToken("looping_stat"); assign_stat(); if(strcmp(token.c_str(),")") == 0) { getToken("looping_stat"); if(strcmp(token.c_str(),"{") == 0) { getToken("looping_stat"); statement_list(); if(strcmp(token.c_str(),"}") == 0) { getToken("looping_stat"); return 1; } else { printf("} expected\n"); exit(1); } } else { printf("{ expected\n"); exit(1); } } else { printf(") expected\n"); exit(1); } } else { printf("Error at ;\n"); exit(1); } } else { printf("Error at ;\n"); exit(1); } } else { printf("( expected\n"); exit(1); } } else { printf("while/for error\n"); exit(1); } }
void adasem(Node node) /*;adasem*/ { /* This is the driver routine for all semantic processing. It is called * by the parser whenever the syntax tree for a compilation unit has * been built. The input to this routine is an AST node, on which two * maps are defined : AST, and SPANS. These maps are global to the front * end. */ Node n1, n2, n3, n4; char *id, *op_id; Fortup ft1; Tuple tup; Node decl_node, id_node, l; Symbol package, s1; if (cdebug2 > 2) { /* TO_ERRFILE("node type ");*/ #ifdef IBM_PC printf("node type: %s %d %p\n", kind_str(N_KIND(node)), N_KIND(node), node); #else printf("node type: %s %d %ld\n", kind_str(N_KIND(node)), N_KIND(node), node); #endif } /* The current node is placed in a global variable, from which the error * routines can extract its span. */ current_node = node; #ifdef DEBUG if (trapns>0 && N_SEQ(node) == trapns && N_UNIT(node) == trapnu)trapn(node); #endif switch(N_KIND(node)) { /* Chapter 2. Lexical elements*/ /* pragma -> [as_pragma identifier argument_list]*/ case(as_pragma): process_pragma(node); break; /* argument_association -> [as_arg identifier expression]*/ case(as_arg): break; /*Unpacked in process_pragmas.*/ /* Chapter 3. Declarations and types */ /* object_declaration -> [as_obj_decl identifier_list subtype_indic * opt_expression] */ case(as_obj_decl): obj_decl(node); break; /* const_declaration -> ['const_decl' identifier_list subtype_indic * opt_expression] */ case(as_const_decl): const_decl(node); break; /* num_declaration -> ['num_decl' identifier_list expression]*/ case(as_num_decl): number_decl(node); break; /* type_decl -> ['type_decl' identifier discriminant_list * type_definition] */ case(as_type_decl): type_decl(node); break; /* Subtype_decl -> ['subtype_decl' identifier subtype_indic]*/ case(as_subtype_decl): subtype_decl(node); break; /* subtype_indication -> ['subtype_indic', name opt_constraint]*/ case(as_subtype_indic): /*[name, opt_constraint] := N_AST(node);*/ adasem(N_AST1(node)); adasem(N_AST2(node)); break; /* derived_type_definition -> ['derived_type' subtype_indication]*/ case(as_derived_type): break; /* discrete_range -> ['range' expression expression]*/ case(as_range): /*[expression1, expression2] := N_AST(node);*/ adasem(N_AST1(node)); adasem(N_AST2(node)); break; /* range_attribute -> ['range_attribute' name range]*/ case(as_range_attribute): N_KIND(node) = as_attribute; n2 = N_AST3(node); find_old(node); adasem(n2); break; /* discrete_range -> ['range_expression' expression]*/ case(as_range_expression): adasem(N_AST1(node)); break; /* constraint -> ['constraint' general_aggregate]*/ case(as_constraint): sem_list(node); break; /* enumeration_type -> [as_enum enumeration_literal_list]*/ case(as_enum): sem_list(node); break; case(as_int_type): break; case(as_float_type): break; case(as_fixed_type): break; case(as_digits): case(as_delta): adasem(N_AST1(node)); adasem(N_AST2(node)); break; /* array_type_definition -> ['array_type' index_list subtype_indication]*/ case(as_array_type): array_typedef(node); break; /* subtype_definition -> ['box' name]*/ case(as_box): adasem(N_AST1(node)); break; /* discrete_range -> [as_subtype opt_name range_constraint] * general_component_association ->[as_subtype opt_name range-constraint] */ case(as_subtype): /*[opt_name, range_constraint] := N_AST(node);*/ n1 = N_AST1(node); n2 = N_AST2(node); if (n1 != OPT_NODE) { adasem(n1); find_old(n1); } if (n2 == OPT_NODE) { /* possible, if syntax error */ N_KIND(node) = as_name; } else adasem(n2); break; /* record_decl -> [as_record component_list]*/ case(as_record): adasem(N_AST1(node)); break; /* component_list -> [ 'component_list' component_decl_list variant]*/ case(as_component_list): /*[component_decl_list, variant] := N_AST(node);*/ sem_list(N_AST1(node)); adasem(N_AST2(node)); break; /* component_declaration -> ['field' identifier_list subtype_indic * opt_expression] */ case(as_field): comp_decl(node); break; /* discr_specification -> ['discr_spec' identifier_list name opt_expr]*/ case(as_discr_spec): /*[id_list_node, name, opt_expr] := N_AST(node);*/ adasem(N_AST2(node)); /* adasem(N_AST3(node)); */ break; /* variant_part -> ['variant_decl' simple_name variant_list]*/ case(as_variant_decl): variant_decl(node); break; /* component_association -> ['choice_list' choice_list expression]*/ case(as_choice_list): /*[choice_list, expression] := N_AST(node);*/ sem_list(N_AST1(node)); adasem(N_AST2(node)); break; case(as_simple_choice): adasem(N_AST1(node)); break; case(as_range_choice): adasem(N_AST1(node)); break; case(as_others_choice): break; case(as_choice_unresolved): adasem(N_AST1(node)); break; case(as_access_type): n1 = N_AST1(node); adasem(n1); n2 = N_AST1(n1); n3 = N_AST2(n1); if (n3 == OPT_NODE ) { /*Special case: type mark may be an incomplete type.*/ N_UNQ(n1) = find_type(n2); } else { /* elaborate subtype indication*/ N_UNQ(n1) = promote_subtype(make_subtype(n1)); } break; /* incomplete_type_decl -> ['incomplete_decl' identifier discriminant]*/ case(as_incomplete_decl): incomplete_decl(node); break; /* declarations -> ['declarations' declaration_list]*/ case(as_declarations): declarative_part(node); break; /* Chapter 4. Names and expressions */ /* name -> ['character_literal' character] * Character literals also appear as enumeration literals, and as * selectors. */ case(as_character_literal): break; /* name -> ['simple_name' identifier]*/ case(as_simple_name): break; /* name -> ['call?' name general_aggregate]*/ case(as_call_unresolved): n1 = N_AST1(node); n2 = N_AST2(node); if (N_KIND(n1) == as_string) { /* Operator designator: reduce to lower case.*/ /*N_VAL(n1) = LOWER_CASE_OF(N_VAL(n1));*/ id = N_VAL(n1); while(*id) { if (isupper(*id)) *id = tolower(*id); id++; } } adasem(n1); FORTUP(n1 = (Node), N_LIST(n2), ft1); adasem(n1); ENDFORTUP(ft1); break; /* name -> ['operator' operator_symbol]*/ case(as_operator): N_KIND(node) = as_simple_name; break; case(as_string): N_KIND(node) = as_simple_name; break; /* name -> ['.' name selector]*/ case(as_selector): adasem(N_AST1(node)); break; case(as_all): adasem(N_AST1(node)); break; case(as_attribute): adasem(N_AST2(node)); adasem(N_AST3(node)); break; /* aggregate -> [as_aggregate expression_list]*/ case(as_aggregate): sem_list(node); break; /* parenthesised_expression -> ['()', expression]*/ case(as_parenthesis): adasem(N_AST1(node) ); break; /* expression -> [operator_designator <expression..>]*/ case(as_op): case(as_un_op): /*[op_node, arg_list] := N_AST(node);*/ n1 = N_AST1(node); op_id = N_VAL(n1); /* KLUDGE until parser fixed. */ if (streq(op_id, "NOT")) N_VAL(n1) = strjoin("not", ""); else if (streq(op_id, "AND")) N_VAL(n1) = strjoin("and", ""); else if (streq(op_id, "XOR")) N_VAL(n1) = strjoin("xor", ""); else if (streq(op_id, "REM")) N_VAL(n1) = strjoin("rem", ""); else if (streq(op_id, "MOD")) N_VAL(n1) = strjoin("mod", ""); else if (streq(op_id, "OR")) N_VAL(n1) = strjoin("or", ""); n2 = N_AST2(node); find_old(n1); FORTUP(n3 = (Node), N_LIST(n2), ft1); adasem(n3); /* * the call to check_range_attribute is useless, since * adasem converts as_range_attribute to as_attribute * (gcs 11 feb) */ /* check_range_attribute(n3); */ ENDFORTUP(ft1); break; case(as_in): case(as_notin): n3 = N_AST2(node); tup = N_LIST(n3); n1 = (Node) tup[1]; n2 = (Node) tup[2]; adasem(n1); adasem(n2); break; case(as_int_literal): break; case(as_real_literal): break; case(as_string_literal): break; case(as_null): break; case(as_name): adasem(N_AST1(node)); break; case(as_qualify): find_type(N_AST1(node)); adasem(N_AST2(node)); break; /* allocator -> ['new_init' name aggregate]*/ case(as_new_init): n1 = N_AST1(node); n2 = N_AST2(node); adasem(n1); adasem(n2); break; /* allocator -> ['new' name constraint_list]*/ case(as_new): n1 = N_AST1(node); n2 = N_AST2(node); adasem(n1); sem_list(n2); break; /* Chapter 5. Statements*/ /* sequence_of_statements -> ['statements' statement_list, label_list]*/ case(as_statements): statement_list(node); break; /* statement -> ['statement' label_list statement]*/ case(as_statement): /*[label_list, stmt] := N_AST(node);*/ n1= N_AST1(node); n2= N_AST2(node); FORTUP(l = (Node), N_LIST(n1), ft1); find_old(l); if (NATURE(N_UNQ(l)) != na_label) { errmsg("label hidden by inner declaration", "5.1", l); } ENDFORTUP(ft1); adasem(n2); break; /* labels_declaration -> ['labels' label_list]*/ case(as_labels): label_decl(node); break; /* null_statement -> [null_s']*/ case(as_null_s): break; /* assignment -> [':=' name expression ]*/ case(as_assignment): assign_statement(node); break; /* if_statement -> ['if' if_part_list opt_else]*/ case(as_if): if_statement(node); break; /* condition -> ['condition' expression]*/ case(as_condition): n1 = N_AST1(node); adasem(n1); check_type(symbol_boolean_type, n1); break; /* case_statement -> ['case' expression alt_list]*/ case(as_case): case_statement(node); break; /* loop_statement -> ['loop' opt_loop_id iteration_rule statements]*/ case(as_loop): loop_statement(node); break; /* iteration_rule -> ['while' condition]*/ case(as_while): adasem(N_AST1(node)); break; /* iteration rule -> ['for' identifier discrete_range]*/ case(as_for): iter_var(node); break; /* iteration_rule -> ['forrev' identifier discrete_range]*/ case(as_forrev): iter_var(node); break; /* block -> [na_block identifier declarations statements exceptions]*/ case(as_block): new_block(node); break; /* exit_statement -> ['exit' opt_name opt_expression]*/ case(as_exit): exit_statement(node); break; /* return_statement -> ['return' opt_expression]*/ case(as_return): return_statement(node); break; case(as_goto): goto_statement(node); break; /* Chapter 6. Subprograms*/ /* subprogram_declaration -> ['subprogram_decl', subprogram_spec]*/ case(as_subprogram_decl): subprog_decl(node); break; /* subprogram_specification -> [na_procedure identifier formals_list] * -> [na_function identifier formals_list name] */ case(as_procedure): break; case(as_function): find_type(N_AST3(node)); break; /* subprogram_body -> ['subprogram' subprogram_spec declarations * statements opt_exceptions] */ case(as_subprogram): subprog_body(node); break; /* parameter_specification -> ['formal' id_list mode name opt_expression]*/ case(as_formal): break; /* mode -> ['mode' identifier]*/ case(as_mode): break; /* call_statement -> ['call' name]*/ case(as_call): call_statement(node); break; /* Chapter 7. Packages*/ /* package_specification -> [na_package_spec identifier declarations * opt_private_part] */ case(as_package_spec): package_specification(node); break; /* package_body -> ['package_body' identifier declarations * opt_statements opt_handler] */ case(as_package_body): id_node = N_AST1(node); decl_node = N_AST2(node); n3 = N_AST3(node); n4 = N_AST4(node); module_body_id(na_package, id_node); adasem(decl_node); adasem(n3); adasem(n4); force_all_types(); module_body(na_package, node); package = N_UNQ(id_node); if (NATURE(package) == na_generic_package) N_KIND(node) = as_generic_package; break; /* private_type_declaration -> ['private_decl' identifier * discriminant_list priv_kind] */ case(as_private_decl): private_decl(node); break; /* Chapter 8. Visibility rules*/ /* use_clause -> [use' identifier_list]*/ case(as_use): use_clause(node); break; /* renaming_declaration -> ['rename_ex' identifier name]*/ case(as_rename_ex): rename_ex(node); break; /* renaming_declaration -> ['rename_pack' identifier name]*/ case(as_rename_pack): rename_pack(node); break; /* renaming_declaration -> ['rename_obj' identifier type_mark name]*/ case(as_rename_obj): rename_object(node); break; /* renaming declarations -> ['rename_sub' subprogam_spec name]*/ case(as_rename_sub): rename_subprogram(node); break; /* Chapter 9. Tasks */ /* task_specification -> [task_kind identifier opt_entry_declaration * opt_rep_clause] * task_kind -> 'task_spec' * -> na_task_type_spec */ case(as_task_spec): case(as_task_type_spec): /* clear N_AST3 as specification not supported now, and * need this field for N_TYPE DS 9-21-86 */ N_AST3(node) = (Node)0; task_spec(node); break; /* task_body -> ['task' identifier declarations statements * opt_exceptions] */ case(as_task): /*[id_node, decls, stmts, excepts] := N_AST(node);*/ id_node = N_AST1(node); n2 = N_AST2(node); n3 = N_AST3(node); n4 = N_AST4(node); module_body_id(na_task_type, id_node); /* clear the private_decls field set in module_body_id as this is */ /* irrelevant to tasks. */ private_decls(N_UNQ(id_node)) = (Set)0; adasem(n2); adasem(n3); adasem(n4); module_body(na_task_type, node); s1 = N_UNQ(id_node); check_incomplete_decls(s1, node); break; /* entry_declaration -> [na_entry identifier formals_list]*/ case(as_entry): entry_decl(node); break; /* * entry_declaration -> [na_entry_family identifier discrete_range * formals_list] */ case(as_entry_family): entry_family_decl(node); break; /* accept_statement -> ['accept' name opt_expression opt_formal_part * opt_statements] */ case(as_accept): accept_statement(node); break; /* delay_statement -> ['delay' expression]*/ case(as_delay): n1 = N_AST1(node); adasem(n1); check_type(symbol_duration, n1); break; /* selective_wait -> ['selective_wait' alternative_list else_part]*/ case(as_selective_wait): n1 = N_AST1(node); n2 = N_AST2(node); sem_list(n1); if (n2 != OPT_NODE) adasem(n2); break; /* select_alternative -> ['guard' condition selective_wait_alternative]*/ case(as_guard): adasem(N_AST1(node)); adasem(N_AST2(node)); break; /* selective_wait_alternative -> ['accept_alt' accept_statement opt_stats] * -> ['delay_alt' delay_statement opt_stats] */ case(as_accept_alt): adasem(N_AST1(node)); adasem(N_AST2(node)); break; case(as_delay_alt): adasem(N_AST1(node)); adasem(N_AST2(node)); break; /* selective_wait_alternative -> ['terminate_alt' ]*/ case(as_terminate_alt): terminate_statement(node); break; /* conditional_entry_call -> ['conditional_entry_call' call_statement * statements else_stat] */ case(as_conditional_entry_call): check_entry_call(N_AST1(node)); adasem(N_AST2(node)); adasem(N_AST3(node)); break; /* timed_entry_call -> ['timed_entry_call', call_statement statements * delay_alternative] */ case(as_timed_entry_call): check_entry_call(N_AST1(node)); adasem(N_AST2(node)); adasem(N_AST3(node)); break; /* abort_statement -> ['abort' task_name_list]*/ case(as_abort): abort_statement(node); break; /* Chapter 10. Program structure...*/ /* (as_compilation): * This node is used for pragmas that precede a compilation unit. * TBSL */ /* unit_declaration -> ['unit' context_clause unit_body]*/ case(as_unit): compunit(node); break; /* context_clause -> ['with_use_list' [with_or_use...]] * No action is necessary since this is handled in comp_unit * body_stub -> ['subprogam_stub' subprogram_specification] * -> ['package_stub' name] * -> ['task_stub' name] */ case(as_subprogram_stub): { Symbol u_name; n1 = N_AST1(node); n2 = N_AST1(n1); u_name = dcl_get(DECLARED(scope_name), N_VAL(n2)); /* For generic stubs ignore call to check_spec. * TBSL: code for checking formals. * Note: if uname is undefined here it indicates that the stub had * no subprog declaration and therefore is certainly not generic. */ if (u_name != (Symbol)0 && (NATURE(u_name) == na_generic_procedure_spec || NATURE(u_name) == na_generic_function_spec)) { N_UNQ(n2) = u_name; newscope(u_name); adasem(n1); popscope(); save_stub(node); } else { adasem(n1); check_spec(node); u_name = N_UNQ(n2); NATURE(u_name) = N_KIND(n1) == as_procedure ? na_procedure_spec : na_function_spec; if (in_op_designators(ORIG_NAME(u_name) ) ){ errmsg_l("Name of separately compiled unit cannot be ", "an operator designator", "10.1", n2); } else { save_stub(node); } } } break; case(as_package_stub): stub_head(na_package, node); save_stub(node); break; case(as_task_stub): stub_head(na_task, node); save_stub(node); break; /* subunit -> ['separate' parent_name unit]*/ case(as_separate): adasem(N_AST2(node)); break; /* Chapter 11. Exceptions*/ /* Exception_declaration -> ['except_decl' identifier_list]*/ case(as_except_decl): except_decl(node); break; /* exceptions -> ['exception' handler_list]*/ case(as_exception): exception_part(node); break; /* exception_handler -> ['handler' exception_choice_list statements]*/ case(as_handler): exception_handler(node); break; case(as_others): break; /* raise_statement -> ['raise opt_identifier]*/ case(as_raise): raise_statement(node); break; /* Chapter 12. Generics*/ case(as_generic_procedure): case(as_generic_function): generic_subprog_spec(node); break; case(as_generic_package): generic_pack_spec(node); break; /* Generic part -> ['generic_formals' generic_decl_list]*/ case(as_generic_formals): /*$$$newtypes with:= []; $ Anonymous types may be created (???)*/ sem_list(node); /*$$$ generic_list := []+/sem_list(2); and new_type_list*/ break; /* Generic_formal -> ['generic_obj' id_list mode name opt_expression]*/ case(as_generic_obj): generic_obj_decl(node); break; /* Generic formal -> ['generic_type' identifier type_def]*/ case(as_generic_type): generic_type_decl(node); break; /* Generic formal -> ['gen_priv_type' private_type_declaration]*/ case(as_gen_priv_type): generic_priv_decl(node); break; /* Generic_formal -> ['generic_subp', subprogram_spec opt_is]*/ case(as_generic_subp): generic_subp_decl(node); break; /* Generic_type_definition -> ['generic' identifier]*/ case(as_generic): break; /* Package_instance -> ['package_instance' identifier name instance_list]*/ case(as_package_instance): package_instance(node); break; /* subprogram_instance * -> ['function_instance' designator name generic_actual_part] * -> ['procedure_instance' identifier name generic_actual_part] */ case(as_function_instance): case(as_procedure_instance): subprog_instance(node); break; /* generic_parameter_association->['instance' opt_identifier expression]*/ case(as_instance): break; /* Chapter 13. Representation specs...*/ /* length_clause -> ['length_clause' attribute simple_expression ]*/ case(as_length_clause): length_clause (node); break; /* * enumeration_representation_clause -> ['enum_rep_clause' * simple_name aggregate ] */ case(as_enum_rep_clause): enum_rep_clause (node); break; /* * record_representation_clause -> * ['rec_rep_clause' simple_name opt_align_clause comp_clause_list ] */ case(as_rec_rep_clause): rec_rep_clause(node); break; /* component_clause -> ['compon_clause' name simple_expression range]*/ case(as_compon_clause): adasem(N_AST1(node)); adasem(N_AST2(node)); adasem(N_AST3(node)); break; /* address_clause -> ['address_clause' simple_name simple_expression]*/ case(as_address_clause): break; case(as_opt): break; case(as_line_no): break; default: if (node == (Node)0) return; /* above is single line added re OPT_NODE 4 jul*/ printf("adasem: invalid node %d kind %d\n", node, N_KIND(node)); errmsg_str("System error: invalid node %", kind_str(N_KIND(node)), "none", node); } }