PPFailure.st
changeset 0 739fe9b7253e
child 4 90de244a7fa2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PPFailure.st	Thu Aug 18 20:56:17 2011 +0200
@@ -0,0 +1,63 @@
+"{ Package: 'squeak:petitparser' }"
+
+Object subclass:#PPFailure
+	instanceVariableNames:'message position'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitParser-Core'
+!
+
+PPFailure comment:'The failure object in PetitParser. It is the only class that responds to #isPetitFailure with true. It contains an error message and a position of the occurrence of the failure.
+Instance Variables:
+	message	<String>	The error message of this failure.
+	position	<Integer>	The position of this failure in the input stream.
+'
+!
+
+
+!PPFailure class methodsFor:'instance creation'!
+
+message: aString at: anInteger
+	^ self basicNew initializeMessage: aString at: anInteger
+! !
+
+!PPFailure methodsFor:'accessing'!
+
+message
+	"Answer a human readable error message of this parse failure."
+	
+	^ message
+!
+
+position
+	"Answer the position in the source string that caused this parse failure."
+
+	^ position
+! !
+
+!PPFailure methodsFor:'initialization'!
+
+initializeMessage: aString at: anInteger
+	message := aString.
+	position := anInteger
+! !
+
+!PPFailure methodsFor:'printing'!
+
+printOn: aStream
+	aStream nextPutAll: self message; nextPutAll: ' at '; print: position
+! !
+
+!PPFailure methodsFor:'testing'!
+
+isPetitFailure
+	"I am the only class that should implement this method to return true."
+
+	^ true
+! !
+
+!PPFailure class methodsFor:'documentation'!
+
+version_SVN
+    ^ '$Id: PPFailure.st,v 1.1 2011-08-18 18:56:17 cg Exp $'
+! !