PARSER_BEGIN(Assignment) class Assignment { public static void main(String[] args) throws ParseException, TokenMgrError { try { Assignment parser = new Assignment(System.in); parser.Start(); System.out.println("PASS"); } catch (ParseException e) { System.out.println("FAIL"); System.err.println(e.currentToken.beginLine); } } } PARSER_END(Assignment) TOKEN : { } TOKEN : { } TOKEN : { } TOKEN : { } void Start() : {} { (ValidLine())+ } // Single well-parenthesized string void ValidLine() : {} { Parens()Parens() } // Recursion to allow arbitrary length of parentheses void Parens() : {} { Parens()Parens() | Epsilon() } void Epsilon() : {} { {} // Have to have some kind of body apparently }