--- a/PPFailure.st Fri Oct 03 01:59:10 2014 +0100
+++ b/PPFailure.st Fri Oct 03 02:33:08 2014 +0100
@@ -1,7 +1,7 @@
"{ Package: 'stx:goodies/petitparser' }"
Object subclass:#PPFailure
- instanceVariableNames:'message position'
+ instanceVariableNames:'message context position'
classVariableNames:''
poolDictionaries:''
category:'PetitParser-Core'
@@ -10,8 +10,21 @@
!PPFailure class methodsFor:'instance creation'!
+message: aString
+ ^ self basicNew initializeMessage: aString
+!
+
message: aString at: anInteger
+ "One should not use this method if the furthest failure is supposed to be reported correctly"
^ self basicNew initializeMessage: aString at: anInteger
+!
+
+message: aString context: aPPContext
+ ^ self basicNew initializeMessage: aString context: aPPContext
+!
+
+message: aString context: aPPContext at: position
+ ^ self basicNew initializeMessage: aString context: aPPContext position: position
! !
!PPFailure methodsFor:'accessing'!
@@ -30,15 +43,33 @@
!PPFailure methodsFor:'initialization'!
+initializeMessage: aString
+ message := aString.
+!
+
initializeMessage: aString at: anInteger
+ "One should not use this method if the furthest failure is supposed to be reported correctly"
message := aString.
- position := anInteger
+ position := anInteger.
+!
+
+initializeMessage: aString context: aPPContext
+ self initializeMessage: aString context: aPPContext position: aPPContext position
+!
+
+initializeMessage: aString context: aPPContext position: anInteger
+ message := aString.
+ context := aPPContext.
+ position := anInteger.
+
+ "record the furthest failure encountered while parsing the input stream "
+ aPPContext noteFailure: self.
! !
!PPFailure methodsFor:'printing'!
printOn: aStream
- aStream nextPutAll: self message; nextPutAll: ' at '; print: position
+ aStream nextPutAll: self message; nextPutAll: ' at '; print: self position
! !
!PPFailure methodsFor:'testing'!
@@ -62,3 +93,4 @@
version_SVN
^ '§Id: PPFailure.st 2 2010-12-17 18:44:23Z vranyj1 §'
! !
+