32 lines
822 B
Smalltalk
32 lines
822 B
Smalltalk
Extension { #name : 'PPTrimmingParser' }
|
|
|
|
{ #category : '*petitcompiler' }
|
|
PPTrimmingParser >> asCompilerNode [
|
|
^ PPCTrimNode new
|
|
child: parser;
|
|
"
|
|
JK HACK ALERT, because trimmer is not included in children, it will never be asked
|
|
to be translated into the PPCNode when building compiler tree. We have to do it on
|
|
our own :(
|
|
"
|
|
trimmer: trimmer star asCompilerTree;
|
|
name: self name;
|
|
parser: self;
|
|
yourself
|
|
]
|
|
|
|
{ #category : '*petitcompiler' }
|
|
PPTrimmingParser >> parseOn: aPPContext [
|
|
| memento element |
|
|
memento := aPPContext remember.
|
|
[ (trimmer parseOn: aPPContext) isPetitFailure ]
|
|
whileFalse.
|
|
element := parser parseOn: aPPContext.
|
|
element isPetitFailure ifTrue: [
|
|
aPPContext restore: memento.
|
|
^ element ].
|
|
[ (trimmer parseOn: aPPContext) isPetitFailure ]
|
|
whileFalse.
|
|
^ element
|
|
]
|