PARSER_BEGIN(Q1) class Q1 { /** Standard code to call the parser */ public static void main(String args[]) { Q1 parser; System.out.println("Reading from standard input . . ."); parser = new Q1(System.in); try { parser.line(); System.out.println("Yes"); } catch (TokenMgrError e) { // Lexical error System.out.println("No"); } catch (ParseException e) { // Parsing error System.out.println("No"); } } /* End of function "main" */ } PARSER_END(Q1) /******************/ /***** TOKENS *****/ /******************/ SKIP : /* WHITE SPACE */ { " " | "\t" | "\n" | "\r" } TOKEN : { < LBR : "(" > | < RBR : ")" > | < X : "x" > | } /*************************/ /***** GRAMMAR RULES *****/ /*************************/ void line () : {} { s() } void s () : {} { l() | } void l() : {} { s() ( s() )* }