compiler/PPCPlusNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 05 Nov 2014 21:40:01 +0000
changeset 413 5389e6fbb3bc
parent 392 9b297f0d949c
child 421 7e08b31e0dae
permissions -rw-r--r--
Classes renamed to ease following merge wirh Pharo version. * PetitBenchmark renamed to PPCBenchmark * PetitBenchmarkSources renamed to PPCBenchmarkResources * PetitCompilerTest renamed to PPCCompilerTest

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

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

!PPCPlusNode methodsFor:'as yet unclassified'!

compileWith: compiler effect: effect id: id
		
	compiler startMethod: id.
	compiler addVariable: 'retval'.
	compiler addVariable: 'element'.
		
	compiler add: 'retval := OrderedCollection new.'.
	compiler add: 'element := '.
	compiler callOnLine: (child compileWith: compiler).
	compiler add: 'error ifTrue: [ ^ self error: ''at least one occurence expected'' ].'.
	compiler add: 'retval add: element.'.
	
	compiler add: 'element := '.
	compiler callOnLine: (child compileWith: compiler).
	compiler add: '[ error ] whileFalse: ['.
	compiler indent.
	compiler add: 'retval add: element.'.
	compiler add: 'element := '.
	compiler callOnLine: (child compileWith: compiler).
	compiler dedent.
	compiler add: '].'.
	compiler add: 'self clearError.'.
	compiler add: '^ retval asArray'.
 ^ compiler stopMethod.
!

prefix
	^ #plus
! !