compiler/PPCListNode.st
changeset 391 553a5456963b
child 392 9b297f0d949c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compiler/PPCListNode.st	Sun Oct 26 01:03:31 2014 +0000
@@ -0,0 +1,68 @@
+"{ Package: 'stx:goodies/petitparser/compiler' }"
+
+PPCNode subclass:#PPCListNode
+	instanceVariableNames:'children'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitCompiler-Nodes'
+!
+
+PPCListNode comment:''
+!
+
+!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
+! !
+