PPCConfiguration refactoring: [4/10]: introduced a class - PPCPass
... representing a compilation pass over the PPCNode tree.
The pass has a common api method: #run:in: which is not used in
PPCConfiguration. This simplifed the code and removed some code
duplication.
"{ Package: 'stx:goodies/petitparser/compiler' }"
"{ NameSpace: Smalltalk }"
PPCConfiguration subclass:#PPCUniversalConfiguration
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Core'
!
!PPCUniversalConfiguration methodsFor:'compiling'!
initialize
super initialize.
"Modified: / 25-08-2015 / 00:03:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
invokePhases
self toPPCIr.
self createTokens.
self cacheFirstFollow.
self specialize.
self createRecognizingComponents.
self specialize.
self inline.
self merge.
self check.
self generate.
! !
!PPCUniversalConfiguration methodsFor:'error handling'!
buildClass
| builder |
self assert:(context parserClass isKindOf:PPCClass).
builder := PPCClassBuilder new.
builder compiledClassName:context options parserName.
builder compiledSuperclass:PPCompiledParser.
builder methodDictionary:context parserClass methodDictionary.
builder constants:context parserClass constants.
^ builder compileClass.
"Modified: / 25-08-2015 / 00:04:08 / Jan Vrany <jan.vrany@fit."
"Modified: / 26-08-2015 / 20:01:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
generate
| compiledParser |
context options generate ifFalse:[
^ self
].
self runPass: PPCUniversalCodeGenerator.
compiledParser := self buildClass.
compiledParser startSymbol:(context parserClass propertyAt:#rootMethod) methodName.
compiledParser := compiledParser new.
ir := compiledParser.
"Modified: / 25-08-2015 / 00:03:46 / Jan Vrany <jan.vr"
"Modified: / 26-08-2015 / 22:50:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPCUniversalConfiguration class methodsFor:'documentation'!
version
^ 'Path: stx/goodies/petitparser/compiler/PPCUniversalConfiguration.st, Version: 1.0, User: jv, Time: 2015-08-26T20:03:52.218+01'
!
version_HG
^ 'Path: stx/goodies/petitparser/compiler/PPCUniversalConfiguration.st, Version: 1.0, User: jv, Time: 2015-08-26T20:03:52.218+01'
! !