|
1 "{ Package: 'stx:goodies/petitparser/compiler' }" |
|
2 |
|
3 PPCAbstractLiteralNode subclass:#PPCInlineLiteralNode |
|
4 instanceVariableNames:'' |
|
5 classVariableNames:'' |
|
6 poolDictionaries:'' |
|
7 category:'PetitCompiler-Nodes' |
|
8 ! |
|
9 |
|
10 PPCInlineLiteralNode comment:'' |
|
11 ! |
|
12 |
|
13 !PPCInlineLiteralNode methodsFor:'compiling'! |
|
14 |
|
15 compileWith: compiler effect: effect id: id |
|
16 | encodedLiteral | |
|
17 |
|
18 encodedLiteral := self encodeQuotes: literal. |
|
19 compiler startInline: id. |
|
20 compiler add: '((context peek: ', literal size asString, ') = #''', encodedLiteral, ''')'. |
|
21 compiler indent. |
|
22 compiler add: ' ifTrue: [ context skip: ', literal size asString, '. #''', encodedLiteral, ''']'. |
|
23 compiler add: ' ifFalse: [ self error: ''', encodedLiteral, ' expected'' ].'. |
|
24 compiler dedent. |
|
25 ^ compiler stopInline. |
|
26 ! |
|
27 |
|
28 inlineWith: compiler id: id |
|
29 | encodedLiteral | |
|
30 |
|
31 encodedLiteral := self encodeQuotes: literal. |
|
32 compiler startInline: id. |
|
33 compiler add: '((context peek: ', literal size asString, ') = #''', encodedLiteral, ''')'. |
|
34 compiler indent. |
|
35 compiler add: ' ifTrue: [ context skip: ', literal size asString, '. #''', encodedLiteral, ''']'. |
|
36 compiler add: ' ifFalse: [ self error: ''', encodedLiteral, ' expected'' ].'. |
|
37 compiler dedent. |
|
38 ^ compiler stopInline. |
|
39 ! ! |
|
40 |
|
41 !PPCInlineLiteralNode methodsFor:'printing'! |
|
42 |
|
43 printOn: aStream |
|
44 aStream nextPutAll: '#inline'. |
|
45 super printOn: aStream |
|
46 ! ! |
|
47 |