Merged JK's work on PetitCompiler
Name: PetitCompiler-JanKurs.57
Author: JanKurs
Time: 05-11-2014, 05:10:47 AM
UUID: 4c625efe-77fd-465d-bd63-72ead0b5d3ba
Name: PetitCompiler-Tests-JanVrany.13
Author: JanVrany
Time: 05-11-2014, 09:31:07 AM
UUID: 189ae287-6bc1-40ba-8458-b8392c4260a0
"{ Package: 'stx:goodies/petitparser/compiler' }"
PPCAbstractLiteralNode subclass:#PPCNotLiteralNode
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Nodes'
!
!PPCNotLiteralNode methodsFor:'accessing'!
asInlined
^ PPCInlineNotLiteralNode new
name: name;
literal: literal;
yourself
!
firstCharParser
^ literal first asParser
!
firstCharSet
^ PPCharSetPredicate on: [:e | e ~= literal first ]
!
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.
! !