compiler/PPCListNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 03 Nov 2014 11:30:59 +0000
changeset 407 a0e6299c7337
parent 392 9b297f0d949c
child 414 0eaf09920532
permissions -rw-r--r--
Removed unused / obsolete methods from PPToken * remove PPToken class>>on:start:stop * remove PPToken>>initializeOn:start:stop

"{ Package: 'stx:goodies/petitparser/compiler' }"

PPCNode subclass:#PPCListNode
	instanceVariableNames:'children'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Nodes'
!

!PPCListNode methodsFor:'accessing'!

children
	^ children
!

children: anObject
	
	children := anObject
! !

!PPCListNode methodsFor:'analysis'!

acceptsEpsilon
	self subclassResponsibility
!

acceptsEpsilonOpenSet: set
	self subclassResponsibility
!

replace: node with: anotherNode
	children keysAndValuesDo: [ :index :child |
		child == node ifTrue: [ children at: index put: anotherNode ] 
	]
! !

!PPCListNode methodsFor:'copying'!

postCopy
	super postCopy.
	children := children copy
! !

!PPCListNode methodsFor:'optimizing'!

inline: changeStatus
	| inlinedNode |
	self children do: [ :child |
		inlinedNode := child asInlined.
		(inlinedNode ~= child) ifTrue: [ 
			changeStatus change.
			^ self replace: child with: inlinedNode.
		]
	]
!

optimize: params status: changeStatus
	| retval |
	retval := self.
	retval := retval rewrite: params status: changeStatus.
	retval := retval inline: params status: changeStatus.
	
	^ retval
! !