compiler/PPCAbstractLiteralNode.st
changeset 391 553a5456963b
child 392 9b297f0d949c
equal deleted inserted replaced
390:17ba167b8ee1 391:553a5456963b
       
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
       
     2 
       
     3 PPCNode subclass:#PPCAbstractLiteralNode
       
     4 	instanceVariableNames:'literal'
       
     5 	classVariableNames:''
       
     6 	poolDictionaries:''
       
     7 	category:'PetitCompiler-Nodes'
       
     8 !
       
     9 
       
    10 PPCAbstractLiteralNode comment:''
       
    11 !
       
    12 
       
    13 !PPCAbstractLiteralNode methodsFor:'accessing'!
       
    14 
       
    15 acceptsEpsilon
       
    16 	^ literal size = 0
       
    17 !
       
    18 
       
    19 firstCharParser
       
    20 	^ literal first asParser
       
    21 !
       
    22 
       
    23 literal
       
    24 	
       
    25 	^ literal
       
    26 !
       
    27 
       
    28 literal: anObject
       
    29 	
       
    30 	literal := anObject
       
    31 !
       
    32 
       
    33 prefix
       
    34 	^ #lit
       
    35 ! !
       
    36 
       
    37 !PPCAbstractLiteralNode methodsFor:'compiling'!
       
    38 
       
    39 encodeQuotes: string
       
    40 	| x s |
       
    41 	s := WriteStream on: ''.
       
    42 	1 to: string size do: [ :i|
       
    43 		s nextPut: (x := string at: i).
       
    44 		x = $' ifTrue: [ s nextPut: x ].
       
    45 	].
       
    46 	^ s contents
       
    47 ! !
       
    48