@@ -21,28 +21,19 @@ stringToken (c : cs) cur = case c of
2121 )
2222 _ -> stringToken cs (cur ++ [c])
2323
24- compactLambda :: String -> String -> (String , String )
25- compactLambda [] _ = error " Tokenize error in compactLambda"
26- compactLambda (c : cs) cur = case c of
27- ' }' -> ((' {' : cur) ++ [' }' ], cs)
28- _ -> compactLambda cs (cur ++ [c])
29-
3024tokenize' :: String -> [String ] -> String -> [String ]
3125tokenize' cur tokens (c : cs) = case c of
3226 ' (' -> tokenize' " " (" (" : add' cur tokens) cs
3327 ' )' -> tokenize' " " (" )" : add' cur tokens) cs
28+ ' {' -> tokenize' " " (" {" : add' cur tokens) cs
29+ ' }' -> tokenize' " " (" }" : add' cur tokens) cs
3430 ' \' ' -> tokenize' " " (" '" : add' cur tokens) cs
3531 ' ,' -> tokenize' " " (" ," : add' cur tokens) cs
3632 ' "' -> tokenize' " " newTokens newCs
3733 where
3834 new = stringToken cs " "
3935 newTokens = fst new : tokens
4036 newCs = snd new
41- ' {' -> tokenize' " " newTokens newCs
42- where
43- new = compactLambda cs " "
44- newTokens = fst new : tokens
45- newCs = snd new
4637 _ ->
4738 if isSpace c
4839 then tokenize' " " (add' cur tokens) cs
@@ -98,6 +89,11 @@ parse' stack (t : ts) = case t of
9889 " (" -> parse' (Pair (head stack) (head tl) : tail tl) ts
9990 where
10091 tl = tail stack
92+ " }" -> parse' (Nil : stack) ts
93+ " {" ->
94+ let h = head stack
95+ tl = tail stack
96+ in parse' (Pair (Name " compact" ) h : tl) (" (" : ts)
10197 " ," ->
10298 let h = head stack
10399 el = fst'' h
0 commit comments