More useful semantics for proper-quoted string literals.

This commit is contained in:
Chris Pressey 2014-09-02 22:17:13 +01:00
parent dd5b1fa3bf
commit a2ed74b1f9
3 changed files with 5 additions and 4 deletions

View file

@ -864,11 +864,11 @@ that contains arbitrary text terminated by a sentinel.
### Multi-terminal sugar ###
The syntax `“abc”` (with the proper, oriented, opening and closing quotation
marks) is syntactic sugar for `"a" & "b" & "c"`.
marks) is syntactic sugar for `"a" & "b" & "c" & return 'abc'`.
| main = “appar”.
+ apparently
= r
= appar
| main = “appar”.
+ apple

View file

@ -71,7 +71,8 @@ tamsin_parser {
return call(prodref('$', return), list(atom(T), nil))
| pq_string → T &
$:unquote(T, '“', '”') → T &
expect_chars(T) → E & return E
expect_chars(T) → E &
return and(E, call(prodref('$', return), list(atom(T), nil)))
| prodref → P &
L ← nil &
["(" &

View file

@ -179,7 +179,7 @@ class Parser(EventProducer):
node = expect
else:
node = And(node, expect)
return node
return And(node, Call(Prodref('$', 'return'), [AtomNode(s)]))
elif self.consume(u'«') or self.consume('<<'):
t = self.texpr()
if self.consume(u'»') or self.consume('>>'):