compiler/PPCStarCharSetPredicateNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 20 May 2015 16:47:52 +0100
changeset 463 d4014e0a47a0
parent 452 9f4558b3be66
child 464 f6d77fee9811
permissions -rw-r--r--
Small improvement in inlining: inline child of an action node.

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

"{ NameSpace: Smalltalk }"

PPCStarNode subclass:#PPCStarCharSetPredicateNode
	instanceVariableNames:'predicate'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Nodes'
!

!PPCStarCharSetPredicateNode methodsFor:'accessing'!

extendClassification: classification
    ^ (classification asOrderedCollection addLast: false; yourself) asArray
!

firstCharSet
    ^ PPCharSetPredicate on: predicate 	
!

predicate
    
    ^ predicate
!

predicate: anObject
    
    predicate := anObject
!

prefix
    ^ #starPredicate
! !

!PPCStarCharSetPredicateNode methodsFor:'comparing'!

= anotherNode
    super = anotherNode ifFalse: [ ^ false ].
    ^ predicate = anotherNode predicate.
!

hash
    ^ super hash bitXor: predicate hash
! !

!PPCStarCharSetPredicateNode methodsFor:'first follow next'!

firstSets: aFirstDictionary into: aSet suchThat: aBlock
    "
        First and follow should be performed on the non-specialized tree, i.e. on a tree
        with star -> messageNode. Not on myself.
        
        The reason for that is, that:
        - I am terminal
        - I am nullable
        
        This means, I look like epsilon node for the first follow analysis. And epsilons 
        are ignored in sequences, thus sequence of StarMessagePredicate, Literal
        leads to { Literal } as firstSet and not expected { MessagePredicate, Literal }
    "
    ^ self error: 'Cannot perform first/follow analysis on myself, sorry for that :('
! !

!PPCStarCharSetPredicateNode methodsFor:'visiting'!

accept: visitor
    ^ visitor visitStarCharSetPredicateNode: self
! !