old-www/LDP/LG/issue41/lopes/main.htm

47 lines
1.8 KiB
HTML

<!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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; created.
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> javac Main.java
<BR>To Run: > java Main test.txt
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
where test.txt is an test input file for the calculator.
<BR>*/
<P>/* Import classes needed.&nbsp; The class we created for the parser,
the standard
<BR>&nbsp;&nbsp; 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>&nbsp; static boolean do_debug_parse = false;
<BR>&nbsp; static public void main(String argv[]) {
<P>&nbsp; /* Start the parser */
<BR>&nbsp; try {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parser p = new parser(new Lexer(new
FileReader(argv[0])));
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object result = p.parse().value;
<BR>&nbsp;
<P>&nbsp;&nbsp;&nbsp; } catch (Exception e) {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* do cleanup here -- possibly rethrow
e */
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } finally {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* do close out here */
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<BR>&nbsp; }
<BR><B>}</B><B></B>
<P><B>/*&nbsp;</B> <A HREF="lopes.html#main">Return to Main for our Calculator</A>&nbsp;
*/
</BODY>
</HTML>