diff -r 17ba167b8ee1 -r 553a5456963b compiler/PPCAbstractCharacterNode.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compiler/PPCAbstractCharacterNode.st Sun Oct 26 01:03:31 2014 +0000 @@ -0,0 +1,67 @@ +"{ Package: 'stx:goodies/petitparser/compiler' }" + +PPCNode subclass:#PPCAbstractCharacterNode + instanceVariableNames:'character' + classVariableNames:'' + poolDictionaries:'' + category:'PetitCompiler-Nodes' +! + +PPCAbstractCharacterNode comment:'' +! + +!PPCAbstractCharacterNode methodsFor:'accessing'! + +acceptsEpsilon + ^ false +! + +character + ^ character +! + +character: char + character := char +! + +prefix + ^ #char +! ! + +!PPCAbstractCharacterNode methodsFor:'analysis'! + +firstCharParser + ^ character asParser +! ! + +!PPCAbstractCharacterNode methodsFor:'compiling'! + +body: compiler + | id | + + character ppcPrintable ifTrue: [ + id := character printString + ] ifFalse: [ + id := compiler idFor: character prefixed: #char. + compiler addConstant: (Character value: character asInteger) as: id . + ]. + + compiler add: '(context peek == ', id, ')'. + compiler indent. + compiler add: 'ifFalse: [ self error: ''', character asInteger asString, ' expected'' at: context position ] '. + compiler add: 'ifTrue: [ context next ].'. + compiler dedent. +! + +compileWith: compiler effect: effect id: id + self start: compiler id: id. + self body: compiler. + ^ self stop: compiler. +! + +compileWith: compiler id: id + self start: compiler. + self body: compiler. + ^ compiler stopMethod. +! ! +