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