summaryrefslogtreecommitdiff
path: root/frontends/verilog/parser.y
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-12-04 21:06:54 +0100
committerClifford Wolf <clifford@clifford.at>2013-12-04 21:06:54 +0100
commit4a4a3fc3377243d85100b829a0f6b785376cce9f (patch)
tree689dda333df9ac7012ce460e8f7e801b631c0882 /frontends/verilog/parser.y
parentf4b46ed31e5f5c41bbd4ee1fdf996ecdc2010174 (diff)
Various improvements in support for generate statements
Diffstat (limited to 'frontends/verilog/parser.y')
-rw-r--r--frontends/verilog/parser.y44
1 files changed, 40 insertions, 4 deletions
diff --git a/frontends/verilog/parser.y b/frontends/verilog/parser.y
index 5a45a776..01c9a009 100644
--- a/frontends/verilog/parser.y
+++ b/frontends/verilog/parser.y
@@ -887,6 +887,22 @@ case_item:
ast_stack.pop_back();
};
+gen_case_body:
+ gen_case_body gen_case_item |
+ /* empty */;
+
+gen_case_item:
+ {
+ AstNode *node = new AstNode(AST_COND);
+ ast_stack.back()->children.push_back(node);
+ ast_stack.push_back(node);
+ } case_select {
+ case_type_stack.push_back(0);
+ } gen_stmt_or_null {
+ case_type_stack.pop_back();
+ ast_stack.pop_back();
+ };
+
case_select:
case_expr_list ':' |
TOK_DEFAULT;
@@ -956,7 +972,6 @@ single_arg:
module_gen_body:
module_gen_body gen_stmt |
- module_gen_body module_body_stmt |
/* empty */;
// this production creates the obligatory if-else shift/reduce conflict
@@ -967,7 +982,7 @@ gen_stmt:
ast_stack.push_back(node);
} simple_behavioral_stmt ';' expr {
ast_stack.back()->children.push_back($6);
- } ';' simple_behavioral_stmt ')' gen_stmt {
+ } ';' simple_behavioral_stmt ')' gen_stmt_block {
ast_stack.pop_back();
} |
TOK_IF '(' expr ')' {
@@ -975,7 +990,15 @@ gen_stmt:
ast_stack.back()->children.push_back(node);
ast_stack.push_back(node);
ast_stack.back()->children.push_back($3);
- } gen_stmt opt_gen_else {
+ } gen_stmt_block opt_gen_else {
+ ast_stack.pop_back();
+ } |
+ case_type '(' expr ')' {
+ AstNode *node = new AstNode(AST_GENCASE, $3);
+ ast_stack.back()->children.push_back(node);
+ ast_stack.push_back(node);
+ } gen_case_body TOK_ENDCASE {
+ case_type_stack.pop_back();
ast_stack.pop_back();
} |
TOK_BEGIN opt_label {
@@ -989,10 +1012,23 @@ gen_stmt:
if ($6 != NULL)
delete $6;
ast_stack.pop_back();
+ } |
+ module_body_stmt;
+
+gen_stmt_block:
+ {
+ AstNode *node = new AstNode(AST_GENBLOCK);
+ ast_stack.back()->children.push_back(node);
+ ast_stack.push_back(node);
+ } gen_stmt {
+ ast_stack.pop_back();
};
+gen_stmt_or_null:
+ gen_stmt_block | ';';
+
opt_gen_else:
- TOK_ELSE gen_stmt | /* empty */;
+ TOK_ELSE gen_stmt_or_null | /* empty */;
expr:
basic_expr {