compiler/PPCAbstractLiteralNode.st
changeset 391 553a5456963b
child 392 9b297f0d949c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compiler/PPCAbstractLiteralNode.st	Sun Oct 26 01:03:31 2014 +0000
@@ -0,0 +1,48 @@
+"{ Package: 'stx:goodies/petitparser/compiler' }"
+
+PPCNode subclass:#PPCAbstractLiteralNode
+	instanceVariableNames:'literal'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitCompiler-Nodes'
+!
+
+PPCAbstractLiteralNode comment:''
+!
+
+!PPCAbstractLiteralNode methodsFor:'accessing'!
+
+acceptsEpsilon
+	^ literal size = 0
+!
+
+firstCharParser
+	^ literal first asParser
+!
+
+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
+! !
+