compiler/PPCActionNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 01 Nov 2014 00:30:28 +0000
changeset 403 7063d523b064
parent 392 9b297f0d949c
child 414 0eaf09920532
permissions -rw-r--r--
Removed autoload attribut for tests. As all classes are in a test package, when package is loaded likely tests are required, so load them right away.

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

PPCAbstractActionNode subclass:#PPCActionNode
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Nodes'
!

!PPCActionNode methodsFor:'as yet unclassified'!

compileWith: compiler effect: effect id: id
	compiler addConstant: block as: id.
	
	compiler startMethod: id.
	compiler addVariable: 'element'.
	compiler add: 'element := '.
	compiler callOnLine: (child compileWith: compiler).
	compiler add: 'error ifFalse: [ ^ ',  id, ' value: element ].'.
	compiler add: '^ failure'.
 ^ compiler stopMethod.
!

rewrite: changeStatus
	"TODO JK: Find another way how to recognize the trimming token!!"
	(name = 'trimmingToken') ifTrue: [ 
		changeStatus change.
		^ PPCTrimmingTokenNode new
			"name: name"
			"JK: I am sorry"
			child: child children second child;
			tokenClass: child children second tokenClass;
			whitespace: child children first;
			yourself
	].
	
	block isSymbol ifTrue: [ 
		changeStatus change.
		^ PPCSymbolActionNode new
			block: block;
			name: name;
			child: child;
			yourself
	]
! !