compiler/PPCLL1Configuration.st
changeset 465 f729f6cd3c76
parent 463 d4014e0a47a0
parent 464 f6d77fee9811
child 466 ac2d987a03d3
equal deleted inserted replaced
463:d4014e0a47a0 465:f729f6cd3c76
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
       
     4 
       
     5 PPCConfiguration subclass:#PPCLL1Configuration
       
     6 	instanceVariableNames:''
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'PetitCompiler-Core'
       
    10 !
       
    11 
       
    12 !PPCLL1Configuration methodsFor:'compiling'!
       
    13 
       
    14 invokePhases
       
    15     self toPPCIr.
       
    16     self createTokens.
       
    17     self cacheFirstFollow.
       
    18     self createLL1Choices.
       
    19     self tokenize.
       
    20 
       
    21     "Merge duplicate tokens and recompute first follow"
       
    22     self merge.
       
    23     self cacheFirstFollow.
       
    24 
       
    25     self specialize.
       
    26     self createRecognizingComponents.
       
    27     self specialize.
       
    28     self inline.
       
    29     self merge.
       
    30     self check.	
       
    31     self generate.
       
    32 ! !
       
    33 
       
    34 !PPCLL1Configuration methodsFor:'hooks'!
       
    35 
       
    36 codeCompilerOn: args
       
    37     ^ PPCTokenizingCompiler on: args
       
    38 !
       
    39 
       
    40 codeGeneratorVisitorOn: compiler
       
    41     ^ PPCTokenizingCodeGenerator on: compiler
       
    42 ! !
       
    43 
       
    44 !PPCLL1Configuration methodsFor:'phases'!
       
    45 
       
    46 createLL1Choices
       
    47     ir :=  PPCLL1Visitor new
       
    48         arguments: arguments;
       
    49         visit: ir.
       
    50     self remember: #LL1
       
    51 !
       
    52 
       
    53 tokenize
       
    54     "
       
    55         This will try transform the parser into the tokenizing parser
       
    56     "
       
    57     arguments tokenize ifFalse: [ ^ self ] .
       
    58     
       
    59     ir :=  PPCTokenizingVisitor new
       
    60         arguments: arguments;
       
    61         visit: ir.
       
    62     self remember: #tokenize
       
    63 ! !
       
    64