/* This files implements an interpreter for a BASIC-like language */ //need jbclasses.java; public class jbrun { /* Hand coded abstract syntax example label BEGIN; print "Hello\n"; goto BEGIN; static prog p0 = new prog( cons(new labelst("BEGIN"), cons(new printst(new strexp("Hello!\n")), cons(new gotost("BEGIN"), null)))); */ static jblexer jblx; // way to go around java's lack of closures public static void main(String[] args) throws Exception { jblx = new jblexer(new java.io.FileReader(args[0])); Mylexer lexer = new Mylexer() { public Gsym next() throws java.io.IOException { return jblx.yylex(); }}; jbparser theparser = new jbparser(lexer); // create parser object prog theprogram = null; // abstract syntax tree try { theprogram = theparser.parse(); } catch(ParseError pe) { pe.line = jblx.linenum()+1; // in Flex, first line is 0th line pe.column = jblx.columnnum()+1; System.out.println(pe); System.exit(1); }// error reporting theprogram.run(); // run the program! } } // end of class jbrun