Skip to content

Commit

Permalink
Remove trailing-if-expr from the grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
i2y committed May 30, 2016
1 parent 509b21f commit fae5b96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 7 additions & 2 deletions examples/etc.mochi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ elif False:
elif False:
200000
else:
print "False!"
print("False!")

if True:
w = "aiueo"
Expand Down Expand Up @@ -87,7 +87,12 @@ else:

print(str(1) + str(2), 10)

tuple(map(-> $1 + 10 if True else $1 + 20, [1, 2, 3]))
m1 = map([1, 2, 3]) ->
if True:
$1 + 10
else:
$1 + 20
m1 |> tuple |> print

match ["faa", 200]:
["aaa", xx]: print(xx + 200)
Expand Down
3 changes: 1 addition & 2 deletions mochi/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ def binding(p):
@pg.production('expr : fn_expr')
@pg.production('expr : paren_expr')
@pg.production('expr : if_expr')
@pg.production('expr : trailing_if_expr')
@pg.production('expr : prim_expr')
@pg.production('expr : uq_expr')
@pg.production('expr : uqs_expr')
Expand Down Expand Up @@ -554,7 +553,7 @@ def elseif_expr_empty(p):
return None


@pg.production('trailing_if_expr : binop_expr IF binop_expr ELSE binop_expr')
#@pg.production('trailing_if_expr : binop_expr IF binop_expr ELSE binop_expr')
def trailing_if_expr(p):
return [Symbol('if'), p[2], p[0], p[4]]

Expand Down

0 comments on commit fae5b96

Please sign in to comment.