compiler/PPCNotLiteralNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 15 Apr 2015 11:28:09 +0100
changeset 422 116d2b2af905
parent 421 7e08b31e0dae
child 438 20598d7ce9fa
permissions -rw-r--r--
To fold

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

"{ NameSpace: Smalltalk }"

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

!PPCNotLiteralNode methodsFor:'accessing'!

asInlined
	^ PPCInlineNotLiteralNode new
		name: name;
		literal: literal;
		yourself
!

firstCharSet
	^ PPCharSetPredicate on: [:e | true ]
!

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