comparison doc/misc/html/examples/rcalc.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 <TITLE>Roman Numeral Calculator</TITLE>
3 </HEAD>
4
5
6 <BODY BGCOLOR="#ffffff" BACKGROUND="tilbl6h.gif"
7 TEXT="#000000" LINK="#0033CC"
8 VLINK="#CC0033" ALINK="#CC0099">
9
10 <P>
11 <IMG ALIGN="right" SRC="../images/agrsl6c.gif" ALT="AnaGram"
12 WIDTH=124 HEIGHT=30 >
13 <BR CLEAR="all">
14 Back to <A HREF="../index.html">Index</A>
15 <P>
16 <IMG ALIGN="bottom" SRC="../images/rbline6j.gif" ALT="----------------------"
17 WIDTH=1010 HEIGHT=2 >
18 <P>
19
20 <H1>Roman Numeral Calculator</H1>
21 <IMG ALIGN="bottom" SRC="../images/rbline6j.gif" ALT="----------------------"
22 WIDTH=1010 HEIGHT=2 >
23 <P>
24 <H2>Introduction</H2>
25 <P>
26 <tt>rcalc</tt> is a simple four function desk calculator program
27 which accepts its input and displays its output in Roman
28 numerals. The source code for <tt>rcalc</tt> is completely contained
29 in the file <tt>rcalc.syn</tt>.
30
31 <tt>rcalc</tt> illustrates the following AnaGram features:
32 <UL>
33 <LI> pointer input </LI>
34 <LI> <tt>SYNTAX_ERROR</tt> macro </LI>
35 <LI> context tracking </LI>
36 </UL>
37 <P>
38
39 <H2> Building RCALC </H2>
40 To build a working copy of <tt>rcalc</tt>, you need to carry out the
41 following steps:
42 <UL>
43 <LI> 1. Run Anagram and build a parser for <tt>rcalc</tt> </LI>
44 <LI> 2. Using your C compiler, compile and link <tt>rcalc.c</tt>. </LI>
45 </UL>
46 <P>
47
48 <H2> Running RCALC </H2>
49 When you run <tt>rcalc</tt> (from the command line), it will
50 display a '<CODE>#</CODE>' prompt. Type an
51 arithmetic expression in Roman numerals, using either upper
52 or lower case letters. <tt>rcalc</tt> will accept addition,
53 subtraction, multiplication and division operations, as well
54 as unary negation, using integer arithmetic. It respects the
55 conventional order of operations. You may use spaces and tabs
56 freely when you type the expression and parentheses to
57 override the natural order of computation. You may use the
58 word <tt>NIHIL</tt> to represent zero.
59 <P>
60 When you have typed your expression, press Enter. <tt>rcalc</tt> will
61 parse your expression, and if it has no syntax errors, <tt>rcalc</tt>
62 will display the result in Roman numerals. If there is a
63 syntax error, or if you tried to divide by zero, <tt>rcalc</tt> will
64 display a diagnostic message, showing the location of the
65 error. You may exit the program by pressing Enter at the
66 prompt.
67
68
69 <BR><BR><BR>
70 <H2> Theory of Operation </H2>
71 <tt>rcalc</tt>, like Gaul, is divided into three parts: reading
72 input, interpreting Roman numerals, and evaluating
73 expressions.
74 <P>
75 In <tt>rcalc</tt>, the main program, written in C, displays a prompt,
76 reads a line of input, calls the parser to interpret it, and
77 loops until it encounters end of file. The <tt>rcalc</tt> parser uses
78 "pointer input" to parse a string already in memory. The
79 main program needs only to set the "pointer" field in the
80 parser control block to point to the string before calling
81 the parser.
82 <P>
83 The syntax for the Roman numerals consists of
84 straightforward enumeration of the possibilities. At every
85 level but the thousands, there are a number of special
86 cases, and at every level including the thousands there is
87 the possibility of repetition. The major complicating factor
88 is that every field, from the thousands to the units, is
89 optional, but at least one field has to be present.
90 <P>
91 The expression logic is simply the conventional syntax for
92 the basic arithmetic functions.
93 </P>
94
95 <BR>
96
97 <IMG ALIGN="bottom" SRC="../images/rbline6j.gif" ALT="----------------------"
98 WIDTH=1010 HEIGHT=2 >
99 <P>
100 <IMG ALIGN="right" SRC="../images/pslrb6d.gif" ALT="Parsifal Software"
101 WIDTH=181 HEIGHT=25>
102 <BR CLEAR="right">
103 <P>
104 Back to <A HREF="../index.html">Index</A>
105 <P>
106 <ADDRESS><FONT SIZE="-1"><BR><BR>
107 AnaGram parser generator - examples<BR>
108 Roman Numeral Calculator <BR>
109 Copyright (c) MCMXCIII-MCMXCIX, Parsifal Software. <BR>
110 All Rights Reserved. <BR>
111 </FONT></ADDRESS>
112
113 </BODY>
114 </HTML>
115
116