equal
deleted
inserted
replaced
|
1 "{ Package: 'stx:goodies/petitparser/compiler' }" |
|
2 |
|
3 "{ NameSpace: Smalltalk }" |
|
4 |
|
5 Object subclass:#PPCCompilerTokenizingRememberStrategy |
|
6 instanceVariableNames:'compiler' |
|
7 classVariableNames:'' |
|
8 poolDictionaries:'' |
|
9 category:'PetitCompiler-Core' |
|
10 ! |
|
11 |
|
12 !PPCCompilerTokenizingRememberStrategy class methodsFor:'instance creation'! |
|
13 |
|
14 on: aPPCCompiler |
|
15 ^ self new |
|
16 compiler: aPPCCompiler; |
|
17 yourself |
|
18 ! ! |
|
19 |
|
20 !PPCCompilerTokenizingRememberStrategy methodsFor:'accessing'! |
|
21 |
|
22 compiler: aPPCCompiler |
|
23 compiler := aPPCCompiler |
|
24 ! ! |
|
25 |
|
26 !PPCCompilerTokenizingRememberStrategy methodsFor:'as yet unclassified'! |
|
27 |
|
28 smartRemember: parser to: variableName |
|
29 parser isContextFree ifTrue: [ |
|
30 compiler codeAssign: '{ context lwRemember. currentTokenType . currentTokenValue }.' |
|
31 to: variableName. |
|
32 ] ifFalse: [ |
|
33 compiler codeAssign: '{ context remember. currentTokenType . currentTokenValue }.' |
|
34 to: variableName. |
|
35 ] |
|
36 ! |
|
37 |
|
38 smartRestore: parser from: mementoName |
|
39 parser isContextFree ifTrue: [ |
|
40 compiler add: 'context lwRestore: ', mementoName, ' first.'. |
|
41 ] ifFalse: [ |
|
42 compiler add: 'context restore: ', mementoName, ' first.'. |
|
43 ]. |
|
44 compiler codeAssign: mementoName, ' second.' to: 'currentTokenType'. |
|
45 compiler codeAssign: mementoName, ' third.' to: 'currentTokenValue'. |
|
46 ! ! |
|
47 |