PPParser.st
changeset 381 0bbbcf5da2d4
parent 377 6112a403a52d
child 389 009c2e13973c
--- a/PPParser.st	Sun Oct 05 00:05:20 2014 +0100
+++ b/PPParser.st	Sat Oct 04 21:26:15 2014 +0100
@@ -24,7 +24,6 @@
 
 
 
-
 !PPParser methodsFor:'accessing'!
 
 children
@@ -133,6 +132,34 @@
 	properties := properties copy
 ! !
 
+!PPParser methodsFor:'enumerating'!
+
+allParsers
+	"Answer all the parse nodes of the receiver."
+
+	| result |
+	result := OrderedCollection new.
+	self allParsersDo: [ :parser | result addLast: parser ].
+	^ result
+!
+
+allParsersDo: aBlock
+	"Iterate over all the parse nodes of the receiver."
+
+	self allParsersDo: aBlock seen: IdentitySet new
+!
+
+allParsersDo: aBlock seen: aSet
+	"Iterate over all the parse nodes of the receiver, do not visit and follow the ones contained in aSet."
+
+	(aSet includes: self)
+		ifTrue: [ ^ self ].
+	aSet add: self.
+	aBlock value: self.
+	self children
+		do: [ :each | each allParsersDo: aBlock seen: aSet ]
+! !
+
 !PPParser methodsFor:'initialization'!
 
 initialize