equal
deleted
inserted
replaced
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:'' |
6 instanceVariableNames:'clazz' |
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: compiler |
14 buildClass |
15 | builder | |
15 | builder | |
|
16 self assert: (clazz isKindOf: PPCClass). |
|
17 |
16 builder := PPCClassBuilder new. |
18 builder := PPCClassBuilder new. |
17 |
19 |
18 builder compiledClassName: arguments parserName. |
20 builder compiledClassName: arguments parserName. |
19 builder compiledSuperclass: PPCompiledParser. |
21 builder compiledSuperclass: PPCompiledParser. |
20 builder methodDictionary: compiler methodDictionary. |
22 builder methodDictionary: clazz methodDictionary. |
21 builder constants: compiler constants. |
23 builder constants: clazz constants. |
22 |
24 |
23 ^ builder compileClass. |
25 ^ builder compileClass. |
|
26 ! |
|
27 |
|
28 initialize |
|
29 super initialize. |
|
30 |
|
31 clazz := PPCClass new. |
24 ! |
32 ! |
25 |
33 |
26 invokePhases |
34 invokePhases |
27 self toPPCIr. |
35 self toPPCIr. |
28 self createTokens. |
36 self createTokens. |
34 self merge. |
42 self merge. |
35 self check. |
43 self check. |
36 self generate. |
44 self generate. |
37 ! ! |
45 ! ! |
38 |
46 |
|
47 !PPCUniversalConfiguration methodsFor:'hooks'! |
|
48 |
|
49 codeGenerator |
|
50 ^ PPCUniversalCodeGenerator new |
|
51 arguments: arguments |
|
52 ! ! |
|
53 |
|
54 !PPCUniversalConfiguration methodsFor:'phases'! |
|
55 |
|
56 generate |
|
57 | rootMethod compiledParser | |
|
58 arguments generate ifFalse: [ ^ self ]. |
|
59 |
|
60 rootMethod := self codeGenerator |
|
61 arguments: arguments; |
|
62 clazz: clazz; |
|
63 visit: ir. |
|
64 |
|
65 compiledParser := self buildClass. |
|
66 compiledParser startSymbol: rootMethod methodName. |
|
67 compiledParser := compiledParser new. |
|
68 |
|
69 ir := compiledParser. |
|
70 ! ! |
|
71 |