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' }"
PPCAbstractActionNode subclass:#PPCActionNode
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Nodes'
!
!PPCActionNode methodsFor:'as yet unclassified'!
asFast
^ PPCTokenActionNode new
child: child;
name: self name;
yourself
!
compileWith: compiler effect: effect id: id
| |
compiler addConstant: block as: id.
compiler startMethod: id.
compiler addVariable: 'element'.
compiler add: 'element := '.
compiler callOnLine: (child compileWith: compiler).
compiler add: 'error ifFalse: [ ^ ', id, ' value: element ].'.
compiler add: '^ failure'.
^ compiler stopMethod.
!
rewrite: changeStatus
"TODO JK: Find another way how to recognize the trimming token!!"
(name = 'trimmingToken') ifTrue: [
changeStatus change.
^ PPCTrimmingTokenNode new
"name: name"
"JK: I am sorry"
child: child children second child;
tokenClass: child children second tokenClass;
whitespace: child children first;
yourself
].
block isSymbol ifTrue: [
changeStatus change.
^ PPCSymbolActionNode new
block: block;
name: name;
child: child;
yourself
]
! !