-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.java
40 lines (31 loc) · 961 Bytes
/
Main.java
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
/*
This example comes from a short article series in the Linux
Gazette by Richard A. Sevenich and Christopher Lopes, titled
"Compiler Construction Tools". The article series starts at
http://www.linuxgazette.com/issue39/sevenich.html
Small changes and updates to newest JFlex+Cup versions
by Gerwin Klein
*/
/*
Commented By: Christopher Lopes
File Name: Main.java
To Create:
After the scanner, lcalc.flex, and the parser, ycalc.cup, have been created.
> javac Main.java
To Run:
> java Main test.txt
where test.txt is an test input file for the calculator.
*/
import java.io.*;
public class Main {
static public void main(String argv[]) {
/* Start the parser */
try {
parser p = new parser(new Lexer(new FileReader(argv[0])));
Object result = p.parse().value;
} catch (Exception e) {
/* do cleanup here -- possibly rethrow e */
e.printStackTrace();
}
}
}