compiler/PPCTokenGuard.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 17 Jun 2015 16:49:28 +0100
changeset 492 fc3dbe5654c5
parent 464 f6d77fee9811
permissions -rw-r--r--
Use #deepCopy instead of #copy when copying RB parse tree ...because #copy make a copy if child nodes but does not set their parents properly. Therefore node replacing does not work because it replaces it in wrong tree (original, not the copy).

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

"{ NameSpace: Smalltalk }"

Object subclass:#PPCTokenGuard
	instanceVariableNames:'node'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Guards'
!

!PPCTokenGuard class methodsFor:'as yet unclassified'!

on: node
    ^ self new
        node: node;
        yourself
! !

!PPCTokenGuard methodsFor:'as yet unclassified'!

firstToken
    self assert: node firstSetWithTokens  size = 1.
    ^ node firstSetWithTokens anyOne
!

makesSense
    ^ node firstSetWithTokens size = 1 and: [ node firstSetWithTokens anyOne isTokenNode ]
!

node
    ^ node
!

node: aPPCNode
    node := aPPCNode
! !