finished basic account add
[Bookkeeping.git] / src / com / interrupt / bookkeeping / cc / Compiler.java
blob1b7aa8b972b939164ba77073c787e6dfc32fdd52
2 package com.interrupt.bookkeeping.cc;
4 import java.io.PushbackReader;
5 import java.io.InputStreamReader;
6 import java.io.Reader;
7 import org.apache.log4j.Logger;
9 import com.interrupt.bookkeeping.cc.bkell.Bkell;
10 import com.interrupt.bookkeeping.cc.lexer.Lexer;
11 import com.interrupt.bookkeeping.cc.node.Start;
12 import com.interrupt.bookkeeping.cc.parser.Parser;
15 public class Compiler {
18 private Logger logger = Logger.getLogger(Compiler.class);
19 public Compiler() {
21 this._init(new InputStreamReader(System.in));
23 public Compiler(Reader reader) {
25 this._init(reader);
28 public void _init(Reader reader) {
31 logger.debug("Running Compiler. Input Expression >");
33 try {
35 PushbackReader pbreader = new PushbackReader( reader, 1024 );
36 Lexer lexer = new Lexer(pbreader);
37 Parser parser = new Parser(lexer);
39 // parse the input
40 Start tree = parser.parse();
42 // apply the Visitor
43 tree.apply( new ExpressionVisitor() );
46 catch(Exception e) {
47 e.printStackTrace();
53 public static void main(String args[]) {
55 Logger.getLogger(Compiler.class).debug("Running Compiler. Input Expression >");
56 try {
58 PushbackReader pbreader = new PushbackReader( new InputStreamReader(System.in), 1024 );
59 Lexer lexer = new Lexer(pbreader);
60 Parser parser = new Parser(lexer);
62 // parse the input
63 Start tree = parser.parse();
65 // apply the Visitor
66 tree.apply( new ExpressionVisitor() );
69 catch(Exception e) {
70 e.printStackTrace();