git @ Cat's Eye Technologies Tamsin / 42cf57e
Implement proper-quotes in Tamsin-in-Tamsin compiler. Chris Pressey 10 years ago
2 changed file(s) with 22 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
0 main = set T = 'foobar' &
1 print T &
2 expect_chars(T).
3
4 # Given a single-character string, return call(prodref('$', 'expect'), S)
5 # Given a string, return and(call(prodref('$', 'expect'), head(S)),
6 # expect_chars(tail(S))).
7
8 expect_chars(S) = print S & expect_chars_r @ S.
9 expect_chars_r = any → C &
10 set E = call(prodref('$', 'expect'), list(atom(C), nil)) &
11 ((eof & return E) | (expect_chars_r → R & return and(E, R))).
7070 return call(prodref('$', return), list(atom(T), nil))
7171 | pq_string → T &
7272 $:unquote(T, '“', '”') → T &
73 ########## XXX this is not correct yet
74 return call(prodref('$', return), list(atom(T), nil))
73 expect_chars(T) → E & return E
7574 | prodref → P &
7675 L ← nil &
7776 ["(" &
150149 Acc ← constructor(list, list(Fst, list(Acc, nil))) &
151150 reverse_c(Snd, Acc).
152151 reverse_c(Other, Acc) = Acc.
152
153 # Given a single-character string, return call(prodref('$', 'expect'), S)
154 # Given a string, return and(call(prodref('$', 'expect'), head(S)),
155 # expect_chars(tail(S))).
156
157 expect_chars(S) = (expect_chars_r using $:utf8) @ S.
158 expect_chars_r = any → C &
159 E ← call(prodref('$', 'expect'), list(atom(C), nil)) &
160 ((eof & return E) | (expect_chars_r → R & return and(E, R))).
153161 }