compiler/PPCCacheFirstFollowPass.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 23 Nov 2015 11:14:30 +0100
changeset 551 00ebb1b85f53
parent 534 a949c4fe44df
permissions -rw-r--r--
Fixed CI scripts on Windows For an unknown reason, unzip on Windows reports status code 50 (presumably "the disk is (or was) full during extraction.") even if there's plenty of space. To workaround this, simply ignore status code 50 on Windows. Sigh.

"{ Package: 'stx:goodies/petitparser/compiler' }"

"{ NameSpace: Smalltalk }"

PPCPass subclass:#PPCCacheFirstFollowPass
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Core'
!

!PPCCacheFirstFollowPass methodsFor:'running'!

run: ir
    "Actually run the pass on given IR (tree of PPCNode) and return
     (possibly transformed or completely new) another IR."

    | firstSets firstSetsWithTokens followSets followSetsWithTokens |

    "Cache first sets"
    firstSets := ir firstSets.
    ir allNodesDo: [ :node | node firstSet: (firstSets at: node) ].
    firstSetsWithTokens := ir firstSetsSuchThat: [:e | e isTerminal or: [ e isTokenNode ] ].
    ir allNodesDo: [ :node | node firstSetWithTokens: (firstSetsWithTokens at: node) ].

    "Cache follow sets"
    followSets := ir followSets.
    ir allNodesDo: [ :node | node followSet: (followSets at: node) ].
    followSetsWithTokens := ir followSetsSuchThat: [:e | e isTerminal or: [ e isTokenNode ] ].
    ir allNodesDo: [ :node | node followSetWithTokens: (followSetsWithTokens at: node) ].
    ^ ir

    "Created: / 29-08-2015 / 07:27:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !