compiler/PPCNotLiteralNode.st
changeset 391 553a5456963b
child 392 9b297f0d949c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compiler/PPCNotLiteralNode.st	Sun Oct 26 01:03:31 2014 +0000
@@ -0,0 +1,55 @@
+"{ Package: 'stx:goodies/petitparser/compiler' }"
+
+PPCAbstractLiteralNode subclass:#PPCNotLiteralNode
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitCompiler-Nodes'
+!
+
+PPCNotLiteralNode comment:''
+!
+
+!PPCNotLiteralNode methodsFor:'accessing'!
+
+asInlined
+	^ PPCInlineNotLiteralNode new
+		name: name;
+		literal: literal;
+		yourself
+!
+
+firstCharParser
+	^ literal first asParser
+!
+
+literal
+	
+	^ literal
+!
+
+literal: anObject
+	
+	literal := anObject
+!
+
+prefix
+	^ #notLit
+! !
+
+!PPCNotLiteralNode methodsFor:'as yet unclassified'!
+
+compileWith: compiler effect: effect id: id
+	| encodedLiteral size |
+	encodedLiteral := self encodeQuotes: literal.
+	size := literal size asString.
+	
+	compiler startMethod: id.
+	compiler add: '((context peek: ', size, ') =#''', encodedLiteral, ''')'.
+	compiler indent.
+	compiler add: ' ifTrue: [ self error: ''', encodedLiteral, ' not expected'' ]'.
+	compiler add: ' ifFalse: [ nil ].'.
+	compiler dedent.
+ ^ compiler stopMethod.
+! !
+