1 "{ Package: 'stx:goodies/petitparser/compiler' }" |
1 "{ Package: 'stx:goodies/petitparser/compiler' }" |
2 |
2 |
3 "{ NameSpace: Smalltalk }" |
3 "{ NameSpace: Smalltalk }" |
4 |
4 |
5 PPCConfiguration subclass:#PPCUniversalConfiguration |
5 PPCConfiguration subclass:#PPCUniversalConfiguration |
6 instanceVariableNames:'clazz' |
6 instanceVariableNames:'' |
7 classVariableNames:'' |
7 classVariableNames:'' |
8 poolDictionaries:'' |
8 poolDictionaries:'' |
9 category:'PetitCompiler-Core' |
9 category:'PetitCompiler-Core' |
10 ! |
10 ! |
11 |
11 |
12 !PPCUniversalConfiguration methodsFor:'compiling'! |
12 !PPCUniversalConfiguration methodsFor:'compiling'! |
13 |
13 |
14 buildClass |
14 buildClass |
15 | builder | |
15 | builder | |
16 self assert: (clazz isKindOf: PPCClass). |
16 self assert: (context parserClass isKindOf: PPCClass). |
17 |
17 |
18 builder := PPCClassBuilder new. |
18 builder := PPCClassBuilder new. |
19 |
19 |
20 builder compiledClassName: options parserName. |
20 builder compiledClassName: options parserName. |
21 builder compiledSuperclass: PPCompiledParser. |
21 builder compiledSuperclass: PPCompiledParser. |
22 builder methodDictionary: clazz methodDictionary. |
22 builder methodDictionary: context parserClass methodDictionary. |
23 builder constants: clazz constants. |
23 builder constants: context parserClass constants. |
24 |
24 |
25 ^ builder compileClass. |
25 ^ builder compileClass. |
|
26 |
|
27 "Modified: / 25-08-2015 / 00:04:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
26 ! |
28 ! |
27 |
29 |
28 initialize |
30 initialize |
29 super initialize. |
31 super initialize. |
30 |
32 |
31 clazz := PPCClass new. |
33 "Modified: / 25-08-2015 / 00:03:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
32 ! |
34 ! |
33 |
35 |
34 invokePhases |
36 invokePhases |
35 self toPPCIr. |
37 self toPPCIr. |
36 self createTokens. |
38 self createTokens. |
57 | rootMethod compiledParser | |
59 | rootMethod compiledParser | |
58 options generate ifFalse: [ ^ self ]. |
60 options generate ifFalse: [ ^ self ]. |
59 |
61 |
60 rootMethod := self codeGenerator |
62 rootMethod := self codeGenerator |
61 options: options; |
63 options: options; |
62 clazz: clazz; |
64 clazz: context parserClass; |
63 visit: ir. |
65 visit: ir. |
64 |
66 |
65 compiledParser := self buildClass. |
67 compiledParser := self buildClass. |
66 compiledParser startSymbol: rootMethod methodName. |
68 compiledParser startSymbol: rootMethod methodName. |
67 compiledParser := compiledParser new. |
69 compiledParser := compiledParser new. |
68 |
70 |
69 ir := compiledParser. |
71 ir := compiledParser. |
|
72 |
|
73 "Modified: / 25-08-2015 / 00:03:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
70 ! ! |
74 ! ! |
71 |
75 |