Mercurial > ~dholland > hg > ag > index.cgi
comparison doc/misc/html/gtrace.html @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> | |
2 <HTML> | |
3 <HEAD> | |
4 <TITLE>AnaGram's Grammar Trace Facility</TITLE> | |
5 | |
6 </HEAD> | |
7 | |
8 <BODY BGCOLOR="#ffffff" BACKGROUND="tilbl6h.gif" | |
9 TEXT="#000000" LINK="#0033CC" | |
10 VLINK="#CC0033" ALINK="#CC0099"> | |
11 | |
12 <P> | |
13 <IMG ALIGN="right" SRC="images/agrsl6c.gif" ALT="AnaGram" | |
14 WIDTH=124 HEIGHT=30> | |
15 <BR CLEAR="RIGHT"> | |
16 </P> | |
17 | |
18 <P> | |
19 Back to <A HREF="index.html">Index</A> | |
20 <IMG ALIGN="bottom" SRC="images/rbline6j.gif" ALT="----------------------" | |
21 WIDTH=1010 HEIGHT=2 > | |
22 | |
23 <H2>AnaGram's Grammar Trace</H2> | |
24 <IMG ALIGN="bottom" SRC="images/rbline6j.gif" ALT="----------------------" | |
25 WIDTH=1010 HEIGHT=2 > | |
26 | |
27 <P> | |
28 | |
29 The Grammar Trace facility lets you examine the workings of your | |
30 parser in detail, <ITALIC>interactively</ITALIC>. You can use Grammar Trace even | |
31 <ITALIC>before</ITALIC> you | |
32 write any code to attach to the rules of your grammar, and before actually | |
33 building a parser. If you have a test file available, you may prefer to use <A | |
34 HREF="ftrace.html"><STRONG>File Trace</STRONG></A>. | |
35 <P> | |
36 Using the various options associated with this trace | |
37 you can set up a representation of the parser state stack and parser | |
38 state as they might appear in the course of execution of your | |
39 parser. You can then examine the allowable input tokens and the | |
40 changes to the state and the state stack caused by any input tokens you | |
41 choose. | |
42 | |
43 <IMG ALIGN="right" SRC="gramtr6g.gif" ALT="sample Grammar Trace window" | |
44 WIDTH=489 HEIGHT=338 VSPACE=8 HSPACE=8 > | |
45 | |
46 | |
47 <P> | |
48 AnaGram now provides a combo box where you can enter input characters | |
49 for a Grammar Trace, in addition to choosing tokens. This means you can | |
50 run a Grammar Trace like a <A | |
51 HREF="ftrace.html">File Trace</A> where the test file is replaced | |
52 by the combo box characters you type. This is a very convenient way | |
53 to check out your grammar. | |
54 </P> | |
55 | |
56 <BR> | |
57 | |
58 <H3> Starting Grammar Traces:</H3> | |
59 | |
60 A Grammar Trace can be selected from either the Action Menu or the | |
61 Control Panel toolbar once your grammar has been analyzed. There are | |
62 also prebuilt grammar traces like the Conflict Trace and the | |
63 Auxiliary Trace, which can be selected from the Auxiliary Windows | |
64 popup menu for certain AnaGram windows or panes. | |
65 <P> | |
66 Like File Trace, a Grammar Trace presents three principal panes. These | |
67 are a Parser Stack pane on the left, an Allowable Input pane on the | |
68 right, and a Rule Stack pane at the bottom. | |
69 <P> | |
70 Initially, the Parser Stack will consist of a single line, which | |
71 represents the initial configuration of your parser. The first column | |
72 will show zero, which is the value of the parser stack | |
73 index. The second column will show the state number of the parser, | |
74 initially S000. The third column of the Parser Stack, which shows the | |
75 token seen at that state, is initially blank. The Rule Stack will | |
76 likewise be at level 0, state 000. The active pane of the Grammar | |
77 Trace will be the Allowable Input pane, ready for you to choose a | |
78 token. | |
79 <BR> | |
80 | |
81 <H3> Using Grammar Trace </H3> | |
82 | |
83 At any stage, the Parser Stack pane represents a parse | |
84 in progress. It shows the sequence of tokens that have | |
85 been input so far and the states in which they were | |
86 seen. When a production is complete and the grammar rule | |
87 is reduced, the tokens that make up the rule are removed | |
88 from the stack and replaced by the token on the left | |
89 side of the production. The Rule Stack pane shows you all | |
90 the grammar rules that are currently active | |
91 at any level in the stack. | |
92 <P> | |
93 | |
94 To explore your grammar, choose a token from the Allowable Input | |
95 pane. This pane shows the tokens allowable at the current state of the | |
96 grammar, and the actions that result when the tokens are chosen. | |
97 The Action field for each token shows whether it | |
98 would cause a shift or a reduction, and the new state or the rule | |
99 reduced. It is blank if the parser action is a compound action. | |
100 | |
101 <P> | |
102 Select a token by double-clicking it with the left mouse button or by | |
103 positioning the cursor bar on the token and pressing Enter. | |
104 Then the Parser Stack and Rule | |
105 Stack will be modified to reflect the input choice you made. Note | |
106 that the panes in the Grammar Trace window are synched with each | |
107 other and also with your syntax file window if it is on-screen. The | |
108 Rule Stack is particularly useful for seeing the relationship between | |
109 the Parser Stack contents and your grammar. | |
110 | |
111 <P> | |
112 You may now continue stepping through your grammar. At any time, as an | |
113 alternative to choosing tokens in the Allowable Input pane, you may | |
114 type text in the combo box at the bottom of the Grammar Trace | |
115 window and either press Enter or select the Proceed button to parse | |
116 the text. The Single Step button will accept the combo box input one | |
117 step at a time if the combo box is active, or the highlighted token | |
118 if Allowable Input is active. | |
119 | |
120 <P> You can back up the parse by | |
121 moving the cursor bar in the Parser Stack window to the desired level | |
122 and double-clicking the highlighted token in Allowable Input. You can | |
123 reset the trace to the beginning with the Reset button. | |
124 | |
125 <P> | |
126 If you are using semantically determined productions, a Reduction | |
127 Choices pane will appear to the left of the Rule Stack when it is | |
128 time to reduce such a production. Select the desired reduction token | |
129 from the pane before continuing with the parse. | |
130 | |
131 <P> | |
132 All Grammar Trace activity updates the trace coverage counts. | |
133 <P> | |
134 | |
135 <IMG ALIGN="bottom" SRC="images/rbline6j.gif" ALT="----------------------" | |
136 WIDTH=1010 HEIGHT=2 > | |
137 <P> | |
138 <IMG ALIGN="right" SRC="images/pslrb6d.gif" ALT="Parsifal Software" | |
139 WIDTH=181 HEIGHT=25> | |
140 <BR CLEAR="right"> | |
141 | |
142 <P> | |
143 Back to <A HREF="index.html">Index</A> | |
144 <P> | |
145 <ADDRESS><FONT SIZE="-1"> | |
146 AnaGram parser generator - documentation<BR> | |
147 Grammar Trace<BR> | |
148 Copyright © 1993-1999, Parsifal Software. <BR> | |
149 All Rights Reserved.<BR> | |
150 </FONT></ADDRESS> | |
151 | |
152 </BODY> | |
153 </HTML> | |
154 | |
155 |