--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/compiler/PPCUnknownNode.st Sun Oct 26 01:03:31 2014 +0000
@@ -0,0 +1,80 @@
+"{ Package: 'stx:goodies/petitparser/compiler' }"
+
+PPCNode subclass:#PPCUnknownNode
+ instanceVariableNames:'parser'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'PetitCompiler-Nodes'
+!
+
+PPCUnknownNode comment:''
+!
+
+!PPCUnknownNode methodsFor:'accessing'!
+
+acceptsEpsilon
+ ^ parser acceptsEpsilon
+!
+
+acceptsEpsilonOpenSet: aSet
+ ^ parser acceptsEpsilonOpenSet: aSet
+!
+
+children
+ ^ parser children
+!
+
+firstCharParser
+ ^ parser firstCharParser
+!
+
+isContextFreePrim
+ ^ parser isContextFreePrim
+!
+
+parser
+
+ ^ parser
+!
+
+parser: anObject
+
+ parser := anObject
+!
+
+prefix
+ ^ #parser
+! !
+
+!PPCUnknownNode methodsFor:'compiling'!
+
+compileWith: compiler effect: effect id: id
+ | compiledChild compiledParser |
+ compiler startMethod: id.
+
+ compiledParser := parser copy.
+ "Compile all the children and call compiled version of them instead of the original one"
+ compiledParser children do: [ :child |
+ compiledChild := child compileWith: compiler.
+ compiledParser replace: child with: compiledChild bridge.
+ ].
+
+ compiler addConstant: compiledParser as: id.
+
+ compiler addVariable: 'retval'.
+ compiler add: 'self clearError.'.
+ compiler add: '(retval := ', id, ' parseOn: context) isPetitFailure'.
+ compiler indent.
+ compiler add: ' ifTrue: [self error: retval message at: retval position ].'.
+ compiler dedent.
+ compiler add: 'error := retval isPetitFailure.'.
+ compiler add: '^ retval'.
+ ^ compiler stopMethod.
+! !
+
+!PPCUnknownNode methodsFor:'transformation'!
+
+replace: node with: anotherNode
+ parser replace: node with: anotherNode
+! !
+