PPActionParser.st
changeset 0 739fe9b7253e
child 4 90de244a7fa2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PPActionParser.st	Thu Aug 18 20:56:17 2011 +0200
@@ -0,0 +1,50 @@
+"{ Package: 'squeak:petitparser' }"
+
+PPDelegateParser subclass:#PPActionParser
+	instanceVariableNames:'block'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitParser-Parsers'
+!
+
+PPActionParser comment:'A parser that performs an action block with the successful parse result of the delegate.
+Instance Variables:
+	block	<BlockClosure>	The action block to be executed.
+'
+!
+
+
+!PPActionParser class methodsFor:'instance creation'!
+
+on: aParser block: aBlock
+	^ (self on: aParser) setBlock: aBlock
+! !
+
+!PPActionParser methodsFor:'accessing'!
+
+block
+	"Answer the action block of the receiver."
+
+	^ block
+! !
+
+!PPActionParser methodsFor:'initialization'!
+
+setBlock: aBlock
+	block := aBlock
+! !
+
+!PPActionParser methodsFor:'parsing'!
+
+parseOn: aStream
+	| element |
+	^ (element := parser parseOn: aStream) isPetitFailure
+		ifFalse: [ block value: element ]
+		ifTrue: [ element ]
+! !
+
+!PPActionParser class methodsFor:'documentation'!
+
+version_SVN
+    ^ '$Id: PPActionParser.st,v 1.1 2011-08-18 18:56:17 cg Exp $'
+! !