compiler/PPCActionNode.st
changeset 391 553a5456963b
child 392 9b297f0d949c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compiler/PPCActionNode.st	Sun Oct 26 01:03:31 2014 +0000
@@ -0,0 +1,49 @@
+"{ Package: 'stx:goodies/petitparser/compiler' }"
+
+PPCAbstractActionNode subclass:#PPCActionNode
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitCompiler-Nodes'
+!
+
+PPCActionNode comment:''
+!
+
+!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
+	]
+! !
+