A few notes on using jflex and byaccj Token values declared in the yacc file become static constants in Parser.y. For example, %token HELLO_tok may produce: public final static short HELLO_tok=257; so in your lex file you would write: hello { return Parser.HELLO_tok; } You will create an intance of your scanner class (class Yylex) from your parser. Since you will need a FileReader to pass to the constructor for your scanner (which is now created from the parser), you will write a new constructor for the parser which will accept a FileReader parameter and then create the scanner. The parser will call a method (from its own class) called yylex() which you must provide. You can write a method which just calls the yylex() method from class Yylex. An appropriate third section of your yacc file which will accomplish this is: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% private Yylex scanner; public Parser(FileReader fr) { this(); scanner = new Yylex(fr); } int yylex() { try { return scanner.yylex(); } catch (IOException e) { System.out.println("Exception caught: " + e); return 0; } } void yyerror(String s) { System.out.println("parse error on line " + scanner.line_num); System.exit(1); } +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Be sure to import java.io.*; inside %{ ... %} in the first section of your yacc file. In your lex file you should put %byaccj at the beginning of the second section and DO NOT change the name of the generated class with %class (byaccj expects the default class name Yylex). In your main you will create a FileReader object and pass it to the (new, written by you) Parser constructor. To start parsing call the yyparse() method from this class.