
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Map;

import javax.imageio.stream.FileImageInputStream;

import org.antlr.runtime.ANTLRFileStream;
import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.tree.CommonTree;
import org.antlr.runtime.tree.CommonTreeNodeStream;


@SuppressWarnings("unchecked")
public class Main {
	static int	symIndex = 0;
	static Map	symtable = new HashMap();
	static int	labelIndex = 1;
	
	public static void addVar(String name) {
		symtable.put(name, new Integer(symIndex++));
	}
	
	public static String varHexIndex(String name) {
		Integer index = (Integer)symtable.get(name);
		if (index == null) {
			System.err.println("Invalid variable name");
//			System.exit(1);
		}
		return (String.format("%x", index.intValue()));
	}
	
	public static String genLabel() {
		return ("L" + labelIndex++);
	}
	
	public static String toHexString(String val) {
		return (String.format("%x", Integer.parseInt(val)));
	}
	
    public static void main(String[] args) throws Exception {
//    	ANTLRFileStream input = new ANTLRFileStream("1.c");
    	ANTLRInputStream input = new ANTLRInputStream(System.in);
        Gem4cLexer lex = new Gem4cLexer(input);
        CommonTokenStream tokens = new CommonTokenStream(lex);

        Gem4cParser g = new Gem4cParser(tokens);
        try {
            g.prog();
        } catch (RecognitionException e) {
            e.printStackTrace();
        }
    }

}
