home *** CD-ROM | disk | FTP | other *** search
- [CALC.CNV]
- [G. Cisneros, 9.7.85]
- [Include #.#^#%]
- [[Calculator: accepts <arith. expr.> or <var.>=<arith. expr.>]]
-
- [main routine: parses the line given to it]
- ((
- ((IVL,0,9,)) d [digit]
- (<:d:>(ITR,<:d:>)) i [integer]
- ((or,<:i:>.<:i:>,<:i:>.,.<:i:>)) r [real]
- ((or,+,-,)) s [optional sign]
- ((or,E,D,e,d)<:s:><:i:>) D [exponent of 10]
- ((or,<:r:>,<:i:>)(or,<:D:>,)) n [number]
- ((or,(IVL,A,Z,),(IVL,a,z,))) l [letter]
- ((or,<:d:>,<:l:>)) a [alphanumeric]
- (<:l:>(ITR,<:a:>)) v [variable]
- ((or,<:n:>,<:v:>,<(><:e:><)>)) p [operand]
- ((or,+,-,**,*,/,^,%)) o [operator]
- (<:s:><:p:>(ITR,<:o:><:p:>)) e [expression]
- )()(0 1)(
- (<>,(%t,Accepts (<)arith.expr.(>) or (<)var.(>)=(<)arith.expr.(>))(%r)):
- ((^Z),);
- ((and,<:v:>,<0>)=(and,<:e:>,<1>)<>,(A,(V,<1>))(%r)):
- (<:e:><>,(%t,(V,<=>))(%r)):
- ((or,<:v:>=,)(or,<:e:>,)<1>,(%t,<1> not recognized)(%r)):
- )) P
-
- [evaluate an expression]
- ((
- ((or,<:n:>,<(><:e:><)>)) p [operand, no variables]
- )()(0 1 2)(
- (<:e:><>,(#f,(&u,<=>)));
- ((and,<:v:>,<0>)<1>,(F)<1>):
- ((and,<-->(or,<(>,<:o:>)<:v:>,<1><:v:>,<1><0>)<2>,<1>(F)<2>):
- )) V
-
- [fetch a variable's value]
- (()()()(
- (,(%Or,MEM:v)(%R,(1),MEM:v,(itr,<-->;)<0>:<1>;,<1>,0));
- )) F
-
- [assign a value to a variable]
- (()()(2)(
- (<2>,(%Or,MEM:v)<<
- >>(%W,MEM:v,<<
- >>(%R,(1 3),MEM:v,<<
- >>(and,(itr,<-->;)<0>:,<1>)<-->;<3>,<<
- >>(%Ow,MEM:v)<1><2>;<3>,<0>:<2>;)<<
- >>));
- )) A
-
- [main program - open the symbol table]
- (()()()(
- (,(P,<=>(%Ow,MEM:v,4096)));
- ))
-
- [end]