compiler/PPCInlineLiteralNode.st
changeset 422 116d2b2af905
parent 421 7e08b31e0dae
equal deleted inserted replaced
421:7e08b31e0dae 422:116d2b2af905
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
     2 
     4 
     3 PPCLiteralNode subclass:#PPCInlineLiteralNode
     5 PPCLiteralNode subclass:#PPCInlineLiteralNode
     4 	instanceVariableNames:''
     6 	instanceVariableNames:''
     5 	classVariableNames:''
     7 	classVariableNames:''
     6 	poolDictionaries:''
     8 	poolDictionaries:''
     8 !
    10 !
     9 
    11 
    10 !PPCInlineLiteralNode methodsFor:'compiling'!
    12 !PPCInlineLiteralNode methodsFor:'compiling'!
    11 
    13 
    12 compileWith: compiler effect: effect id: id
    14 compileWith: compiler effect: effect id: id
    13 	| encodedLiteral |
       
    14 	
       
    15 	encodedLiteral := self encodeQuotes: literal.
       
    16 	compiler startInline: id.
       
    17 	compiler add: '((context peek: ', literal size asString, ') = #''', encodedLiteral, ''')'.
       
    18 	compiler indent.
       
    19 	compiler add: ' ifTrue: [ context skip: ', literal size asString, '. #''', encodedLiteral, ''']'.
       
    20 	compiler add: ' ifFalse: [ self error: ''', encodedLiteral,  ' expected'' ].'.
       
    21 	compiler dedent.
       
    22  ^ compiler stopInline.
       
    23 !
       
    24 
       
    25 inlineWith: compiler id: id
       
    26 	| encodedLiteral |
    15 	| encodedLiteral |
    27 	
    16 	
    28 	encodedLiteral := self encodeQuotes: literal.
    17 	encodedLiteral := self encodeQuotes: literal.
    29 	compiler startInline: id.
    18 	compiler startInline: id.
    30 	compiler add: '((context peek: ', literal size asString, ') = #''', encodedLiteral, ''')'.
    19 	compiler add: '((context peek: ', literal size asString, ') = #''', encodedLiteral, ''')'.