PPTrimmingParser.st
author sr
Wed, 04 Jul 2018 15:30:19 +0200
changeset 611 38338f2de417
parent 39 743bee9b3ed1
child 377 6112a403a52d
permissions -rw-r--r--
build order was wrong

"{ Package: 'stx:goodies/petitparser' }"

PPDelegateParser subclass:#PPTrimmingParser
	instanceVariableNames:'trimmer'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitParser-Parsers'
!


!PPTrimmingParser class methodsFor:'instance creation'!

on: aParser trimmer: aTrimParser
	^ self new
		setParser: aParser;
		setTrimmer: aTrimParser;
		yourself
! !

!PPTrimmingParser methodsFor:'initialization'!

setTrimmer: aParser
	trimmer := aParser
! !

!PPTrimmingParser methodsFor:'operations'!

trim
	"There is no point in trimming more than once."

	^ self
! !

!PPTrimmingParser methodsFor:'parsing'!

parseOn: aStream
	| position element |
	position := aStream position.
	[ (trimmer parseOn: aStream) isPetitFailure ]
		whileFalse.
	element := parser parseOn: aStream.
	element isPetitFailure ifTrue: [
		aStream position: position.
		^ element ].
	[ (trimmer parseOn: aStream) isPetitFailure ]
		whileFalse.
	^ element
! !

!PPTrimmingParser class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPTrimmingParser.st,v 1.3 2012-05-04 22:05:38 vrany Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPTrimmingParser.st,v 1.3 2012-05-04 22:05:38 vrany Exp $'
!

version_SVN
    ^ '§Id: PPTrimmingParser.st 2 2010-12-17 18:44:23Z vranyj1 §'
! !