compiler/PPCPlusNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 19 Apr 2015 22:25:38 +0100
changeset 430 77cf8e710a8e
parent 422 116d2b2af905
child 438 20598d7ce9fa
permissions -rw-r--r--
Added dependencies on petitparser/analyzer and petitparser/islands ...as compiler makes use of some of their extension methods.

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

"{ NameSpace: Smalltalk }"

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.
!

followSets: aFollowDictionary firstSets: aFirstDictionary into: aSet suchThat: aBlock
	| first |
	super followSets: aFollowDictionary firstSets:  aFirstDictionary into: aSet suchThat: aBlock.
	
	first := aFirstDictionary at: self.
	(aFollowDictionary at: child) addAll: (first reject: [:each | each isNullable])
!

prefix
	^ #plus
! !

!PPCPlusNode class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !