From 649319b1dafb130801638c5a156e37d9e865ba5c Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 29 Jan 2022 23:11:03 +0200 Subject: Implement strings as phrases of chars --- src/ltypes.hs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/ltypes.hs (limited to 'src/ltypes.hs') diff --git a/src/ltypes.hs b/src/ltypes.hs new file mode 100644 index 0000000..bb7e0de --- /dev/null +++ b/src/ltypes.hs @@ -0,0 +1,24 @@ +module LTypes where + +import Utils + +data LWord + = LSymbol String + | LInteger Integer + | LFloat Double + | LBool Bool + | LChar Char + | LLabel String + | LStringLitRef String + | LPhrase [LWord] + deriving (Show, Eq) + +reprWord :: LWord -> String +reprWord (LSymbol a) = a +reprWord (LInteger a) = show a +reprWord (LFloat a) = show a +reprWord (LBool a) = show a +reprWord (LChar a) = show a +reprWord (LLabel a) = a +reprWord (LStringLitRef a) = "StrLit(" ++ a ++ ")" +reprWord (LPhrase a) = "P[ " ++ map reprWord a $> unwords ++ " ]" -- cgit v1.3