|
1 "{ Package: 'stx:goodies/petitparser/compiler/tests/extras' }" |
|
2 |
|
3 "{ NameSpace: Smalltalk }" |
|
4 |
|
5 PPAbstractParserTest subclass:#PPCAbstractParserTest |
|
6 instanceVariableNames:'' |
|
7 classVariableNames:'' |
|
8 poolDictionaries:'' |
|
9 category:'PetitCompiler-Extras-Tests-Support' |
|
10 ! |
|
11 |
|
12 !PPCAbstractParserTest class methodsFor:'resources'! |
|
13 |
|
14 resources |
|
15 ^ Array with: (PPCSetUpBeforeTearDownAfterResource for: self) |
|
16 ! ! |
|
17 |
|
18 !PPCAbstractParserTest class methodsFor:'testing'! |
|
19 |
|
20 isAbstract |
|
21 ^ self == PPCAbstractParserTest |
|
22 |
|
23 "Modified: / 30-07-2015 / 07:28:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
24 ! ! |
|
25 |
|
26 !PPCAbstractParserTest methodsFor:'accessing'! |
|
27 |
|
28 compiledParser |
|
29 ^ self compiledParserClass new |
|
30 |
|
31 "Created: / 29-07-2015 / 17:00:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
32 ! |
|
33 |
|
34 compiledParserClass |
|
35 ^ Smalltalk at: self compiledParserClassName |
|
36 |
|
37 "Created: / 29-07-2015 / 16:54:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
38 ! |
|
39 |
|
40 compiledParserClassName |
|
41 "Return the name of the compiled parser" |
|
42 |
|
43 ^ (self petitParserClass name , 'C_' , |
|
44 "This is bit hacky!!" |
|
45 ((self compilerConfiguration isKindOf: PPCTokenizingConfiguration) ifTrue:[ 'Tokenizing' ] ifFalse:[ 'Universal' ])) asSymbol |
|
46 |
|
47 "Created: / 29-07-2015 / 16:54:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
48 ! |
|
49 |
|
50 compilerConfiguration |
|
51 "Return configuration to use when compiling parser (as instance of PPCConfiguration)" |
|
52 |
|
53 ^ self subclassResponsibility |
|
54 |
|
55 "Created: / 29-07-2015 / 16:53:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
56 ! |
|
57 |
|
58 parserClass |
|
59 ^ self compiledParserClass |
|
60 |
|
61 "Modified: / 29-07-2015 / 18:43:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
62 ! |
|
63 |
|
64 parserInstanceFor: aSymbol |
|
65 ^ self parserClass new startSymbol: aSymbol |
|
66 |
|
67 "Modified: / 29-07-2015 / 18:43:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
68 ! |
|
69 |
|
70 petitParser |
|
71 ^ self petitParserClass new |
|
72 |
|
73 "Created: / 29-07-2015 / 17:01:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
74 ! |
|
75 |
|
76 petitParserClass |
|
77 "Return the name of the petit parser to compile" |
|
78 |
|
79 ^ self subclassResponsibility |
|
80 |
|
81 "Created: / 29-07-2015 / 17:01:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
82 ! ! |
|
83 |
|
84 !PPCAbstractParserTest methodsFor:'context'! |
|
85 |
|
86 context |
|
87 |
|
88 ^ PPCContext new |
|
89 ! ! |
|
90 |
|
91 !PPCAbstractParserTest methodsFor:'setup & teardown'! |
|
92 |
|
93 setUpBefore |
|
94 "Called before any of my tests is run (when resources are set up)" |
|
95 | time configuration | |
|
96 |
|
97 configuration := self compilerConfiguration. |
|
98 configuration arguments parserName: self compiledParserClassName. |
|
99 time := Time millisecondsToRun: [ |
|
100 self petitParser compileWithConfiguration: configuration. |
|
101 ]. |
|
102 Transcript show: self petitParserClass name ; show:' compiled in: '; show: time asString; show: 'ms'; cr. |
|
103 |
|
104 "Created: / 29-07-2015 / 16:29:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
105 "Modified: / 29-07-2015 / 18:40:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
106 ! |
|
107 |
|
108 tearDownAfter |
|
109 "Called after all my tests are ryn(when resources are torn down)" |
|
110 |
|
111 "Created: / 29-07-2015 / 16:33:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
112 ! ! |
|
113 |