--- a/PPContext.st Mon Apr 13 14:19:55 2015 +0100
+++ b/PPContext.st Mon Apr 13 22:00:44 2015 +0100
@@ -1,7 +1,9 @@
"{ Package: 'stx:goodies/petitparser' }"
+"{ NameSpace: Smalltalk }"
+
Object subclass:#PPContext
- instanceVariableNames:'stream root properties globals'
+ instanceVariableNames:'stream root properties globals furthestFailure'
classVariableNames:''
poolDictionaries:''
category:'PetitParser-Core'
@@ -17,8 +19,6 @@
yourself
! !
-
-
!PPContext methodsFor:'accessing-globals'!
globalAt: aKey
@@ -140,16 +140,16 @@
furthestFailure
" the furthest failure encountered while parsing the input stream "
- ^ self globalAt: #furthestFailure ifAbsent: [ nil ]
+ "^ self globalAt: #furthestFailure ifAbsent: [ nil ]"
+ "performance optimization:"
+ ^ furthestFailure
!
noteFailure: aPPFailure
"record the furthest failure encountered while parsing the input stream "
- | furthestFailure |
- furthestFailure := self furthestFailure.
( furthestFailure isNil or: [ aPPFailure position > furthestFailure position ])
- ifTrue: [ self globalAt: #furthestFailure put: aPPFailure ].
+ ifTrue: [ furthestFailure := aPPFailure ].
! !
!PPContext methodsFor:'initialization'!
@@ -211,6 +211,15 @@
]
! !
+!PPContext methodsFor:'printing'!
+
+printOn: aStream
+ super printOn: aStream.
+ aStream nextPut: $:.
+ aStream nextPut: $ .
+ stream printOn: aStream
+! !
+
!PPContext methodsFor:'stream mimicry'!
atEnd