git @ Cat's Eye Technologies Quylthulg / b283c4c
Decide that this is how we will handle $ when showing Str values. Chris Pressey 1 year, 4 months ago
2 changed file(s) with 14 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
8080
8181 instance Show Term where
8282 show (Int i) = show i
83 show (Str s) = "~" ++ "$" ++ s ++ "$"
83 show (Str s) = "~" ++ (if elem '$' s then (show s) else "$" ++ s ++ "$")
8484 show (Cons h t) = "[" ++ show h ++ showTail t
8585 where showTail Null = "]"
8686 showTail (Cons h t) = "," ++ show h ++ showTail t
44 exhaustive, but provides a basic sanity check that the language I've designed
55 here comes close to what I had in mind.
66
7 Note that, until March 2019, the Quylthulg reference interpreter displayed
8 the final result of running a Quylthulg program as a standard derived `show`
9 representation of its internal Haskell data structure. After March 2019,
10 it formats the result as a literal term in Quylthulg's concrete syntax.
11 Such terms can be round-tripped: when treated as Quylthulg programs themselves,
12 they will evaluate to themselves. (This is true in almost all cases.
13 Discovering the one case where it is not true is left as an exercise for the
14 reader.)
15
716 -> Tests for functionality "Interpret Quylthulg Program"
817
918 Integer expressions.
2130 String expressions.
2231 -------------------
2332
33 | ~$Hello, world!$
34 = ~$Hello, world!$
35
2436 | &~$Shoes are $&&~~&~$4.99 a pair$&&
25 = ~$Shoes are $4.99 a pair$
37 = ~"Shoes are $4.99 a pair"
2638
2739 List expressions.
2840 -----------------