-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4463315
commit a7cb6b8
Showing
15 changed files
with
307 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
.../main/scala/soda/se/umu/cs/soda/prototype/example/market/serializer/MarketSerializer.soda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
class MarketSerializer | ||
|
||
abstract | ||
|
||
serialize_accounts (accounts : List [Money] ) : List [Operation] = | ||
accounts | ||
.zipWithIndex | ||
.map (lambda pair --> OpDeposit .mk (pair ._2) (pair ._1) ) | ||
|
||
serialize_items (items : List [Item] ) : List [Operation] = | ||
items | ||
.zipWithIndex | ||
.flatMap (lambda pair --> | ||
List [Operation] ( | ||
OpAssign .mk (pair ._2) (pair ._1 .owner) , | ||
OpPrice .mk (pair ._2) (pair ._1 .price) | ||
) | ||
) | ||
|
||
serialize (m : Market) : List [Operation] = | ||
serialize_accounts (m .accounts) .++ ( | ||
serialize_items (m .items) | ||
) | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...rc/main/scala/soda/se/umu/cs/soda/prototype/example/market/serializer/YamlSerializer.soda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
class YamlSerializer | ||
|
||
abstract | ||
|
||
market_serializer = MarketSerializer .mk | ||
|
||
operation_serializer = OperationSerializer .mk | ||
|
||
serialize_operations (operations : List [Operation] ) : String = | ||
"operations:" + | ||
"\n- " + | ||
operations | ||
.map (lambda operation --> operation_serializer .serialize (operation) ) | ||
.mkString ("\n- ") + | ||
"\n\n" | ||
|
||
serialize_market (m : Market) : String = | ||
"---\n" + | ||
serialize_operations ( | ||
market_serializer .serialize (m) | ||
) | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.