compiler/PPCUniversalConfiguration.st
changeset 531 dc3d13c2837d
parent 530 e36906742693
child 532 132d7898a2a1
equal deleted inserted replaced
530:e36906742693 531:dc3d13c2837d
     7 	classVariableNames:''
     7 	classVariableNames:''
     8 	poolDictionaries:''
     8 	poolDictionaries:''
     9 	category:'PetitCompiler-Core'
     9 	category:'PetitCompiler-Core'
    10 !
    10 !
    11 
    11 
       
    12 
    12 !PPCUniversalConfiguration methodsFor:'compiling'!
    13 !PPCUniversalConfiguration methodsFor:'compiling'!
    13 
       
    14 buildClass
       
    15     |  builder |
       
    16     self assert: (context parserClass isKindOf: PPCClass).
       
    17     
       
    18     builder := PPCClassBuilder new.
       
    19     
       
    20     builder compiledClassName: options parserName.
       
    21     builder compiledSuperclass: PPCompiledParser.
       
    22     builder methodDictionary: context parserClass methodDictionary.
       
    23     builder constants: context parserClass constants.
       
    24 
       
    25     ^ builder compileClass.
       
    26 
       
    27     "Modified: / 25-08-2015 / 00:04:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    28 !
       
    29 
    14 
    30 initialize
    15 initialize
    31     super initialize.
    16     super initialize.
    32 
    17 
    33     "Modified: / 25-08-2015 / 00:03:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    18     "Modified: / 25-08-2015 / 00:03:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    44     self merge.
    29     self merge.
    45     self check.	
    30     self check.	
    46     self generate.
    31     self generate.
    47 ! !
    32 ! !
    48 
    33 
       
    34 !PPCUniversalConfiguration methodsFor:'error handling'!
       
    35 
       
    36 buildClass
       
    37     | builder |
       
    38 
       
    39     self assert:(context parserClass isKindOf:PPCClass).
       
    40     builder := PPCClassBuilder new.
       
    41     builder compiledClassName:context options parserName.
       
    42     builder compiledSuperclass:PPCompiledParser.
       
    43     builder methodDictionary:context parserClass methodDictionary.
       
    44     builder constants:context parserClass constants.
       
    45     ^ builder compileClass.
       
    46 
       
    47     "Modified: / 25-08-2015 / 00:04:08 / Jan Vrany <jan.vrany@fit."
       
    48     "Modified: / 26-08-2015 / 20:01:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    49 !
       
    50 
       
    51 generate
       
    52     | rootMethod  compiledParser |
       
    53 
       
    54     context options generate ifFalse:[
       
    55         ^ self
       
    56     ].
       
    57     rootMethod := (self codeGenerator)
       
    58             options:context options;
       
    59             clazz:context parserClass;
       
    60             visit:ir.
       
    61     compiledParser := self buildClass.
       
    62     compiledParser startSymbol:rootMethod methodName.
       
    63     compiledParser := compiledParser new.
       
    64     ir := compiledParser.
       
    65 
       
    66     "Modified: / 25-08-2015 / 00:03:46 / Jan Vrany <jan.vr"
       
    67     "Modified: / 26-08-2015 / 20:00:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    68 ! !
       
    69 
    49 !PPCUniversalConfiguration methodsFor:'hooks'!
    70 !PPCUniversalConfiguration methodsFor:'hooks'!
    50 
    71 
    51 codeGenerator
    72 codeGenerator
    52     ^ PPCUniversalCodeGenerator new
    73     ^ PPCUniversalCodeGenerator new options:context options
    53         options: options
       
    54 ! !
    74 ! !
    55 
    75 
    56 !PPCUniversalConfiguration methodsFor:'phases'!
    76 !PPCUniversalConfiguration class methodsFor:'documentation'!
    57 
    77 
    58 generate
    78 version
    59     | rootMethod compiledParser |
    79     ^ 'Path: stx/goodies/petitparser/compiler/PPCUniversalConfiguration.st, Version: 1.0, User: jv, Time: 2015-08-26T20:03:52.218+01'
    60     options generate ifFalse: [ ^ self ].
    80 !
    61     
       
    62     rootMethod := self codeGenerator
       
    63         options: options;
       
    64         clazz: context parserClass;
       
    65         visit: ir.
       
    66     
       
    67     compiledParser := self buildClass.
       
    68     compiledParser startSymbol: rootMethod methodName.
       
    69     compiledParser := compiledParser new.
       
    70     
       
    71     ir := compiledParser.
       
    72 
    81 
    73     "Modified: / 25-08-2015 / 00:03:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    82 version_HG
       
    83     ^ 'Path: stx/goodies/petitparser/compiler/PPCUniversalConfiguration.st, Version: 1.0, User: jv, Time: 2015-08-26T20:03:52.218+01'
    74 ! !
    84 ! !
    75 
    85