Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
r28760@phanatique: nelhage | 2007-12-20 21:21:10 -0800
move Expression into its own module git-svn-id: svn+ssh://lunatique.mit.edu/data/svn/flnv/trunk@28 e7f7c2cb-1e20-0410-8c26-a6ba679ee1f5
- Loading branch information
nelhage
committed
Jul 25, 2008
1 parent
1aef566
commit 713f774
Showing
5 changed files
with
35 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module FLNV.Expression (Expression(..)) where | ||
|
||
data Expression = Symbol String | ||
| Number Integer | ||
| String String | ||
| Bool Bool | ||
| Cons Expression Expression | ||
| Nil | ||
deriving (Eq) | ||
|
||
instance Show Expression where | ||
show (Symbol s) = s | ||
show (Number n) = show n | ||
show (String s) = '"' : s ++ "\"" | ||
show (Bool True) = "#t" | ||
show (Bool False) = "#f" | ||
show c@(Cons a b) = "(" ++ showListInner c ++ ")" | ||
show Nil = "()" | ||
|
||
showListInner :: Expression -> String | ||
showListInner (Cons a b@(Cons _ _)) = show a ++ " " ++ showListInner b | ||
showListInner (Cons a Nil) = show a | ||
showListInner (Cons a b) = show a ++ " . " ++ showListInner b | ||
showListInner Nil = "" | ||
showListInner x = show x | ||
|
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 was deleted.
Oops, something went wrong.