compiler/PPCPredicateNode.st
changeset 438 20598d7ce9fa
parent 422 116d2b2af905
child 452 9f4558b3be66
--- a/compiler/PPCPredicateNode.st	Tue Apr 21 17:20:11 2015 +0100
+++ b/compiler/PPCPredicateNode.st	Thu Apr 30 23:43:14 2015 +0200
@@ -9,76 +9,9 @@
 	category:'PetitCompiler-Nodes'
 !
 
-!PPCPredicateNode methodsFor:'as yet unclassified'!
-
-bodyOfPredicate: compiler
-	| id |
-	id := (compiler idFor: predicate prefixed: #predicate).
-	compiler addConstant: predicate as: id.
-
-	compiler addOnLine: '(context atEnd not and: [ ', id , ' value: context uncheckedPeek])'.
-	compiler indent.
-	compiler add: 'ifFalse: [ self error: ''predicate not found'' ]'.
-	compiler add: 'ifTrue: [ context next ].'.
-	compiler dedent.	
-!
-
-rewrite: changeStatus
-	| charSet |
-	
-	(predicate class == PPCharSetPredicate) ifTrue: [ 
-		charSet := predicate.
-	].
-	charSet := PPCharSetPredicate on: predicate.
-	
-	(charSet equals: (PPCharSetPredicate on: [ :char | char isLetter])) ifTrue: [ 
-		changeStatus change.
-		^ PPCMessagePredicateNode new
-			name: name;
-			message: #isLetter;
-			predicate: predicate;
-			yourself
-	].
+!PPCPredicateNode methodsFor:'visiting'!
 
-	(charSet equals: (PPCharSetPredicate on: [ :char | char isDigit])) ifTrue: [ 
-		changeStatus change.
-		^ PPCMessagePredicateNode new
-			name: name;
-			message: #isDigit;
-			predicate: predicate;
-			yourself
-	].
-
-	(charSet equals: (PPCharSetPredicate on: [ :char | char isAlphaNumeric])) ifTrue: [ 
-		changeStatus change.
-		^ PPCMessagePredicateNode new
-			name: name;
-			message: #isAlphaNumeric;
-			predicate: predicate;
-			yourself
-	].
-
-	(charSet equals: (PPCharSetPredicate on: [ :char | char isSeparator])) ifTrue: [ 
-		changeStatus change.
-		^ PPCMessagePredicateNode new
-			name: name;
-			message: #isSeparator;
-			predicate: predicate;
-			yourself
-	].
-
-
-	(charSet equals: (PPCharSetPredicate on: [ :char | true ])) ifTrue: [ 
-		changeStatus change.
-		^ PPCAnyNode new
-			name: name;
-			yourself
-	].
-
-	changeStatus change.
-	^ PPCCharSetPredicateNode new
-		name: name;
-		predicate: charSet;
-		yourself.
+accept: visitor
+	^ visitor visitPredicateNode: self
 ! !