gui/PPParserDebuggerResult.st
changeset 331 33ef8249a32b
child 365 5fb1869bd3c7
equal deleted inserted replaced
330:d807737e23f8 331:33ef8249a32b
       
     1 "{ Package: 'stx:goodies/petitparser/gui' }"
       
     2 
       
     3 Object subclass:#PPParserDebuggerResult
       
     4 	instanceVariableNames:'parser result children parent start end'
       
     5 	classVariableNames:''
       
     6 	poolDictionaries:''
       
     7 	category:'PetitGui-Core'
       
     8 !
       
     9 
       
    10 
       
    11 !PPParserDebuggerResult class methodsFor:'instance creation'!
       
    12 
       
    13 parse: aStream with: parser 
       
    14 	| root newParser |
       
    15 	root := self new.
       
    16 	newParser := parser transform: [:each |
       
    17 		each name isNil 
       
    18 			ifTrue: [ each ]
       
    19 			ifFalse: [
       
    20 				each >=> [:stream :continuation | 
       
    21 					| result child |
       
    22 					child := PPParserDebuggerResult new 
       
    23 							parser: each;
       
    24 							parent: root.
       
    25 					root := root children add: child.
       
    26 					child start: stream position + 1.
       
    27 					result := continuation value.
       
    28 					child end: stream position.
       
    29 					root result: result.
       
    30 					root := root parent.
       
    31 					result ]]].
       
    32 	newParser parse: aStream.
       
    33 	^ root children first
       
    34 ! !
       
    35 
       
    36 !PPParserDebuggerResult methodsFor:'accessing'!
       
    37 
       
    38 children
       
    39 	^ children
       
    40 !
       
    41 
       
    42 children: anObject
       
    43 	children := anObject
       
    44 !
       
    45 
       
    46 end
       
    47 	^ end
       
    48 !
       
    49 
       
    50 end: anObject
       
    51 	end := anObject
       
    52 !
       
    53 
       
    54 parent
       
    55 	^ parent
       
    56 !
       
    57 
       
    58 parent: anObject
       
    59 	parent := anObject
       
    60 !
       
    61 
       
    62 parser
       
    63 	^ parser
       
    64 !
       
    65 
       
    66 parser: anObject
       
    67 	parser := anObject
       
    68 !
       
    69 
       
    70 result
       
    71 	^ result
       
    72 !
       
    73 
       
    74 result: anObject
       
    75 	result := anObject
       
    76 !
       
    77 
       
    78 start
       
    79 	^ start
       
    80 !
       
    81 
       
    82 start: anObject
       
    83 	start := anObject
       
    84 ! !
       
    85 
       
    86 !PPParserDebuggerResult methodsFor:'initialization'!
       
    87 
       
    88 initialize 
       
    89 	children := OrderedCollection new
       
    90 ! !
       
    91 
       
    92 !PPParserDebuggerResult methodsFor:'printing'!
       
    93 
       
    94 formattedText
       
    95 	^ self result isPetitFailure 
       
    96 		ifTrue: [ Text string: self printString attribute: TextColor gray ]
       
    97 		ifFalse: [ self printString]
       
    98 !
       
    99 
       
   100 printOn: aStream 
       
   101 	aStream 
       
   102 		nextPutAll: self parser name;
       
   103 		nextPutAll: ' - ';   
       
   104 		nextPutAll: self result printString
       
   105 ! !
       
   106 
       
   107 !PPParserDebuggerResult class methodsFor:'documentation'!
       
   108 
       
   109 version
       
   110     ^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPParserDebuggerResult.st,v 1.1 2014-03-04 21:14:37 cg Exp $'
       
   111 !
       
   112 
       
   113 version_CVS
       
   114     ^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPParserDebuggerResult.st,v 1.1 2014-03-04 21:14:37 cg Exp $'
       
   115 ! !
       
   116