PPChoiceParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 05 May 2012 00:01:37 +0200
changeset 23 93f28e32de35
parent 4 90de244a7fa2
child 36 4fe8e6295f9e
permissions -rw-r--r--
Checkin from browser

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

PPListParser subclass:#PPChoiceParser
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitParser-Parsers'
!

PPChoiceParser comment:'A parser that uses the first parser that succeeds.'
!


!PPChoiceParser methodsFor:'operations'!

/ aRule
	^ self copyWith: aRule
! !

!PPChoiceParser methodsFor:'parsing'!

parseOn: aStream
	"This is optimized code that avoids unnecessary block activations, do not change. When all choices fail, the last failure is answered."

	| element |
	1 to: parsers size do: [ :index |
		element := (parsers at: index)
			parseOn: aStream.
		element isPetitFailure
			ifFalse: [ ^ element ] ].
	^ element
! !

!PPChoiceParser class methodsFor:'documentation'!

version_SVN
    ^ '$Id: PPChoiceParser.st,v 1.2 2012-01-13 11:22:50 cg Exp $'
! !