Merge remote-tracking branch 'origin/topic/jsiwek/string-slicing-fix'

* origin/topic/jsiwek/string-slicing-fix:
  Support omission of string slice low/high indices, BIT-1097.
This commit is contained in:
Robin Sommer 2013-12-04 13:24:45 -08:00
commit 81096820f3
3 changed files with 56 additions and 4 deletions

View file

@ -52,7 +52,7 @@
%type <expr> opt_init
%type <val> TOK_CONSTANT
%type <re> pattern
%type <expr> expr init anonymous_function
%type <expr> expr opt_expr init anonymous_function
%type <event_expr> event
%type <stmt> stmt stmt_list func_body for_head
%type <type> type opt_type enum_body
@ -265,6 +265,13 @@ decl_list:
|
;
opt_expr:
expr
{ $$ = $1; }
|
{ $$ = 0; }
;
expr:
'(' expr ')'
{
@ -422,11 +429,13 @@ expr:
$$ = new IndexExpr($1, $3);
}
| expr '[' expr ':' expr ']'
| expr '[' opt_expr ':' opt_expr ']'
{
set_location(@1, @6);
ListExpr* le = new ListExpr($3);
le->Append($5);
Expr* low = $3 ? $3 : new ConstExpr(new Val(0, TYPE_COUNT));
Expr* high = $5 ? $5 : new SizeExpr($1);
ListExpr* le = new ListExpr(low);
le->Append(high);
$$ = new IndexExpr($1, le, true);
}