compiler/PPCAbstractLiteralNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 18 Jan 2016 08:05:03 +0000
changeset 555 4aa0496e6c22
parent 515 b5316ef15274
permissions -rw-r--r--
For tests on Pharo 5.0, use Spur VM

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

"{ NameSpace: Smalltalk }"

PPCNode subclass:#PPCAbstractLiteralNode
	instanceVariableNames:'literal'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Nodes'
!

!PPCAbstractLiteralNode methodsFor:'accessing'!

defaultName
    ^ #lit
!

literal
    
    ^ literal
!

literal: anObject
    
    literal := anObject
! !

!PPCAbstractLiteralNode methodsFor:'analysis'!

acceptsEpsilon
    ^ literal size = 0
!

firstCharSet
    | letter |
    letter := literal first.
    ^ PPCharSetPredicate on: [:e | e = letter ]
! !

!PPCAbstractLiteralNode methodsFor:'comparison'!

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

hash
    ^ super hash bitXor: literal hash
! !

!PPCAbstractLiteralNode methodsFor:'compiling'!

encodeQuotes: string
    | x s |
    s := WriteStream on: ''.
    1 to: string size do: [ :i|
        s nextPut: (x := string at: i).
        x = $' ifTrue: [ s nextPut: x ].
    ].
    ^ s contents
! !