compiler/PPCCharacterNode.st
changeset 464 f6d77fee9811
parent 452 9f4558b3be66
child 515 b5316ef15274
--- a/compiler/PPCCharacterNode.st	Tue May 12 01:24:03 2015 +0100
+++ b/compiler/PPCCharacterNode.st	Thu May 21 14:12:22 2015 +0100
@@ -2,22 +2,64 @@
 
 "{ NameSpace: Smalltalk }"
 
-PPCAbstractCharacterNode subclass:#PPCCharacterNode
-	instanceVariableNames:''
+PPCNode subclass:#PPCCharacterNode
+	instanceVariableNames:'character'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'PetitCompiler-Nodes'
 !
 
-!PPCCharacterNode methodsFor:'as yet unclassified'!
+!PPCCharacterNode methodsFor:'accessing'!
+
+character
+    ^ character
+!
+
+character: char
+    character := char
+!
 
-start: compiler id: id
-    compiler startMethod: id.
-    compiler add: '^ '.
+prefix
+    ^ #char
+! !
+
+!PPCCharacterNode methodsFor:'analysis'!
+
+acceptsEpsilon
+    ^ false
+!
+
+firstCharSet
+    ^ PPCharSetPredicate on: [:e | e = character ]
 !
 
-stop: compiler
-    ^ compiler stopMethod
+recognizedSentencesPrim
+    ^ Array with: character asString
+! !
+
+!PPCCharacterNode methodsFor:'comparison'!
+
+= anotherNode
+    super = anotherNode ifFalse: [ ^ false ].
+    ^ character = anotherNode character.
+!
+
+hash
+    ^ super hash bitXor: character hash
+! !
+
+!PPCCharacterNode methodsFor:'printing'!
+
+printNameOn: aStream
+    super printNameOn: aStream.
+
+    character = $" ifTrue: [ 
+        "this is hack to allow for printing '' in comments..."
+        aStream nextPutAll: ', '; nextPutAll: '$'''''.
+        ^ self
+    ].
+
+    aStream nextPutAll: ', not('; print: character; nextPutAll: ')'
 ! !
 
 !PPCCharacterNode methodsFor:'visiting'!