A new version of Compiler was added to project The Inbox:
http://source.squeak.org/inbox/Compiler.quasiquote-eem.249.mcz==================== Summary ====================
Name: Compiler.quasiquote-eem.249
Author: eem
Time: 6 February 2013, 9:33:57.257 am
UUID: e3c0a389-e2f8-4b65-b611-4d09089f4237
Ancestors: Compiler.quasiquote-eem.248
New version that uses $ for escaping $ ` and [.
Add a quasi-quote form that allows convenient embedding
of substrings within a format string, and provides a
convenient way of embedding literal strings within an
alternative literal string whose string delimiter is different.
e.g.
`hello [#cruel] world!`
evaluates to
'hello cruel world'.
`S1[B1]...SN[BN]SN+1`
is equivalent to
{ 'S1'. [B1] value. ... 'SN'. [BN] value. 'SN+1' } concatenateQuasiQuote
where concatenateQuasiQuote sends asString to each
element and answers the concatenation of those elements.
however, single-statement blocks are inlined, so e.g. the
above `hello [#cruel] world!` is compiled as
{ 'hello '. #cruel. ' world!' } concatenateQuasiQuote
See Tests.quasiquote-eem.189 for tests and examples.
=============== Diff against Compiler.quasiquote-eem.248 ===============
Item was changed:
----- Method: MessageNode>>printQuasiQuoteOn:indent: (in category 'printing') -----
printQuasiQuoteOn: aStream indent: level
aStream nextPut: $`.
receiver elements do:
[:parseNode|
(parseNode isLiteralNode
and: [parseNode key class == 'literal' class])
ifTrue:
[parseNode key do:
[:char|
+ ('$`[' includes: char) ifTrue:
+ [aStream nextPut: $$].
- ('`[\' includes: char) ifTrue:
- [aStream nextPut: $\].
aStream nextPut: char]]
ifFalse:
[(parseNode isMessageNode
and: [parseNode selector key == #value
and: [parseNode receiver isBlockNode]])
ifTrue:
[parseNode receiver printOn: aStream indent: 0]
ifFalse:
[aStream nextPut: $[.
parseNode printOn: aStream indent: 0.
aStream nextPut: $]]]].
aStream nextPut: $`!
Item was changed:
----- Method: Parser>>scanQuasiQuoteCharactersUsing: (in category 'scanning') -----
scanQuasiQuoteCharactersUsing: stringStream
"Answer the next non-empty sequence of characters in a quasi-quote string, or nil, if none."
stringStream reset.
[hereChar ~~ $` and: [hereChar ~~ $[ and: [hereChar ~~ DoItCharacter]]] whileTrue:
+ [(hereChar == $$ and: ['`[$' includes: aheadChar])
- [hereChar == $\
ifTrue:
[stringStream nextPut: aheadChar. self step]
ifFalse:
[stringStream nextPut: hereChar].
self step].
self setHereTypeForQuasiQuote.
^stringStream position > 0 ifTrue:
[encoder encodeLiteral: stringStream contents]!