compiler/PPCDelegateNode.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:#PPCDelegateNode
       
     4 	instanceVariableNames:'child'
       
     5 	classVariableNames:''
       
     6 	poolDictionaries:''
       
     7 	category:'PetitCompiler-Nodes'
       
     8 !
       
     9 
       
    10 PPCDelegateNode comment:''
       
    11 !
       
    12 
       
    13 
       
    14 !PPCDelegateNode methodsFor:'accessing'!
       
    15 
       
    16 child
       
    17 	^ child
       
    18 !
       
    19 
       
    20 child: whatever
       
    21 	child := whatever 
       
    22 !
       
    23 
       
    24 children
       
    25 	^ { child }
       
    26 ! !
       
    27 
       
    28 !PPCDelegateNode methodsFor:'analysis'!
       
    29 
       
    30 acceptsEpsilon
       
    31 	^ child acceptsEpsilonOpenSet: (IdentitySet with: self).
       
    32 !
       
    33 
       
    34 acceptsEpsilonOpenSet: set
       
    35 	(set includes: child) ifFalse: [ 
       
    36 		set add: child.
       
    37 		^ child acceptsEpsilonOpenSet: set 
       
    38 	].
       
    39 	^ false
       
    40 ! !
       
    41 
       
    42 !PPCDelegateNode methodsFor:'optimizing'!
       
    43 
       
    44 inline: changeStatus	
       
    45 	| inlinedNode |
       
    46 	inlinedNode := child asInlined.
       
    47 	(inlinedNode ~= child) ifTrue: [ 
       
    48 		changeStatus change.
       
    49 		self replace: child with: inlinedNode.
       
    50 	]
       
    51 !
       
    52 
       
    53 optimize: params status: changeStatus
       
    54 	| retval |
       
    55 	retval := self.
       
    56 	
       
    57 	retval := retval rewrite: params status: changeStatus.
       
    58 	retval := retval inline: params status: changeStatus.
       
    59 	
       
    60 	^ retval
       
    61 ! !
       
    62 
       
    63 !PPCDelegateNode methodsFor:'transformation'!
       
    64 
       
    65 replace: node with: anotherNode
       
    66 	child == node ifTrue: [ child := anotherNode ]
       
    67 ! !
       
    68 
       
    69 !PPCDelegateNode class methodsFor:'documentation'!
       
    70 
       
    71 version_HG
       
    72 
       
    73     ^ '$Changeset: <not expanded> $'
       
    74 ! !
       
    75