Mercurial > ~dholland > hg > ag > index.cgi
comparison doc/manual/intro.tex @ 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 % This file was converted by WP2LaTeX version 2.99 | |
2 % (and modified a lot afterwards) | |
3 | |
4 %\baselineskip=2.00ex | |
5 % | |
6 %\headtext{\evenpages}{ | |
7 %\thepage AnaGram User's Guide | |
8 %} | |
9 %\foottext{\allpages}{ | |
10 %\strut\hfill \today{} | |
11 %} | |
12 %\headtext{\oddpages}{ | |
13 %Chapter 1\hfill Introduction\thepage | |
14 %} | |
15 %\vspace{2.55cm}% | |
16 %\begin{flushright} | |
17 % | |
18 %\section{{ Chapter 1 | |
19 %Introduction to AnaGram}} | |
20 %\end{flushright} | |
21 | |
22 \chapter{Introduction to AnaGram} | |
23 | |
24 AnaGram is a software development tool which brings the power of | |
25 syntax directed parsing to the C or C++ programmer. AnaGram provides | |
26 a rule-based, non-procedural system for dealing with input to computer | |
27 programs. | |
28 | |
29 AnaGram is a completely new LALR parser generator with a powerful | |
30 notation for representing context free grammars. A flexible, | |
31 interactive environment combined with powerful debugging capabilities | |
32 and language extensions make it easy to incorporate syntax directed | |
33 parsing in your programs. AnaGram makes it possible for you to reap | |
34 the benefits of syntax directed parsing on all of your projects, big | |
35 and small. | |
36 | |
37 Syntax directed parsing has long been recognized as the most powerful | |
38 technique available for interpreting program input. Up to now, the | |
39 tools available to the software developer to support this technique | |
40 have been primitive and hard to use, suitable mainly for compilers and | |
41 other large projects. AnaGram was specifically designed to make | |
42 syntax directed parsing accessible to the software developer for | |
43 everyday use. | |
44 | |
45 Few portions of a program are more prone to errors than the logic that | |
46 deciphers the input to the program. To interpret its input a program | |
47 usually needs many flags and switches, many tests, and a lot of | |
48 conditional code. Of necessity such a program has many paths and many | |
49 opportunities to go awry. Such code is hard to write, hard to | |
50 document, hard to debug and hard to maintain. | |
51 | |
52 With AnaGram, you can completely separate the analysis of input from | |
53 the processing of data. Instead of writing a detailed procedure for | |
54 interpreting input, you write a {\it description} of that input using | |
55 an adaptation of | |
56 % noindex | |
57 Backus-Naur Form, or BNF. | |
58 AnaGram builds for you, | |
59 based on your description, a procedure to interpret your input. All | |
60 those tests, all that conditional code, all those flags and switches | |
61 vanish. In a convenient way you can attach, to the procedure, code to | |
62 process the data once it is identified in the input stream. Your | |
63 input processing now takes on the aspect of a rule-based, | |
64 non-procedural system. | |
65 | |
66 There are many benefits to this approach. Your program is easier to | |
67 understand. It is easier to debug. It is easier to extend and | |
68 maintain. A large project can be more easily divided up among the | |
69 members of your team. The description, or grammar, of your input can | |
70 serve as solid and reliable documentation. You will also find that it | |
71 becomes much easier to re-use code on other projects, because the data | |
72 processing is cleanly separated from the parsing, or input analysis. | |
73 | |
74 These benefits are now available because AnaGram, in addition to | |
75 implementing the basic algorithms of an LALR parser generator, | |
76 provides powerful new features that make syntax directed parsing a | |
77 practical reality. Here is a summary of some of the more important | |
78 features of AnaGram: | |
79 | |
80 \paragraph{Interactive File Trace.} | |
81 An online | |
82 % noindex | |
83 \agwindow{File Trace} function lets you run test files through your | |
84 grammar interactively. You can see how your parser will interpret | |
85 them. You can see the contents of the parse stack. You can see the | |
86 grammar rules that are partially matched at any stage in the parse. | |
87 You can back up the parse to any point and try again. You can go | |
88 through a test file in single step mode, one character at a time, or | |
89 simply parse the whole file to see if it has any errors. While | |
90 interpreting your grammar and parsing your file, AnaGram will count | |
91 the number of times each grammar rule is matched and give you a report | |
92 so you can assess the thoroughness of your testing. | |
93 | |
94 \paragraph{Grammar Trace.} | |
95 The | |
96 % noindex | |
97 \agwindow{Grammar Trace} is another feature which allows you to | |
98 inspect the workings of your parser interactively. It is particularly | |
99 suited for dealing with ``what if?'' questions. You can work through | |
100 a parse at whatever level of detail is necessary to see how an error | |
101 arises, to see the nature of an ambiguity, or simply to gain | |
102 confidence in the way the parser works. In case of certain types of | |
103 errors, AnaGram will provide pre-built grammar traces to illustrate | |
104 the problem. | |
105 | |
106 \paragraph{Other Debugging Tools.} | |
107 AnaGram provides a number of debugging tools that can help you get | |
108 your program up and running on schedule. In particular, AnaGram has | |
109 powerful tools for identifying ambiguities in your grammar. AnaGram | |
110 also has coverage analysis facilities to help you ascertain the | |
111 effectiveness of your test suites. | |
112 | |
113 When AnaGram analyzes a grammar, it creates numerous tables describing | |
114 various aspects of the grammar. To facilitate inspection of these | |
115 tables, AnaGram has an interactive interface to enable you to find | |
116 quickly any problems in your grammar. An extensive, on-line help | |
117 system provides quick online answers to the questions you have about | |
118 AnaGram. | |
119 | |
120 \paragraph{No Lexical Scanner Required.} | |
121 \index{Lexical scanner} | |
122 When you use AnaGram, you seldom have to use a ``lexical scanner'', or | |
123 input processor, written in still another programming language, to | |
124 ``tokenize'' character-based input for your parser. Instead, you can | |
125 specify {\it all} the details of the input stream directly in your | |
126 grammar in a natural way. If those details need to be changed, you | |
127 can make all the changes in one place and rebuild your parser without | |
128 having to deal with a cumbersome lexical scanner interface. AnaGram | |
129 accomplishes this by providing a notation that allows you to specify | |
130 keywords and character sets simply and intuitively. AnaGram also | |
131 provides options for selectively ignoring white space or other | |
132 uninteresting characters in your input. | |
133 | |
134 On the other hand, if you already have a lexical scanner, or some | |
135 other data source, you can interface it cleanly and simply to a parser | |
136 AnaGram generates. If the nature of your problem requires a lexical | |
137 scanner, or multi-stage parsing, you can use AnaGram for each level of | |
138 parsing. | |
139 | |
140 \paragraph{Flexible Interfacing.} | |
141 AnaGram provides numerous ways for you to interface your parser to the | |
142 rest of your program. Since you can even configure a parser to work | |
143 in an event driven mode, you can use AnaGram very effectively to deal | |
144 with the new programming styles required by modern window based | |
145 operating systems. | |
146 | |
147 AnaGram provides new notation for linking data to your processing | |
148 routines. Symbolic hooks tie syntactic constructs directly to your C | |
149 or C++ code. The processing routines are easier to write and to | |
150 modify. You can also modify your grammar without having to alter your | |
151 data processing routines. | |
152 | |
153 \paragraph{Virtual Productions.} | |
154 AnaGram provides a powerful, intuitive shorthand notation to help you | |
155 to describe many commonly occurring syntactic forms, such as optional | |
156 elements, lists, and simple sets of options. | |
157 | |
158 \paragraph{Semantic Control over Syntactic Analysis.} | |
159 Extensions to the basic algorithms for developing LALR parsers allow | |
160 you to exert semantic control over syntactic processing by using a new | |
161 feature called ``semantically determined productions''. | |
162 | |
163 \paragraph{Precise Control over White Space.} | |
164 Convenient attribute statements allow you to skip white space and | |
165 comments where they are meaningless, but recognize them where it | |
166 matters. | |
167 | |
168 \paragraph{Easy Configuration.} | |
169 An extensive set of configuration switches and parameters allow you to | |
170 configure both AnaGram and the parsers you build to your precise | |
171 requirements. Wherever AnaGram provides options, it also provides | |
172 sensible defaults, so that you can ignore most switches and parameters | |
173 until you need the capability they control. | |
174 |