compiler/PPCOptionalNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 30 Oct 2014 23:01:54 +0000
changeset 398 b3e47bab2de6
parent 392 9b297f0d949c
child 421 7e08b31e0dae
permissions -rw-r--r--
Added teardown to PetitCompilerTests to clean up a generated parser after tests.

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

PPCDelegateNode subclass:#PPCOptionalNode
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Nodes'
!

!PPCOptionalNode methodsFor:'as yet unclassified'!

acceptsEpsilon
	^ true
!

acceptsEpsilonOpenSet: set
	^ true
!

compileWith: compiler effect: effect id: id
	compiler startMethod: id.
	compiler addVariable: 'retval'.

	compiler add: 'retval := '.
	compiler callOnLine: (child compileWith: compiler ).
	compiler add: '^ error ifFalse: [ retval ] ifTrue: [ self clearError. nil ]'.
 ^ compiler stopMethod.
!

prefix
	^ #opt
! !