fix parse and semantic v2.1
This commit is contained in:
@@ -18,7 +18,7 @@ static int savedNumber;
|
||||
static int savedLineNo; /* ditto */
|
||||
static TreeNode * savedTree; /* stores syntax tree for later return */
|
||||
static int yylex(void); // added 11/2/11 to ensure no conflict with lex
|
||||
|
||||
int yyerror(char * message);
|
||||
%}
|
||||
|
||||
%token IF ELSE WHILE RETURN INT VOID
|
||||
@@ -120,13 +120,16 @@ param_list : param_list COMMA param {
|
||||
} | param {$$ = $1; };
|
||||
|
||||
param : type_specifier name_specifier {
|
||||
$$ = newDeclNode(NonArrParamK );
|
||||
$$ = newDeclNode(NonArrParamK);
|
||||
$$->attr.name = savedName;
|
||||
$$->type = $1->type;
|
||||
} | type_specifier name_specifier LBRACE RBRACE {
|
||||
$$ = newDeclNode(ArrParamK);
|
||||
$$->type = $1->type;
|
||||
$$->attr.name = savedName;
|
||||
if ($1->type == Integer)
|
||||
$$->type = IntegerArray;
|
||||
else
|
||||
$$->type = Void;
|
||||
};
|
||||
|
||||
compound_stmt : LCURLY local_declarations statement_list RCURLY {
|
||||
|
||||
Reference in New Issue
Block a user