author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 25 May 2015 02:49:22 +0100 | |
changeset 472 | 72074e22bd61 |
parent 365 | 5fb1869bd3c7 |
permissions | -rw-r--r-- |
331 | 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 |
||
365
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
13 |
new |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
14 |
^ self basicNew initialize |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
15 |
! |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
16 |
|
331 | 17 |
parse: aStream with: parser |
365
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
18 |
| root newParser | |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
19 |
root := self new. |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
20 |
newParser := parser transform: [:each | |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
21 |
each name isNil |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
22 |
ifTrue: [ each ] |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
23 |
ifFalse: [ |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
24 |
each >=> [:stream :continuation | |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
25 |
| result child | |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
26 |
child := PPParserDebuggerResult new |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
27 |
parser: each; |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
28 |
parent: root. |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
29 |
root := root children add: child. |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
30 |
child start: stream position + 1. |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
31 |
result := continuation value. |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
32 |
child end: stream position. |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
33 |
root result: result. |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
34 |
root := root parent. |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
35 |
result ]]]. |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
36 |
newParser parse: aStream. |
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
37 |
^ root children first |
331 | 38 |
! ! |
39 |
||
40 |
!PPParserDebuggerResult methodsFor:'accessing'! |
|
41 |
||
42 |
children |
|
43 |
^ children |
|
44 |
! |
|
45 |
||
46 |
children: anObject |
|
47 |
children := anObject |
|
48 |
! |
|
49 |
||
50 |
end |
|
51 |
^ end |
|
52 |
! |
|
53 |
||
54 |
end: anObject |
|
55 |
end := anObject |
|
56 |
! |
|
57 |
||
58 |
parent |
|
59 |
^ parent |
|
60 |
! |
|
61 |
||
62 |
parent: anObject |
|
63 |
parent := anObject |
|
64 |
! |
|
65 |
||
66 |
parser |
|
67 |
^ parser |
|
68 |
! |
|
69 |
||
70 |
parser: anObject |
|
71 |
parser := anObject |
|
72 |
! |
|
73 |
||
74 |
result |
|
75 |
^ result |
|
76 |
! |
|
77 |
||
78 |
result: anObject |
|
79 |
result := anObject |
|
80 |
! |
|
81 |
||
82 |
start |
|
83 |
^ start |
|
84 |
! |
|
85 |
||
86 |
start: anObject |
|
87 |
start := anObject |
|
88 |
! ! |
|
89 |
||
90 |
!PPParserDebuggerResult methodsFor:'initialization'! |
|
91 |
||
92 |
initialize |
|
93 |
children := OrderedCollection new |
|
94 |
! ! |
|
95 |
||
96 |
!PPParserDebuggerResult methodsFor:'printing'! |
|
97 |
||
98 |
formattedText |
|
99 |
^ self result isPetitFailure |
|
100 |
ifTrue: [ Text string: self printString attribute: TextColor gray ] |
|
101 |
ifFalse: [ self printString] |
|
102 |
! |
|
103 |
||
104 |
printOn: aStream |
|
105 |
aStream |
|
106 |
nextPutAll: self parser name; |
|
107 |
nextPutAll: ' - '; |
|
108 |
nextPutAll: self result printString |
|
109 |
! ! |
|
110 |
||
111 |
!PPParserDebuggerResult class methodsFor:'documentation'! |
|
112 |
||
113 |
version |
|
365
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
114 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPParserDebuggerResult.st,v 1.2 2014-03-04 23:58:31 cg Exp $' |
331 | 115 |
! |
116 |
||
117 |
version_CVS |
|
365
5fb1869bd3c7
class: PPParserDebuggerResult
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
118 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPParserDebuggerResult.st,v 1.2 2014-03-04 23:58:31 cg Exp $' |
331 | 119 |
! ! |
120 |