Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Name: PetitCompiler-JanVrany.135
Author: JanVrany
Time: 22-07-2015, 06:53:29.127 PM
UUID: 890178b5-275d-46af-a2ad-1738998f07cb
Ancestors: PetitCompiler-JanVrany.134
Name: PetitCompiler-Tests-JanKurs.93
Author: JanKurs
Time: 20-07-2015, 11:30:10.283 PM
UUID: 6473e671-ad70-42ca-b6c3-654b78edc531
Ancestors: PetitCompiler-Tests-JanKurs.92
Name: PetitCompiler-Extras-Tests-JanVrany.16
Author: JanVrany
Time: 22-07-2015, 05:18:22.387 PM
UUID: 8f6f9129-dbba-49b1-9402-038470742f98
Ancestors: PetitCompiler-Extras-Tests-JanKurs.15
Name: PetitCompiler-Benchmarks-JanKurs.12
Author: JanKurs
Time: 06-07-2015, 02:10:06.901 PM
UUID: cb24f1ac-46a4-494d-9780-64576f0f0dba
Ancestors: PetitCompiler-Benchmarks-JanKurs.11, PetitCompiler-Benchmarks-JanVrany.e29bd90f388e.20150619081300
"{ Package: 'stx:goodies/petitparser/compiler' }"
"{ NameSpace: Smalltalk }"
PPCompiledParser subclass:#PPTokenizingCompiledParser
instanceVariableNames:'currentTokenValue currentTokenType scanner'
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Parsers'
!
!PPTokenizingCompiledParser methodsFor:'tokenizing'!
consume: tokenType
self halt: 'deprecated'.
(self perform: tokenType) ifTrue: [
currentTokenType := nil.
^ currentTokenValue.
].
"self error: 'expected: ', tokenType storeString, ' got ', currentTokenType storeString."
self error.
!
consumeWhitespace
self shouldBeImplemented
!
currentTokenType
currentTokenType isNil ifTrue: [ self nextToken ].
^ currentTokenType
!
currentTokenTypeIs: tokenType
"if the type is read"
self halt: 'deprecated'.
currentTokenType isNil ifFalse: [ ^ currentTokenType = tokenType ].
"if not, try to read the token"
^ self perform: tokenType.
!
currentTokenValue
currentTokenType isNil ifTrue: [ self nextToken ].
^ currentTokenType
!
nextToken
self shouldBeImplemented
!
parseOn: aPPContext
| retval |
context := aPPContext.
context compiledParser: self.
failure := PPFailure new message: nil; context: context; position: -1.
context noteFailure: failure.
error := false.
currentTokenType := nil.
scanner := PPCScanner new.
self consumeWhitespace.
retval := self perform: startSymbol.
" self consumeWhitespace."
(retval isPetitFailure) ifTrue: [ aPPContext noteFailure: failure ].
error ifTrue: [ aPPContext noteFailure: failure. retval := failure ].
" aPPContext position: context position."
^ retval
! !