PPConditionalParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 08 Sep 2015 02:40:05 +0100
changeset 543 02d90f0038fd
parent 427 a7f5e6de19d2
permissions -rw-r--r--
Poratbility: do not use #removeAtIndex: under Pharo. Pharo does not have #removeAtIndex: which is actually and ANSI protocol. But Pharoers do not like ANSI and don't give a shit about compatibility. To workaround it, use super-ugly #respondsTo: test.

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

"{ NameSpace: Smalltalk }"

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

!PPConditionalParser class methodsFor:'as yet unclassified'!

on: aPPParser block: block
	^ (PPConditionalParser on: aPPParser)
		block: block;
		yourself
! !

!PPConditionalParser methodsFor:'accessing'!

block: aBlock
	block := aBlock
! !

!PPConditionalParser methodsFor:'parsing'!

parseOn: aPPContext
	^ (block value: aPPContext) 
		ifTrue: [ parser parseOn: aPPContext ]
		ifFalse: [ PPFailure message: block asString, ' was not evaluated to true.' context: aPPContext ]
! !