--- a/compiler/PPCScanner.st Mon Aug 17 12:13:16 2015 +0100
+++ b/compiler/PPCScanner.st Mon Aug 24 15:34:14 2015 +0100
@@ -3,8 +3,8 @@
"{ NameSpace: Smalltalk }"
Object subclass:#PPCScanner
- instanceVariableNames:'match matchPosition matches tokens stream currentChar
- maxSymbolNumber position'
+ instanceVariableNames:'match matchPosition matches tokens currentChar maxSymbolNumber
+ position context'
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Scanner'
@@ -33,11 +33,11 @@
!
stream
- ^ stream
+ ^ context
!
stream: anObject
- stream := anObject
+ context := anObject
! !
!PPCScanner methodsFor:'initialization'!
@@ -55,7 +55,7 @@
reset
matchPosition := nil. "This flag says that multimode run the last time"
- position := stream position.
+ position := context position.
" matches := Array new: maxSymbolNumber."
!
@@ -76,7 +76,7 @@
matchPosition := -1. "this is a flag that the distnict mode was running"
" matches := nil."
- position := stream position.
+ position := context position.
! !
@@ -170,18 +170,32 @@
!PPCScanner methodsFor:'results - distinct'!
+recordDistinctFailure
+ match := nil.
+ matchPosition := position.
+ ^ false
+!
+
+recordDistinctFailure: matchValue
+ match := matchValue.
+ matchPosition := context position.
+ ^ false
+!
+
recordDistinctMatch: matchValue
match := matchValue.
- matchPosition := stream position.
+ matchPosition := context position.
+ ^ true
!
recordDistinctMatch: matchValue offset: offset
match := matchValue.
currentChar isNil ifFalse: [
- matchPosition := stream position - offset.
+ matchPosition := context position - offset.
] ifTrue: [
- matchPosition := stream position.
- ]
+ matchPosition := context position.
+ ].
+ ^ true
!
returnDistinct
@@ -199,14 +213,14 @@
!
recordMatch: index
- matches at: index put: stream position.
+ matches at: index put: context position.
!
recordMatch: index offset: offset
currentChar isNil ifFalse: [
- matches at: index put: stream position - offset.
+ matches at: index put: context position - offset.
] ifTrue: [
- matches at: index put: stream position.
+ matches at: index put: context position.
].
!
@@ -217,12 +231,14 @@
!PPCScanner methodsFor:'scanning'!
-next
- self error: 'deprecated?'.
- stream next
+back
+ currentChar isNil ifFalse: [
+ context skip: -1
+ ]
!
peek
+ self flag: 'inline this, do not call peek!!'.
^ currentChar
!
@@ -232,7 +248,7 @@
!
step
- currentChar := stream next
+ currentChar := context next
! !
!PPCScanner methodsFor:'testing'!