compiler/PPCTokenActionNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 19 Apr 2015 22:25:38 +0100
changeset 430 77cf8e710a8e
parent 422 116d2b2af905
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 }"

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

!PPCTokenActionNode methodsFor:'as yet unclassified'!

asFast
	^ self
!

compileWith: compiler effect: effect id: id
	|  |
	compiler addConstant: block as: id.

	"
		Actually, do nothing, we are in Token mode and the 
		child does not return any result and token takes only
		the input value.
	"	
	compiler startMethod: id.
	compiler add: '^ '.
	compiler callOnLine: (child compileWith: compiler).
 ^ compiler stopMethod.
!

rewrite: changeStatus
	(self hasProperty: #trimmingToken) ifTrue: [ 
		| retval |
		changeStatus change.
		"Get rid of action and sequence with whitespace"
		retval := child children second child. 	"JK: oups, what a chain!!"
		retval name ifNil: [ retval name: self name ].
		^ retval
	].

	child name ifNil: [  
		changeStatus change.
		child name: self name.
		^ child
	].

	(child name = self name) ifTrue: [ 
		changeStatus change.
		^ child
	]
!

suffix
	^ '_fast'
! !