compiler/PPCLL1Configuration.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 10 May 2015 14:20:24 +0100
changeset 454 a9cd5ea7cc36
parent 452 9f4558b3be66
child 459 4751c407bb40
permissions -rw-r--r--
Portability: fixes for Smalltalk/X * Do not use detect:ifFound: - not present in Smalltalk/X * Removed leftover debugging code (Halt if:, ...) * Do not use `aClass methods`, use `aClass methodDictionary values` * Do not use #allPairsDo; - not present in Smalltalk/X * Do not use #crShow: - not present in Smalltalk/X * On Smalltalk?X use Filename - there's no FileReference in Smalltalk/X * Do not use CharacterSet, use String

"{ Package: 'stx:goodies/petitparser/compiler' }"

"{ NameSpace: Smalltalk }"

PPCConfiguration subclass:#PPCLL1Configuration
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Core'
!

!PPCLL1Configuration methodsFor:'accessing'!

defaultArguments
 	^ PPCArguments default
		guards: false;
		yourself
! !

!PPCLL1Configuration methodsFor:'compiling'!

invokePhases
    self toPPCIr.
    self createTokens.
    self cacheFirstFollow.
    self createLL1Choices.
    self tokenize.

    "Merge duplicate tokens and recompute first follow"
    self merge.
    self cacheFirstFollow.

    self specialize.
    self createRecognizingComponents.
    self specialize.
    self inline.
    self merge.
    self check.	
    self generate.
! !

!PPCLL1Configuration methodsFor:'hooks'!

codeCompilerOn: args
    ^ PPCTokenizingCompiler on: args
!

codeGeneratorVisitorOn: compiler
    ^ PPCTokenizingCodeGenerator on: compiler
! !

!PPCLL1Configuration methodsFor:'phases'!

createLL1Choices
    ir :=  PPCLL1Visitor new
        arguments: arguments;
        visit: ir.
    self remember: #LL1
!

tokenize
    "
        This will try transform the parser into the tokenizing parser
    "
    arguments tokenize ifFalse: [ ^ self ] .
    
    ir :=  PPCTokenizingVisitor new
        arguments: arguments;
        visit: ir.
    self remember: #tokenize
! !