Skip to content

Commit

Permalink
minor refactoring in parser. Also disallow array constructors to be u…
Browse files Browse the repository at this point in the history
…sed too often; only allowed in decls of arrays.
  • Loading branch information
kjs committed Jun 16, 2012
1 parent f5962c8 commit cf042f0
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/m1.y
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ yyerror(yyscan_t yyscanner, M1_compiler *comp, char *str) {
TK_STRING_CONST
return_type
type
__type
native_type
TK_USERTYPE

Expand Down Expand Up @@ -940,7 +941,6 @@ expression : constexpr
| function_call_expr
| nullexpr
| newexpr
| arrayconstructor
;

subexpr : '(' expression ')'
Expand Down Expand Up @@ -1046,19 +1046,17 @@ return_type : type { $$ = $1; }
| "void" { $$ = "void"; }
;

type : native_type
type : __type
{
M1_compiler *comp = (M1_compiler *)yyget_extra(yyscanner);
comp->parsingtype = $1;
$$ = $1;
}
| TK_USERTYPE
{
M1_compiler *comp = (M1_compiler *)yyget_extra(yyscanner);
comp->parsingtype = $1;
$$ = $1;
}

}
;

/* __type is a helper rule to prevent code duplication. */
__type : native_type
| TK_USERTYPE
;

native_type : "int" { $$ = "int"; }
Expand Down

0 comments on commit cf042f0

Please sign in to comment.