PPEndOfInputParser.st
changeset 0 739fe9b7253e
child 4 90de244a7fa2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PPEndOfInputParser.st	Thu Aug 18 20:56:17 2011 +0200
@@ -0,0 +1,39 @@
+"{ Package: 'squeak:petitparser' }"
+
+PPDelegateParser subclass:#PPEndOfInputParser
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitParser-Parsers'
+!
+
+PPEndOfInputParser comment:'A parser that succeeds only at the end of the input stream.'
+!
+
+
+!PPEndOfInputParser methodsFor:'operations'!
+
+end
+	^ self
+! !
+
+!PPEndOfInputParser methodsFor:'parsing'!
+
+parseOn: aStream
+	| position result |
+	position := aStream position.
+	result := parser parseOn: aStream.
+	(result isPetitFailure or: [ aStream atEnd ])
+		ifTrue: [ ^ result ].
+	result := PPFailure
+		message: 'end of input expected'
+		at: aStream position.
+	aStream position: position.
+	^ result
+! !
+
+!PPEndOfInputParser class methodsFor:'documentation'!
+
+version_SVN
+    ^ '$Id: PPEndOfInputParser.st,v 1.1 2011-08-18 18:56:17 cg Exp $'
+! !