view doc/misc/html/examples/ffcalc.html @ 8:ec2b657edf13

Add explicit lint-comment-style fallthrough annotations. GCC now assumes that if you don't have these you're making a mistake, which is annoying. XXX: This changeset updates the AG output files only (by hand) and is XXX: abusive - rebuilding them will erase the change. However, I need XXX: to get things to build before I can try to get AG to issue the XXX: annotations itself, so this seems like a reasonable expedient.
author David A. Holland
date Mon, 30 May 2022 23:51:43 -0400
parents 13d2b8934445
children
line wrap: on
line source

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Four Function Calculator</TITLE>
</HEAD>


<BODY BGCOLOR="#ffffff" BACKGROUND="tilbl6h.gif"
 TEXT="#000000" LINK="#0033CC"
 VLINK="#CC0033" ALINK="#CC0099">

<P>
<IMG ALIGN="right" SRC="../images/agrsl6c.gif" ALT="AnaGram"
         WIDTH=124 HEIGHT=30 >
<BR CLEAR="all">
Back to <A HREF="../index.html">Index</A>
<P>
<IMG ALIGN="bottom" SRC="../images/rbline6j.gif" ALT="----------------------"
        WIDTH=1010 HEIGHT=2  >
<P>

<H1>Four Function Calculator</H1>

<IMG ALIGN="bottom" SRC="../images/rbline6j.gif" ALT="----------------------"
        WIDTH=1010 HEIGHT=2  >
<P>
<H2>Introduction</H2>
<P>
          <tt>ffcalc.syn</tt> implements a simple four function
          calculator. The
          calculator has 52 registers, labeled 'a' through 'z' and 'A'
          through 'Z'. <tt>ffcalc</tt> evaluates arithmetic expressions and
          assignment statements and prints the results. The
          expressions may contain '<CODE>+</CODE>', '<CODE>-</CODE>',
          '<CODE>*</CODE>', and '<CODE>/</CODE>' operators as
          well as parentheses. In addition, <tt>ffcalc</tt> supports
          the free
          use of white space and C style comments in the input. It
          also includes syntax error handling, including a diagnostic
          message, and resynchronization.
<P>
          <tt>ffcalcmx.syn</tt> is a simple variation on
          <tt>ffcalc.syn</tt>. The only
          difference between the two grammars is that <tt>ffcalcx</tt> uses a
          deliberately ambiguous grammar for expressions, with
          precedence statements to resolve the ambiguities.
<P>

<H2>Building FFCALC</H2>
          To build a working copy of <tt>ffcalc</tt>, you need to
          carry out the following steps:
<UL>
<LI>      1.  Run Anagram and build a parser for <tt>ffcalc.syn</tt>. </LI>
<LI>      2.  Using your C compiler, compile and link <tt>ffcalc.c</tt>. </LI>
</UL>
<P>

<H2>Running FFCALC</H2>
          <tt>ffcalc</tt> reads expressions and assignment statements from
          stdin. You may either type input directly, or provide input
          by using file redirection. The file <tt>test.ffc</tt> has been
          provided as a sample.
<P>
          Run <tt>ffcalc</tt> from the command line and type an
          arithmetic expression or assignment 
          statement to be evaluated. <tt>ffcalc</tt> will accept addition,
          subtraction, multiplication and division operations, as well
          as unary negation, using floating point arithmetic. It
          respects the conventional order of operations and allows the
          use of parentheses to override the natural order of
          computation. You may use spaces, tabs, and C-style comments
          freely. You may use variable names consisting of a single
          upper or lower case letter.
<P>
          Each expression or assignment statement must be terminated
          by a newline. Note that <tt>ffcalc</tt>, unlike
          <tt>rcalc</tt>, does not explicitly check
          for division by zero.
</P>

<BR>

<IMG ALIGN="bottom" SRC="../images/rbline6j.gif" ALT="----------------------"
      WIDTH=1010 HEIGHT=2 >
<P>
<IMG ALIGN="right" SRC="../images/pslrb6d.gif" ALT="Parsifal Software"
                WIDTH=181 HEIGHT=25>
<BR CLEAR="right">
<P>
Back to <A HREF="../index.html">Index</A>
<P>
<ADDRESS><FONT SIZE="-1">
                  AnaGram parser generator - examples<BR>
                  Four Function Calculator<BR>
                  Copyright &copy; 1993-1999, Parsifal Software. <BR>
                  All Rights Reserved.<BR>
</FONT></ADDRESS>

</BODY>
</HTML>