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' }"
PPCNode subclass:#PPCStarCharSetPredicateNode
instanceVariableNames:'predicate'
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Nodes'
!
!PPCStarCharSetPredicateNode methodsFor:'accessing'!
acceptsEpsilon
^ true
!
compileWith: compiler effect: effect id: id
| classification classificationId |
compiler startMethod: id.
classification := self extendClassification: predicate classification.
classificationId := compiler idFor: classification prefixed: #classification.
compiler addConstant: classification as: classificationId.
compiler addVariable: 'retval'.
compiler add: 'retval := OrderedCollection new.'.
compiler add: '[ ', classificationId, ' at: context peek asInteger ] whileTrue: ['.
compiler indent.
compiler add: ' retval add: context next.'.
compiler dedent.
compiler add: '].'.
compiler add: '^ retval asArray'.
^ compiler stopMethod.
!
extendClassification: classification
^ (classification asOrderedCollection addLast: false; yourself) asArray
!
firstCharParser
^ PPPredicateObjectParser on: predicate message: 'predicate expected'.
!
firstCharSet
^ PPCharSetPredicate on: predicate
!
predicate
^ predicate
!
predicate: anObject
predicate := anObject
!
prefix
^ #starPredicate
! !