compiler/PPCLL1Configuration.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 20 May 2015 16:47:52 +0100
changeset 463 d4014e0a47a0
parent 459 4751c407bb40
permissions -rw-r--r--
Small improvement in inlining: inline child of an action node.

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

"{ NameSpace: Smalltalk }"

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

!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
! !