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