gui/PPParserDebuggerResult.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 26 Oct 2014 01:03:31 +0000
changeset 391 553a5456963b
parent 365 5fb1869bd3c7
permissions -rw-r--r--
Ported PetitCompiler-(Tests). Name: PetitCompiler-JanKurs.41 Author: JanKurs Time: 25-10-2014, 03:30:28 AM UUID: 105186d1-1187-4ca6-8d66-3d2d47def4d3 Repository: http://smalltalkhub.com/mc/JanKurs/PetitParser/main Name: PetitCompiler-Tests-JanKurs.4 Author: JanKurs Time: 25-10-2014, 03:30:58 AM UUID: 3e798fad-d5f6-4881-a583-f0bbffe27869 Repository: http://smalltalkhub.com/mc/JanKurs/PetitParser/main In addition, fixed some problems to make it compilable under Smalltalk/X: * Fixed PPCTokenNode>>initialize - there's no children instvar, it's initialization removed. * Fixed PPCContextMemento>>propertyAt:ifAbsent: - removed return-in-return, not compilable under Smalltalk/X (C issues) * Fixed PPCContextMemento>>hash - there's no stream instvar, access to it removed. * Fixed PPCAbstractCharacterNode>>compileWith:effect:id: - removed dot after method selector (stc does not like it)

"{ Package: 'stx:goodies/petitparser/gui' }"

Object subclass:#PPParserDebuggerResult
	instanceVariableNames:'parser result children parent start end'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitGui-Core'
!


!PPParserDebuggerResult class methodsFor:'instance creation'!

new
    ^ self basicNew initialize
!

parse: aStream with: parser 
        | root newParser |
        root := self new.
        newParser := parser transform: [:each |
                each name isNil 
                        ifTrue: [ each ]
                        ifFalse: [
                                each >=> [:stream :continuation | 
                                        | result child |
                                        child := PPParserDebuggerResult new 
                                                        parser: each;
                                                        parent: root.
                                        root := root children add: child.
                                        child start: stream position + 1.
                                        result := continuation value.
                                        child end: stream position.
                                        root result: result.
                                        root := root parent.
                                        result ]]].
        newParser parse: aStream.
        ^ root children first
! !

!PPParserDebuggerResult methodsFor:'accessing'!

children
	^ children
!

children: anObject
	children := anObject
!

end
	^ end
!

end: anObject
	end := anObject
!

parent
	^ parent
!

parent: anObject
	parent := anObject
!

parser
	^ parser
!

parser: anObject
	parser := anObject
!

result
	^ result
!

result: anObject
	result := anObject
!

start
	^ start
!

start: anObject
	start := anObject
! !

!PPParserDebuggerResult methodsFor:'initialization'!

initialize 
	children := OrderedCollection new
! !

!PPParserDebuggerResult methodsFor:'printing'!

formattedText
	^ self result isPetitFailure 
		ifTrue: [ Text string: self printString attribute: TextColor gray ]
		ifFalse: [ self printString]
!

printOn: aStream 
	aStream 
		nextPutAll: self parser name;
		nextPutAll: ' - ';   
		nextPutAll: self result printString
! !

!PPParserDebuggerResult class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPParserDebuggerResult.st,v 1.2 2014-03-04 23:58:31 cg Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPParserDebuggerResult.st,v 1.2 2014-03-04 23:58:31 cg Exp $'
! !