-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGOParsCode.java
More file actions
45 lines (29 loc) · 994 Bytes
/
GOParsCode.java
File metadata and controls
45 lines (29 loc) · 994 Bytes
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
import java_cup . runtime . *;
import java.io.*;
public class GOParsCode {
public static void main (String args[])
throws IOException {
System.out.println("Source Program");
System.out.println("--------------");
System.out.println();
try {
SymbolFactory symbolFatory = new ComplexSymbolFactory();
GOParserCode parser =
new GOParserCode (new GOLexer (new InputStreamReader(System.in),
symbolFatory));
// parser.parse();
java_cup .runtime . Symbol parserValue = parser . parse ();
Code code = (Code) parserValue . value;
// SymbolTable env2 = new SymbolTable();
//env2 = (SymbolTable) parserValue . value;
code.env() . print ("main");
String outputFile = args[0] + ".c";
PrintStream outStream = new PrintStream(outputFile);
outStream.print(code.generate("main"));
}
catch(Exception e) {
System . out . println ("Error in invoking parser/lexer");
System . out . println (e);
}
}
}