compiler/PPCTokenActionNode.st
changeset 421 7e08b31e0dae
child 422 116d2b2af905
equal deleted inserted replaced
420:b2f2f15cef26 421:7e08b31e0dae
       
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
       
     2 
       
     3 PPCActionNode subclass:#PPCTokenActionNode
       
     4 	instanceVariableNames:''
       
     5 	classVariableNames:''
       
     6 	poolDictionaries:''
       
     7 	category:'PetitCompiler-Nodes'
       
     8 !
       
     9 
       
    10 !PPCTokenActionNode methodsFor:'as yet unclassified'!
       
    11 
       
    12 asFast
       
    13 	^ self
       
    14 !
       
    15 
       
    16 compileWith: compiler effect: effect id: id
       
    17 	|  |
       
    18 	compiler addConstant: block as: id.
       
    19 
       
    20 	"
       
    21 		Actually, do nothing, we are in Token mode and the 
       
    22 		child does not return any result and token takes only
       
    23 		the input value.
       
    24 	"	
       
    25 	compiler startMethod: id.
       
    26 	compiler add: '^ '.
       
    27 	compiler callOnLine: (child compileWith: compiler).
       
    28  ^ compiler stopMethod.
       
    29 !
       
    30 
       
    31 rewrite: changeStatus
       
    32 	(self hasProperty: #trimmingToken) ifTrue: [ 
       
    33 		| retval |
       
    34 		changeStatus change.
       
    35 		"Get rid of action and sequence with whitespace"
       
    36 		retval := child children second child. 	"JK: oups, what a chain!!"
       
    37 		retval name ifNil: [ retval name: self name ].
       
    38 		^ retval
       
    39 	].
       
    40 
       
    41 	child name ifNil: [  
       
    42 		changeStatus change.
       
    43 		child name: self name.
       
    44 		^ child
       
    45 	].
       
    46 
       
    47 	(child name = self name) ifTrue: [ 
       
    48 		changeStatus change.
       
    49 		^ child
       
    50 	]
       
    51 !
       
    52 
       
    53 suffix
       
    54 	^ '_fast'
       
    55 ! !
       
    56