Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
pmineiro committed Aug 10, 2009
1 parent d2073ec commit dbdfe60
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 0.2.0
* handle structured match statements (duh)

Version 0.1.0
* Per Ulf's suggestion, rewrite local call (let_) for nicer syntax.

Expand Down
2 changes: 1 addition & 1 deletion fw-pkgin/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# environment variable FW_PACKAGE_DEFAULT_MAINTAINER if non-empty

FW_PACKAGE_NAME="lyet"
FW_PACKAGE_VERSION="0.1.0"
FW_PACKAGE_VERSION="0.2.0"
FW_PACKAGE_MAINTAINER="Paul Mineiro <[email protected]>"
FW_PACKAGE_SHORT_DESCRIPTION="Erlang parse transform to provide let like functionality."
FW_PACKAGE_DESCRIPTION=`cat README`
Expand Down
10 changes: 2 additions & 8 deletions src/lyet.erl
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,14 @@ parse_transform(Forms, Options) ->
[Expr|Assignments] = lists:reverse(L),
lists:foldl
(fun (Assign, Acc) ->
{ match, Line, { var, _, Var }, Val } =
{ match, Line, Pattern, Val } =
erl_syntax:revert (Assign),
{ call,
Line,
{ 'fun',
Line,
{ clauses,
[ { clause,
Line,
[ { var, Line, Var } ],
[],
[ Acc ]
}
]
[ { clause, Line, [ Pattern ], [], [ Acc ] } ]
}
},
[ Val ]
Expand Down
9 changes: 9 additions & 0 deletions tests/testlyet.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ testmegathree (X) ->
testmeganoassign () ->
let_ (9 + 2).

testmegastructured (X) ->
let_ ({ _, X } = { dude, g (X) },
{ X, _ } = { h (X), wheres },
{ _, X } = { my, l (X) },
{ car, m (X) }).

testone (X) ->
lyet:lyet (X = g (X),
X = h (X),
Expand Down Expand Up @@ -88,6 +94,9 @@ three_mega_test () ->
noassign_mega_test () ->
?assertEqual (11, testmeganoassign ()).

structured_mega_test () ->
?assertEqual ({ car, 11 }, testmegastructured (1)).

one_test () ->
?assertEqual (11, testone (1)).

Expand Down

0 comments on commit dbdfe60

Please sign in to comment.