PPFlattenParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 08 Oct 2014 21:56:20 +0100
changeset 388 74c9c229033b
parent 377 6112a403a52d
child 502 1e45d3c96ec5
permissions -rw-r--r--
Workaround to fix PPComposedTest>>testLeftRecursion - make PPStream>>size returning size of the input. For whatever reason, in Smalltalk/X ReadStream>>size returns size remaning data, not the size of a whole stream. This is a bug and should be fixed in Smalltalk/X libbasic. Meanwhile, override PPStream>>size to return proper value. In Pharo, the method is not needed as the inherited method is exactly the same.

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

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


!PPFlattenParser methodsFor:'hooks'!

create: aCollection start: aStartInteger stop: aStopInteger
	^ aCollection copyFrom: aStartInteger to: aStopInteger
! !

!PPFlattenParser methodsFor:'parsing'!

parseOn: aPPContext
	| start element |
	start := aPPContext position.
	element := parser parseOn: aPPContext.
	element isPetitFailure ifTrue: [ ^ element ].
	^ self on: aPPContext stream collection start: start + 1 stop: aPPContext position value: element
! !

!PPFlattenParser methodsFor:'private'!

on: aCollection start: aStartInteger stop: aStopInteger value: anObject
	^ aCollection copyFrom: aStartInteger to: aStopInteger
! !

!PPFlattenParser class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPFlattenParser.st,v 1.4 2014-03-04 14:32:30 cg Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPFlattenParser.st,v 1.4 2014-03-04 14:32:30 cg Exp $'
!

version_SVN
    ^ '$Id: PPFlattenParser.st,v 1.4 2014-03-04 14:32:30 cg Exp $'
! !