equal
deleted
inserted
replaced
|
1 "{ Package: 'stx:goodies/petitparser/compiler' }" |
|
2 |
|
3 "{ NameSpace: Smalltalk }" |
|
4 |
|
5 PPCPass subclass:#PPCCacheFirstFollowPass |
|
6 instanceVariableNames:'' |
|
7 classVariableNames:'' |
|
8 poolDictionaries:'' |
|
9 category:'PetitCompiler-Core' |
|
10 ! |
|
11 |
|
12 !PPCCacheFirstFollowPass methodsFor:'running'! |
|
13 |
|
14 run: ir |
|
15 "Actually run the pass on given IR (tree of PPCNode) and return |
|
16 (possibly transformed or completely new) another IR." |
|
17 |
|
18 | firstSets firstSetsWithTokens followSets followSetsWithTokens | |
|
19 |
|
20 "Cache first sets" |
|
21 firstSets := ir firstSets. |
|
22 ir allNodesDo: [ :node | node firstSet: (firstSets at: node) ]. |
|
23 firstSetsWithTokens := ir firstSetsSuchThat: [:e | e isTerminal or: [ e isTokenNode ] ]. |
|
24 ir allNodesDo: [ :node | node firstSetWithTokens: (firstSetsWithTokens at: node) ]. |
|
25 |
|
26 "Cache follow sets" |
|
27 followSets := ir followSets. |
|
28 ir allNodesDo: [ :node | node followSet: (followSets at: node) ]. |
|
29 followSetsWithTokens := ir followSetsSuchThat: [:e | e isTerminal or: [ e isTokenNode ] ]. |
|
30 ir allNodesDo: [ :node | node followSetWithTokens: (followSetsWithTokens at: node) ]. |
|
31 ^ ir |
|
32 |
|
33 "Created: / 29-08-2015 / 07:27:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
34 ! ! |
|
35 |