PPActionParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 02 Jun 2015 00:16:55 +0100
changeset 479 6316a98b7150
parent 377 6112a403a52d
permissions -rw-r--r--
Action inlining [1/x]: Initial support for inlining actions parsers (i.e., ==>) The code of the action is now inlined into parsing method rather then delegated to stored block. Mapping parser (i.e., map:[...]) are not supported and not detected, so using them cause crash. This will be fixed later.

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

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


!PPActionParser class methodsFor:'instance creation'!

on: aParser block: aBlock
	^ (self on: aParser) setBlock: aBlock
! !


!PPActionParser methodsFor:'accessing'!

block
	"Answer the action block of the receiver."

	^ block
! !

!PPActionParser methodsFor:'initialization'!

setBlock: aBlock
	block := aBlock
! !

!PPActionParser methodsFor:'parsing'!

parseOn: aPPContext
	| element |
	^ (element := parser parseOn: aPPContext) isPetitFailure
		ifFalse: [ block value: element ]
		ifTrue: [ element ]
! !

!PPActionParser class methodsFor:'documentation'!

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

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

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