compiler/PPCInlineLiteralNode.st
changeset 438 20598d7ce9fa
parent 437 54b3bc9e3987
child 442 d333233f7ebd
child 452 9f4558b3be66
equal deleted inserted replaced
437:54b3bc9e3987 438:20598d7ce9fa
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
       
     4 
       
     5 PPCLiteralNode subclass:#PPCInlineLiteralNode
       
     6 	instanceVariableNames:''
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'PetitCompiler-Nodes'
       
    10 !
       
    11 
       
    12 !PPCInlineLiteralNode methodsFor:'compiling'!
       
    13 
       
    14 compileWith: compiler effect: effect id: id
       
    15 	| encodedLiteral |
       
    16 	
       
    17 	encodedLiteral := self encodeQuotes: literal.
       
    18 	compiler startInline: id.
       
    19 	compiler add: '((context peek: ', literal size asString, ') = #''', encodedLiteral, ''')'.
       
    20 	compiler indent.
       
    21 	compiler add: ' ifTrue: [ context skip: ', literal size asString, '. #''', encodedLiteral, ''']'.
       
    22 	compiler add: ' ifFalse: [ self error: ''', encodedLiteral,  ' expected'' ].'.
       
    23 	compiler dedent.
       
    24  ^ compiler stopInline.
       
    25 ! !
       
    26 
       
    27 !PPCInlineLiteralNode methodsFor:'printing'!
       
    28 
       
    29 asInlined
       
    30 	^ self
       
    31 !
       
    32 
       
    33 printOn: aStream
       
    34 	aStream nextPutAll: '#inline'.
       
    35 	super printOn: aStream
       
    36 ! !
       
    37