summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkugwa <kugwa2000@gmail.com>2015-11-13 01:22:17 +0800
committerkugwa <kugwa2000@gmail.com>2015-11-13 01:22:17 +0800
commitc2137f532483d3fb87a67d2b7fbef476d8cef81d (patch)
tree09be3ec5b6978754aa0446f00290ce5e26e865ef
parent3cb1408762d4a08a1f4abd562c4fd5335f44186b (diff)
downloadcompiler2015-c2137f532483d3fb87a67d2b7fbef476d8cef81d.tar.gz
compiler2015-c2137f532483d3fb87a67d2b7fbef476d8cef81d.tar.zst
compiler2015-c2137f532483d3fb87a67d2b7fbef476d8cef81d.zip
Fix some actions to meet TA's spec
1. dim_fn should be the child of ID 2. decl_list should be the child of VARIABLE_DECL_LIST_NODE 3. stmt_list should be the child of STMT_LIST_NODE 4. Add actions for decl_list 5. ID with initial value should use WITH_INIT_ID instead of NORMAL_ID
-rw-r--r--src/parser.y15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/parser.y b/src/parser.y
index cce793c..6a5cb58 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -157,7 +157,7 @@ param : type ID
| type ID dim_fn
{
$$ = makeDeclNode(FUNCTION_PARAMETER_DECL);
- makeFamily($$, 3, $1, makeIDNode($2, NORMAL_ID), $3);
+ makeFamily($$, 2, $1, makeChild(makeIDNode($2, ARRAY_ID), $3));
}
;
dim_fn : DL_LBRACK expr_null DL_RBRACK
@@ -183,7 +183,7 @@ expr_null :expr
block : decl_list stmt_list
{
$$ = Allocate(BLOCK_NODE);
- makeFamily($$, 2, $1, $2);
+ makeFamily($$, 2, makeChild(Allocate(VARIABLE_DECL_LIST_NODE), $1), makeChild(Allocate(STMT_LIST_NODE), $2));
}
| stmt_list
{
@@ -202,11 +202,11 @@ block : decl_list stmt_list
decl_list : decl_list decl
{
- /*TODO*/
+ $$ = makeSibling($1, $2);
}
| decl
{
- /*TODO*/
+ $$ = $1;
}
;
@@ -252,10 +252,6 @@ type : INT
{
$$ = makeIDNode("float", NORMAL_ID);
}
- /*| ID
- {
- }
- */
;
id_list : ID
@@ -342,8 +338,7 @@ init_id : ID
}
| ID OP_ASSIGN relop_expr
{
- /*TODO*/
- $$ = makeIDNode($1, NORMAL_ID);
+ $$ = makeIDNode($1, WITH_INIT_ID);
makeChild($$, $3);
}
;