Implement step 1
[jackhill/mal.git] / gst / util.st
CommitLineData
34aa5ced
VS
1OrderedCollection extend [
2 asDictionary [
3 | dict assoc |
4 dict := Dictionary new.
5 1 to: self size by: 2 do:
6 [ :i | dict add: (self at: i) -> (self at: i + 1) ].
7 ^dict
8 ]
9]
10
11String extend [
12 parse [
13 |text|
14 text := self copyFrom: 2 to: self size - 1.
15 text := text copyReplaceAll: '\"' with: '"'.
16 text := text copyReplaceAll: '\n' with: '
17'.
18 text := text copyReplaceAll: '\\' with: '\'.
19 ^text
20 ]
21
22 repr [
23 |text|
24 text := self copyReplaceAll: '\' with: '\\'.
25 text := text copyReplaceAll: '
26' with: '\n'.
27 text := text copyReplaceAll: '"' with: '\"'.
28 ^'"', text, '"'
29 ]
30]