PPConditionalParser.st
changeset 427 a7f5e6de19d2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PPConditionalParser.st	Mon Apr 13 22:00:44 2015 +0100
@@ -0,0 +1,33 @@
+"{ Package: 'stx:goodies/petitparser' }"
+
+"{ NameSpace: Smalltalk }"
+
+PPDelegateParser subclass:#PPConditionalParser
+	instanceVariableNames:'block'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitParser-Parsers'
+!
+
+!PPConditionalParser class methodsFor:'as yet unclassified'!
+
+on: aPPParser block: block
+	^ (PPConditionalParser on: aPPParser)
+		block: block;
+		yourself
+! !
+
+!PPConditionalParser methodsFor:'accessing'!
+
+block: aBlock
+	block := aBlock
+! !
+
+!PPConditionalParser methodsFor:'parsing'!
+
+parseOn: aPPContext
+	^ (block value: aPPContext) 
+		ifTrue: [ parser parseOn: aPPContext ]
+		ifFalse: [ PPFailure message: block asString, ' was not evaluated to true.' context: aPPContext ]
+! !
+