gui/PPParserDebuggerResult.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 19 Mar 2016 00:12:47 +0100
changeset 556 51c6afba5c91
parent 365 5fb1869bd3c7
permissions -rw-r--r--
CI: Use VM provided by Pharo team on both Linux and Windows. Hand-crafter Pharo VM is no longer needed as the Linux slave in SWING build farm has been upgraded so it has compatible GLIBC. This makes CI scripts simpler and more usable for other people.

"{ 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 $'
! !