Updated to PetitCompiler-JanKurs.100, PetitCompiler-Tests-JanKurs.44 and PetitCompiler-Benchmarks-JanKurs.4
Name: PetitCompiler-JanKurs.100
Author: JanKurs
Time: 30-04-2015, 10:48:52.165 AM
UUID: 80196870-5921-46d9-ac20-a43bf5c2f3c2
Name: PetitCompiler-Tests-JanKurs.44
Author: JanKurs
Time: 30-04-2015, 10:49:22.489 AM
UUID: 348c02e8-18ce-48f6-885d-fcff4516a298
Name: PetitCompiler-Benchmarks-JanKurs.4
Author: JanKurs
Time: 30-04-2015, 10:58:44.890 AM
UUID: 18cadb42-f9ef-45fb-82e9-8469ade56c8b
"{ Package: 'stx:goodies/petitparser/compiler' }"
"{ NameSpace: Smalltalk }"
PPCRewritingVisitor subclass:#PPCTokenDetector
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Visitors'
!
!PPCTokenDetector methodsFor:'visiting'!
visitActionNode: node
(node hasProperty: #trimmingToken) ifTrue: [
| newWs newChild |
self change.
newChild := self visitWithTokenVisitor: node child children second child. "Oups, what a chain"
newWs := self visitWithTokenVisitor: node child children first.
^ PPCTrimmingTokenNode new
name: node name;
child: newChild;
tokenClass: node child children second tokenClass;
whitespace: newWs;
yourself.
].
^ super visitActionNode: node
!
visitNotNode: node
"We don't need result of the not,..."
| child newChild |
self change.
child := node child.
newChild := self visitWithTokenVisitor: child.
node replace: child with: newChild.
^ node
!
visitTokenNode: node
| child newChild |
self change.
child := node child.
newChild := self visitWithTokenVisitor: child.
node replace: child with: newChild.
^ node
!
visitWithTokenVisitor: node
| retval forbiddenNodes copyVisitor tokenVisitor |
copyVisitor := PPCCopyVisitor new.
tokenVisitor := PPCTokenVisitor new.
forbiddenNodes := openSet copy.
tokenVisitor forbiddenNodes: forbiddenNodes.
retval := copyVisitor visit: node.
retval := tokenVisitor visit: retval.
^ retval
! !