class Assembler {

	public ScriptDefinition assemble(InputStream in) throws IOException
	{
		// Get our lexer
		rs2asmLexer lexer = new rs2asmLexer(new ANTLRInputStream(in));

		LexerErrorListener errorListener = new LexerErrorListener();
		lexer.addErrorListener(errorListener);

		// Get a list of matched tokens
		CommonTokenStream tokens = new CommonTokenStream(lexer);

		// Pass the tokens to the parser
		rs2asmParser parser = new rs2asmParser(tokens);

		// Specify our entry point
		ProgContext progContext = parser.prog();

		if (errorListener.getErrors() > 0)
		{
			throw new RuntimeException("syntax error");
		}

		// Walk it and attach our listener
		ParseTreeWalker walker = new ParseTreeWalker();

		// walk through first and resolve labels
		LabelVisitor labelVisitor = new LabelVisitor();
		walker.walk(labelVisitor, progContext);

		ScriptWriter listener = new ScriptWriter(instructions, labelVisitor);
		walker.walk(listener, progContext);

		return listener.buildScript();
	}

	public  Assembler(Instructions instructions);

}