--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/compiler/PPCTokenNode.st Sun Oct 26 01:03:31 2014 +0000
@@ -0,0 +1,75 @@
+"{ Package: 'stx:goodies/petitparser/compiler' }"
+
+PPCDelegateNode subclass:#PPCTokenNode
+ instanceVariableNames:'tokenClass'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'PetitCompiler-Nodes'
+!
+
+PPCTokenNode comment:''
+!
+
+!PPCTokenNode methodsFor:'accessing'!
+
+initialize
+ super initialize.
+
+ "Modified: / 26-10-2014 / 01:34:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+rewrite: changeStatus
+ | |
+ super rewrite: changeStatus.
+
+ (self allNodes anySatisfy: [ :node | node asFast ~= node ]) ifTrue: [
+ changeStatus change.
+ self replace: child with: (child transform: [:node | node asFast]).
+ ]
+!
+
+tokenClass
+
+ ^ tokenClass
+!
+
+tokenClass: anObject
+
+ tokenClass := anObject
+! !
+
+!PPCTokenNode methodsFor:'as yet unclassified'!
+
+compileWith: compiler effect: effect id: id
+ | |
+
+ compiler startMethod: id.
+ compiler startTokenMode.
+ compiler addVariable: 'start'.
+ compiler addVariable: 'end'.
+
+"
+ (compiler guards and: [ (guardSet := compiler guardCharSet: self) isNil not ]) ifTrue: [
+ guardSetId := (compiler idFor: guardSet prefixed: #guard).
+ compiler addConstant: guardSet as: guardSetId.
+ compiler add: 'context atEnd ifTrue: [ ^ self error ].'.
+ compiler add: '(', guardSetId, ' value: context peek) ifFalse: [ ^ self error ].'.
+ ].
+"
+ compiler add: 'start := context position + 1.'.
+ compiler call: (self child compileWith: compiler).
+ compiler add: 'error ifTrue: [ ^ self ].'.
+ compiler add: 'end := context position.'.
+
+ compiler add: '^ ', tokenClass asString, ' on: (context collection)
+ start: start
+ stop: end
+ value: nil'.
+ compiler stopTokenMode.
+ ^ compiler stopMethod.
+!
+
+prefix
+ ^ #token
+! !
+