fixed some grammar rules
This commit is contained in:
@ -26,6 +26,7 @@
|
|||||||
extern TableNode* chara;
|
extern TableNode* chara;
|
||||||
extern TableNode* stri;
|
extern TableNode* stri;
|
||||||
extern TableNode* boo;
|
extern TableNode* boo;
|
||||||
|
TableNode * tn;
|
||||||
%}
|
%}
|
||||||
//%define api.location.type {location_t}
|
//%define api.location.type {location_t}
|
||||||
%locations
|
%locations
|
||||||
@ -118,7 +119,6 @@ prototype_or_definition_list:
|
|||||||
prototype:
|
prototype:
|
||||||
L_PAREN EXTERNAL R_PAREN FUNCTION ID COLON ID;
|
L_PAREN EXTERNAL R_PAREN FUNCTION ID COLON ID;
|
||||||
|
|
||||||
definition:
|
|
||||||
definition:
|
definition:
|
||||||
TYPE ID COLON {tn = CreateEntry(getAncestor(cur), recprime, $2, CreateRecordInfo(0, cur = CreateScope(cur, 0, 0)));
|
TYPE ID COLON {tn = CreateEntry(getAncestor(cur), recprime, $2, CreateRecordInfo(0, cur = CreateScope(cur, 0, 0)));
|
||||||
if (table_lookup(getAncestor(cur), $2) == NULL) {
|
if (table_lookup(getAncestor(cur), $2) == NULL) {
|
||||||
@ -169,14 +169,10 @@ TYPE ID COLON {tn = CreateEntry(getAncestor(cur), recprime, $2, CreateRecordInfo
|
|||||||
|
|
||||||
|
|
||||||
function_declaration:
|
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);}
|
| 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:
|
idlist:
|
||||||
ID {
|
ID {
|
||||||
@ -222,7 +218,7 @@ declaration:
|
|||||||
;
|
;
|
||||||
|
|
||||||
id_or_types:
|
id_or_types:
|
||||||
ID {printf("string of id in id_or_type is %s\n",$<words>1);} {$$ = $<words>1;}
|
ID {printf("string of id in id_or_type is %s\n",$<words>1); $$ = getType(look_up(cur,$1));}
|
||||||
| types {printf("string of type in id_or_type is %s\n",$<words>1);} {$$ = $<words>1;}
|
| types {printf("string of type in id_or_type is %s\n",$<words>1);} {$$ = $<words>1;}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -276,7 +272,8 @@ ID {TableNode *node = table_lookup(cur, $<words>1);
|
|||||||
}
|
}
|
||||||
$$ = getName(getReturn(look_up(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";}
|
{$$ = "test";}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
Reference in New Issue
Block a user