X-Git-Url: http://nitlanguage.org diff --git a/src/parser/nit.sablecc3xx b/src/parser/nit.sablecc3xx index b950be4..b921879 100644 --- a/src/parser/nit.sablecc3xx +++ b/src/parser/nit.sablecc3xx @@ -78,6 +78,7 @@ long_sstr_body = long_sstr_part*; extern_code_char = [all - ['`' + '\']] | '\' all + | '`' [all - '}'] ; extern_code_body = extern_code_char*; @@ -565,7 +566,7 @@ expr_single~nopar~nobra {-> expr} // !nopar to unambiguise 'foo[5].bar' between '(foo[5]).bar' and 'foo([5].bar), !nobra!nopar | {range} obra no expr [n2]:no dotdot [n3]:no [expr2]:expr_nobra [n4]:no cbra annotations_o {-> New expr.crange(obra, expr, expr2.expr, cbra, annotations_o.annotations)} !nobra!nopar | {orange} obra no expr [n2]:no dotdot [n3]:no [expr2]:expr_nobra [n4]:no [cbra]:obra annotations_o {-> New expr.orange(obra, expr, expr2.expr, cbra, annotations_o.annotations)} -!nobra!nopar | {array} obra no args_list typing_o cbra annotations_o {-> New expr.array(obra, args_list.exprs, typing_o.type, cbra, annotations_o.annotations)} +!nobra!nopar | {array} obra no array_items typing_o cbra annotations_o {-> New expr.array(obra, [array_items.expr], typing_o.type, cbra, annotations_o.annotations)} ; expr_par {-> expr} @@ -581,6 +582,18 @@ many_expr_tail {->expr} = comma no any_expr {-> any_expr.expr} ; +array_items {-> expr*} + = array_item array_items_tail* {-> [array_item.expr, array_items_tail.expr]} + ; +array_items_tail {-> expr} + = comma no array_item {-> array_item.expr} + ; +array_item {-> expr} + = expr no {-> expr} + | {for} kwfor no [ids]:idlist [n2]:no kwin [n3]:no expr [n4]:no kwdo [block]:array_item {-> New expr.for(kwfor, [ids.id], expr, kwdo, block.expr, Null)} + | {if} kwif [n1]:no expr [n2]:no kwthen [n3]:no [then]:array_item {-> New expr.if(kwif, expr, then.expr, Null)} + ; + superstring {-> expr} = superstring_start superstring_middle* superstring_end annotations_o {-> New expr.superstring([superstring_start.expr, superstring_middle.expr, superstring_end.expr], annotations_o.annotations)}; superstring_start {-> expr*} @@ -870,7 +883,7 @@ expr = {block} expr* kwend? | {range} expr [expr2]:expr annotations? | {crange} obra expr [expr2]:expr cbra annotations? | {orange} obra expr [expr2]:expr [cbra]:obra annotations? - | {array} obra [exprs]:exprs type? cbra annotations? + | {array} obra [exprs]:expr* type? cbra annotations? | {self} kwself annotations? | {implicit_self} | {true} kwtrue annotations?