1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.06 [en] (X11; I; Linux 2.0.34 i686) [Netscape]">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000">
/*
<BR>Commented By: Christopher Lopes
<BR>File Name: Main.java
<BR>To Create: After the scanner, lcalc.flex, and the parser, ycalc.cup,
have been
<BR> created.
<BR>
> javac Main.java
<BR>To Run: > java Main test.txt
<BR>
where test.txt is an test input file for the calculator.
<BR>*/
<P>/* Import classes needed. The class we created for the parser,
the standard
<BR> runtime class for java, and an io class.*/
<BR><B>import parser;</B>
<BR><B>import java_cup.runtime.Symbol;</B>
<BR><B>import java.io.*;</B>
<P><B>class Main {</B>
<P> static boolean do_debug_parse = false;
<BR> static public void main(String argv[]) {
<P> /* Start the parser */
<BR> try {
<BR> parser p = new parser(new Lexer(new
FileReader(argv[0])));
<BR> Object result = p.parse().value;
<BR>
<P> } catch (Exception e) {
<BR> /* do cleanup here -- possibly rethrow
e */
<BR> } finally {
<BR> /* do close out here */
<BR> }
<BR> }
<BR><B>}</B><B></B>
<P><B>/* </B> <A HREF="lopes.html#main">Return to Main for our Calculator</A>
*/
</BODY>
</HTML>
|