diff --git a/src/grammar.y b/src/grammar.y index c9da70b..9e765e2 100644 --- a/src/grammar.y +++ b/src/grammar.y @@ -26,6 +26,7 @@ extern TableNode* chara; extern TableNode* stri; extern TableNode* boo; + TableNode * tn; %} //%define api.location.type {location_t} %locations @@ -118,7 +119,6 @@ prototype_or_definition_list: prototype: L_PAREN EXTERNAL R_PAREN FUNCTION ID COLON ID; -definition: definition: TYPE ID COLON {tn = CreateEntry(getAncestor(cur), recprime, $2, CreateRecordInfo(0, cur = CreateScope(cur, 0, 0))); if (table_lookup(getAncestor(cur), $2) == NULL) { @@ -169,14 +169,10 @@ TYPE ID COLON {tn = CreateEntry(getAncestor(cur), recprime, $2, CreateRecordInfo function_declaration: -FUNCTION ID COLON ID {CreateEntry(cur, look_up(cur, $4), $2, CreateFunctionDeclarationInfo(-1, false));} + FUNCTION ID COLON ID {CreateEntry(cur, look_up(cur, $4), $2, CreateFunctionDeclarationInfo(-1, false));} | EXTERNAL FUNCTION ID COLON ID {CreateEntry(cur, look_up(cur, $5), $3, NULL);} ; -parameter: - L_PAREN ID R_PAREN - | AS L_PAREN idlist R_PAREN - ; idlist: ID { @@ -222,7 +218,7 @@ declaration: ; id_or_types: - ID {printf("string of id in id_or_type is %s\n",$1);} {$$ = $1;} + ID {printf("string of id in id_or_type is %s\n",$1); $$ = getType(look_up(cur,$1));} | types {printf("string of type in id_or_type is %s\n",$1);} {$$ = $1;} ; @@ -276,7 +272,8 @@ ID {TableNode *node = table_lookup(cur, $1); } $$ = getName(getReturn(look_up(cur, $1))); } -| assignable rec_op ID {TableNode * tn; printf("this is assignable.id %s\n", getType(look_up(cur, $1)));if(NULL != (tn = table_lookup(getRecList(look_up(cur, $1)), $3))) +| assignable rec_op ID {TableNode * tn; printf("this is assignable.id %s\n", getType(look_up(cur, $1))); + if(NULL != (tn = table_lookup(getRecList(look_up(cur, $1)), $3))) {$$ = "test";} } ;