initial checkin
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 05 May 2012 16:48:51 +0200
changeset 75 11f265240739
parent 68 21381bc66c96
child 76 3a7ad5256cd9
initial checkin
devtools/PPDebugger.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devtools/PPDebugger.st	Sat May 05 16:48:51 2012 +0200
@@ -0,0 +1,75 @@
+"{ Package: 'stx:goodies/petitparser/devtools' }"
+
+Object subclass:#PPDebugger
+	instanceVariableNames:'indent'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitParser-Debugging'
+!
+
+
+!PPDebugger class methodsFor:'instance creation'!
+
+new
+    "return an initialized instance"
+
+    ^ self basicNew initialize.
+! !
+
+!PPDebugger methodsFor:'events'!
+
+enterParser: aPPParser stream: aStream
+
+    indent timesRepeat:[Transcript nextPutAll:'    '].
+    Transcript nextPutAll:'{ '.
+    Transcript nextPutAll: aPPParser name ? aPPParser printString.
+    Transcript nextPutAll: ' pos = '; nextPutAll: aStream position.
+    Transcript cr.
+    indent := indent + 1.
+
+    "Created: / 12-03-2012 / 16:41:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+leaveParser: aPPParser stream: aStream result: result
+
+    indent := indent - 1.
+    indent timesRepeat:[Transcript nextPutAll:'    '].
+    Transcript nextPutAll:'} '.
+    Transcript nextPutAll: aPPParser name ? aPPParser printString.
+    Transcript nextPutAll: ' pos = '; nextPutAll: aStream position.
+    Transcript nextPutAll: ' result = '.
+    result isPetitFailure ifTrue:[
+        Transcript nextPutAll: 'FAILURE '.
+    ].
+    Transcript nextPutAll: result printString.
+    Transcript cr.
+
+    "Created: / 12-03-2012 / 16:41:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!PPDebugger methodsFor:'initialization'!
+
+initialize
+    "Invoked when a new instance is created."
+
+    "/ please change as required (and remove this comment)
+    indent := 0.
+
+    "/ super initialize.   -- commented since inherited method does nothing
+
+    "Modified: / 12-03-2012 / 16:41:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!PPDebugger class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/goodies/petitparser/devtools/PPDebugger.st,v 1.1 2012-05-05 14:48:51 vrany Exp $'
+!
+
+version_CVS
+    ^ '$Header: /cvs/stx/stx/goodies/petitparser/devtools/PPDebugger.st,v 1.1 2012-05-05 14:48:51 vrany Exp $'
+!
+
+version_SVN
+    ^ '§Id: PPDebugger.st 10 2012-05-04 18:54:13Z vranyj1 §'
+! !