compiler/PPCAbstractLiteralNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 06 Nov 2014 02:22:56 +0000
changeset 416 b0fd54ee0412
parent 414 0eaf09920532
child 421 7e08b31e0dae
permissions -rw-r--r--
Do not try to inline PPCPluggableNode on Smalltalk/X Sadly, on Smalltalk/X blocks cannot be inlined because the VM does not provide enough information to map it back to the source code. Very bad indeed!

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

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

!PPCAbstractLiteralNode methodsFor:'accessing'!

acceptsEpsilon
	^ literal size = 0
!

firstCharParser
	^ literal first asParser
!

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

literal
	
	^ literal
!

literal: anObject
	
	literal := anObject
!

prefix
	^ #lit
! !

!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
! !