332
|
1 |
"{ Package: 'stx:goodies/petitparser/gui' }"
|
|
2 |
|
|
3 |
GLMCompositePresentation subclass:#PPParserInspector
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'PetitGui-Core'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!PPParserInspector class methodsFor:'as yet unclassified'!
|
|
12 |
|
|
13 |
openOn: aParserInstance
|
|
14 |
^ self new openOn: aParserInstance
|
|
15 |
! !
|
|
16 |
|
|
17 |
!PPParserInspector methodsFor:'building'!
|
|
18 |
|
|
19 |
compose
|
|
20 |
"self new openOn: PPArithmeticParser new"
|
|
21 |
|
|
22 |
self title: [:each | 'Parser Inspector on ', (each name ifNil: [each class name])].
|
|
23 |
|
|
24 |
self tabulator with: [ :browser |
|
|
25 |
browser
|
|
26 |
column: #sample;
|
|
27 |
column: #inspectors.
|
|
28 |
(browser transmit)
|
|
29 |
fromOutsidePort: #entity;
|
|
30 |
fromOutsidePort: #sampleText;
|
|
31 |
to: #sample;
|
|
32 |
andShowIfNone: [ :a | self sampleIn: a ].
|
|
33 |
(browser transmit)
|
|
34 |
from: #sample port: #text;
|
|
35 |
toOutsidePort: #sampleText.
|
|
36 |
(browser transmit)
|
|
37 |
from: #sample; "result"
|
|
38 |
passivelyFrom: #sample port: #text; "sample text"
|
|
39 |
from: #sample port: #stream; "parser stream"
|
|
40 |
fromOutsidePort: #entity; "parser"
|
|
41 |
to: #inspectors;
|
|
42 |
andShow: [ :a | self inspectorsIn: a ].
|
|
43 |
browser transmit
|
|
44 |
from: #inspectors;
|
|
45 |
to: #sample port: #selectionInterval;
|
|
46 |
transformed: [:debugResult | debugResult ifNotNil: [debugResult start to: debugResult end] ] ]
|
|
47 |
! !
|
|
48 |
|
|
49 |
!PPParserInspector methodsFor:'private building'!
|
|
50 |
|
|
51 |
debuggerIn: composite
|
|
52 |
composite tree
|
|
53 |
title: 'Debugger';
|
|
54 |
format: [:resultNode | resultNode formattedText ];
|
|
55 |
display: [ :result :sample :stream :parser | {PPParserDebuggerResult parse: sample with: parser } ];
|
|
56 |
children: [:resultNode | resultNode children ].
|
|
57 |
!
|
|
58 |
|
|
59 |
inspectorsIn: composite
|
|
60 |
self resultIn: composite.
|
|
61 |
self debuggerIn: composite.
|
|
62 |
self tallyIn: composite.
|
|
63 |
self profileIn: composite.
|
|
64 |
self progressIn: composite
|
|
65 |
!
|
|
66 |
|
|
67 |
profileIn: composite
|
|
68 |
composite table
|
|
69 |
title: 'Profile';
|
|
70 |
column: 'Parser' evaluated: [ :each | each first displayName ];
|
|
71 |
column: 'Time (ms)' evaluated: [ :each | each second printString ];
|
|
72 |
column: 'Percentage (%)' evaluated: [ :each | each third printString ];
|
|
73 |
display: [ :result :sample :stream :parser | stream asFrequencyTable ];
|
|
74 |
noSelection;
|
|
75 |
showOnly: 50
|
|
76 |
!
|
|
77 |
|
|
78 |
progressChartIn: composite
|
|
79 |
composite morph
|
|
80 |
title: 'Progress';
|
|
81 |
display: [ :stream |
|
|
82 |
| morph |
|
|
83 |
morph := ScrollPane new.
|
|
84 |
morph color: Color white.
|
|
85 |
morph scroller addMorph: stream asPositionMorph.
|
|
86 |
morph ]
|
|
87 |
!
|
|
88 |
|
|
89 |
progressIn: composite
|
|
90 |
composite morph
|
|
91 |
title: 'Progress';
|
|
92 |
display: [:result :sample :stream :parser |
|
|
93 |
| morph |
|
|
94 |
morph := ScrollPane new.
|
|
95 |
morph color: Color white.
|
|
96 |
morph scroller addMorph: stream asPositionMorph.
|
|
97 |
morph ]
|
|
98 |
!
|
|
99 |
|
|
100 |
resultIn: composite
|
|
101 |
(composite text)
|
|
102 |
title: 'Result';
|
|
103 |
display: [ :result :sample :stream :parser | result ];
|
|
104 |
act: [ :text :result :sample :stream :parser | result inspect ] icon: GLMUIThemeExtraIcons glamorousInspect entitled: 'Inspect';
|
|
105 |
act: [ :text :result :sample :stream :parser | result explore ] icon: GLMUIThemeExtraIcons glamorousSearch entitled: 'Explore'.
|
|
106 |
!
|
|
107 |
|
|
108 |
sampleIn: composite
|
|
109 |
(composite text)
|
|
110 |
title: 'Sample';
|
|
111 |
display: [:parser :sample | sample ifNil: [''] ];
|
|
112 |
allowNil;
|
|
113 |
populate: #selection
|
|
114 |
icon: GLMUIThemeExtraIcons glamorousPlay
|
|
115 |
on: $s
|
|
116 |
entitled: 'Parse (s)'
|
|
117 |
with: [ :presentation :parser |
|
|
118 |
| stream output |
|
|
119 |
stream := PPBrowserStream on: presentation text asString.
|
|
120 |
output := parser parse: stream.
|
|
121 |
output isPetitFailure
|
|
122 |
ifTrue: [ presentation selectionInterval: (output position + 1 to: output position) ].
|
|
123 |
(presentation pane port: #stream) value: stream.
|
|
124 |
output ]
|
|
125 |
!
|
|
126 |
|
|
127 |
tallyIn: composite
|
|
128 |
composite table
|
|
129 |
title: 'Tally';
|
|
130 |
column: 'Parser' evaluated: [ :each | each first displayName ];
|
|
131 |
column: 'Count' evaluated: [ :each | each second printString ];
|
|
132 |
column: 'Percentage (%)' evaluated: [ :each | each third printString ];
|
|
133 |
display: [:result :sample :stream :parser | stream asFrequencyTable ];
|
|
134 |
noSelection;
|
|
135 |
showOnly: 50
|
|
136 |
! !
|
|
137 |
|
|
138 |
!PPParserInspector class methodsFor:'documentation'!
|
|
139 |
|
|
140 |
version
|
|
141 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPParserInspector.st,v 1.1 2014-03-04 21:14:44 cg Exp $'
|
|
142 |
!
|
|
143 |
|
|
144 |
version_CVS
|
|
145 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPParserInspector.st,v 1.1 2014-03-04 21:14:44 cg Exp $'
|
|
146 |
! !
|
|
147 |
|