compiler/PPCTrimNode.st
changeset 452 9f4558b3be66
parent 438 20598d7ce9fa
child 515 b5316ef15274
--- a/compiler/PPCTrimNode.st	Thu Apr 30 23:43:14 2015 +0200
+++ b/compiler/PPCTrimNode.st	Sun May 10 06:28:36 2015 +0100
@@ -2,7 +2,7 @@
 
 "{ NameSpace: Smalltalk }"
 
-PPCDelegateNode subclass:#PPCTrimNode
+PPCSequenceNode subclass:#PPCTrimNode
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
@@ -11,13 +11,63 @@
 
 !PPCTrimNode methodsFor:'accessing'!
 
+child
+    
+    ^ children at: 2
+!
+
+child: anObject
+    
+    children at: 2 put: anObject
+!
+
 prefix
-	^ #trim
+    ^ #trim
+!
+
+trimmer
+    ^ children at: 1
+!
+
+trimmer: anObject
+    children at: 1 put: anObject
+! !
+
+!PPCTrimNode methodsFor:'analysis'!
+
+acceptsEpsilon
+    ^ self child acceptsEpsilonOpenSet: (IdentitySet with: self).
+!
+
+acceptsEpsilonOpenSet: set
+    (set includes: self child) ifFalse: [ 
+        set add: self child.
+        ^ self child acceptsEpsilonOpenSet: set 
+    ].
+    ^ false
+! !
+
+!PPCTrimNode methodsFor:'initialization'!
+
+defaultTrimmer
+    | message |
+    message := PPCMessagePredicateNode new 
+            message: #isSeparator;
+            yourself.
+    ^ PPCStarNode new
+        child: message;
+        yourself.
+!
+
+initialize
+    super initialize.
+    children := Array new: 2.
+    children at: 1 put: self defaultTrimmer.
 ! !
 
 !PPCTrimNode methodsFor:'visiting'!
 
 accept: visitor
-	^ visitor visitTrimNode: self
+    ^ visitor visitTrimNode: self
 ! !