Mercurial > ~dholland > hg > ag > index.cgi
comparison doc/misc/html/examples/ffcalc.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>Four Function Calculator</TITLE> | |
5 </HEAD> | |
6 | |
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="all"> | |
16 Back to <A HREF="../index.html">Index</A> | |
17 <P> | |
18 <IMG ALIGN="bottom" SRC="../images/rbline6j.gif" ALT="----------------------" | |
19 WIDTH=1010 HEIGHT=2 > | |
20 <P> | |
21 | |
22 <H1>Four Function Calculator</H1> | |
23 | |
24 <IMG ALIGN="bottom" SRC="../images/rbline6j.gif" ALT="----------------------" | |
25 WIDTH=1010 HEIGHT=2 > | |
26 <P> | |
27 <H2>Introduction</H2> | |
28 <P> | |
29 <tt>ffcalc.syn</tt> implements a simple four function | |
30 calculator. The | |
31 calculator has 52 registers, labeled 'a' through 'z' and 'A' | |
32 through 'Z'. <tt>ffcalc</tt> evaluates arithmetic expressions and | |
33 assignment statements and prints the results. The | |
34 expressions may contain '<CODE>+</CODE>', '<CODE>-</CODE>', | |
35 '<CODE>*</CODE>', and '<CODE>/</CODE>' operators as | |
36 well as parentheses. In addition, <tt>ffcalc</tt> supports | |
37 the free | |
38 use of white space and C style comments in the input. It | |
39 also includes syntax error handling, including a diagnostic | |
40 message, and resynchronization. | |
41 <P> | |
42 <tt>ffcalcmx.syn</tt> is a simple variation on | |
43 <tt>ffcalc.syn</tt>. The only | |
44 difference between the two grammars is that <tt>ffcalcx</tt> uses a | |
45 deliberately ambiguous grammar for expressions, with | |
46 precedence statements to resolve the ambiguities. | |
47 <P> | |
48 | |
49 <H2>Building FFCALC</H2> | |
50 To build a working copy of <tt>ffcalc</tt>, you need to | |
51 carry out the following steps: | |
52 <UL> | |
53 <LI> 1. Run Anagram and build a parser for <tt>ffcalc.syn</tt>. </LI> | |
54 <LI> 2. Using your C compiler, compile and link <tt>ffcalc.c</tt>. </LI> | |
55 </UL> | |
56 <P> | |
57 | |
58 <H2>Running FFCALC</H2> | |
59 <tt>ffcalc</tt> reads expressions and assignment statements from | |
60 stdin. You may either type input directly, or provide input | |
61 by using file redirection. The file <tt>test.ffc</tt> has been | |
62 provided as a sample. | |
63 <P> | |
64 Run <tt>ffcalc</tt> from the command line and type an | |
65 arithmetic expression or assignment | |
66 statement to be evaluated. <tt>ffcalc</tt> will accept addition, | |
67 subtraction, multiplication and division operations, as well | |
68 as unary negation, using floating point arithmetic. It | |
69 respects the conventional order of operations and allows the | |
70 use of parentheses to override the natural order of | |
71 computation. You may use spaces, tabs, and C-style comments | |
72 freely. You may use variable names consisting of a single | |
73 upper or lower case letter. | |
74 <P> | |
75 Each expression or assignment statement must be terminated | |
76 by a newline. Note that <tt>ffcalc</tt>, unlike | |
77 <tt>rcalc</tt>, does not explicitly check | |
78 for division by zero. | |
79 </P> | |
80 | |
81 <BR> | |
82 | |
83 <IMG ALIGN="bottom" SRC="../images/rbline6j.gif" ALT="----------------------" | |
84 WIDTH=1010 HEIGHT=2 > | |
85 <P> | |
86 <IMG ALIGN="right" SRC="../images/pslrb6d.gif" ALT="Parsifal Software" | |
87 WIDTH=181 HEIGHT=25> | |
88 <BR CLEAR="right"> | |
89 <P> | |
90 Back to <A HREF="../index.html">Index</A> | |
91 <P> | |
92 <ADDRESS><FONT SIZE="-1"> | |
93 AnaGram parser generator - examples<BR> | |
94 Four Function Calculator<BR> | |
95 Copyright © 1993-1999, Parsifal Software. <BR> | |
96 All Rights Reserved.<BR> | |
97 </FONT></ADDRESS> | |
98 | |
99 </BODY> | |
100 </HTML> | |
101 |