summaryrefslogtreecommitdiff
path: root/frontends/verilog/parser.y
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-11-20 13:05:27 +0100
committerClifford Wolf <clifford@clifford.at>2013-11-20 13:05:27 +0100
commit92035fb38ef8e7ac6319af659f7d682a047d2f70 (patch)
treeaddf8c0a087eac819af1d869af61608061fbfa34 /frontends/verilog/parser.y
parentc4c299eb5a3d9c2b7c9932efb35669c09c1aacb4 (diff)
Implemented indexed part selects
Diffstat (limited to 'frontends/verilog/parser.y')
-rw-r--r--frontends/verilog/parser.y11
1 files changed, 11 insertions, 0 deletions
diff --git a/frontends/verilog/parser.y b/frontends/verilog/parser.y
index c4f386ce..5dbf0490 100644
--- a/frontends/verilog/parser.y
+++ b/frontends/verilog/parser.y
@@ -104,6 +104,7 @@ static void free_attr(std::map<std::string, AstNode*> *al)
%token TOK_GENERATE TOK_ENDGENERATE TOK_GENVAR
%token TOK_SYNOPSYS_FULL_CASE TOK_SYNOPSYS_PARALLEL_CASE
%token TOK_SUPPLY0 TOK_SUPPLY1 TOK_TO_SIGNED TOK_TO_UNSIGNED
+%token TOK_POS_INDEXED TOK_NEG_INDEXED
%type <ast> wire_type range non_opt_range expr basic_expr concat_list rvalue lvalue lvalue_concat_list
%type <string> opt_label tok_prim_wrapper hierarchical_id
@@ -336,6 +337,16 @@ non_opt_range:
$$->children.push_back($2);
$$->children.push_back($4);
} |
+ '[' expr TOK_POS_INDEXED expr ']' {
+ $$ = new AstNode(AST_RANGE);
+ $$->children.push_back(new AstNode(AST_SUB, new AstNode(AST_ADD, $2->clone(), $4), AstNode::mkconst_int(1, true)));
+ $$->children.push_back(new AstNode(AST_ADD, $2, AstNode::mkconst_int(0, true)));
+ } |
+ '[' expr TOK_NEG_INDEXED expr ']' {
+ $$ = new AstNode(AST_RANGE);
+ $$->children.push_back(new AstNode(AST_ADD, $2, AstNode::mkconst_int(0, true)));
+ $$->children.push_back(new AstNode(AST_SUB, new AstNode(AST_ADD, $2->clone(), AstNode::mkconst_int(1, true)), $4));
+ } |
'[' expr ']' {
$$ = new AstNode(AST_RANGE);
$$->children.push_back($2);