parser code {: Yylex lexer; // Error handling function. public void report_fatal_error (String message, Object info) { done_parsing (); System . out . println (message); System . exit (1); } // This constructor assumes that the parser is named TPPParser. public TPPParser (Yylex l) { this (); lexer = l; } :}; scan with {: return lexer . nextToken (); :}; terminal SEMICOLON, DOUCOLON, COLON, COMMA, DOT, LPAREN, RPAREN, CLASS,END,EXTENDS; terminal String PROTONOTION, METANOTION; non terminal SyntaxTree class_definition, meta_rules, hyper_rules, meta_rule, meta_alternatives, hyper_rule, hyper_alternatives, alternative, hypernotion, class_identifier; //the parser can not parse the hyper rule starting with a metanotion, which is caused by the reduce/shift conflict. the %prec operator can be used to set the precedence of a production. But in that case, the reduce is always choosed and the parser can not parse the meta-rules. Need more work here. start with class_definition; class_definition ::= CLASS class_identifier:id DOT meta_rules:meta hyper_rules:hyper END CLASS DOT {: RESULT =new SyntaxTree("class "+ id.root() , meta, hyper); System.out.println("in class-definition");:} | CLASS class_identifier:id1 EXTENDS class_identifier:id2 DOT meta_rules:meta hyper_rules:hyper END CLASS DOT {: RESULT =new SyntaxTree("class" + id1.root(), id2, meta, hyper); :}; meta_rules ::= meta_rule:meta meta_rules:metas {:RESULT =new SyntaxTree ("meta_rules", meta, metas); System.out.println("in meta-rules-non-empty");:} | {:RESULT =null; System.out.println("in meta-rules-empty");:}; hyper_rules ::= hyper_rule:hyper hyper_rules:hypers {:RESULT =new SyntaxTree ("hyper_rules", hyper, hypers); System.out.println("in hyper-rules-non-empty");:} | hyper_rule:hyper {:RESULT =new SyntaxTree ("hyper_rule", hyper); System.out.println("in hyper-rules-emppty");:}; meta_rule ::= METANOTION:meta DOUCOLON meta_alternatives:alternatives DOT {:RESULT =new SyntaxTree("::", new SyntaxTree(meta), alternatives); System.out.println("in meta-rule");:} | METANOTION:meta DOUCOLON DOT {: RESULT =new SyntaxTree("::", new SyntaxTree(meta)); :}; meta_alternatives ::= hypernotion:hyper SEMICOLON meta_alternatives:alternatives {:RESULT =new SyntaxTree (";", hyper, alternatives); System.out.println("in meta-alternatives-non-empty");:} | hypernotion:hyper {:RESULT = hyper; System.out.println("in meta-alternatives-empty");:}; hyper_rule ::= hypernotion:hyper COLON hyper_alternatives:alternatives DOT {:RESULT =new SyntaxTree(":", hyper, alternatives); System.out.println("in hyper rule"); :} | hypernotion:hyper COLON DOT {:RESULT =new SyntaxTree(":", hyper); :}; hyper_alternatives ::= alternative:alternative SEMICOLON hyper_alternatives:alternatives {:RESULT =new SyntaxTree(";", alternative ,alternatives); System.out.println("in hyper-alternatives-non-empty");:} |alternative:alternative {:RESULT =alternative; System.out.println("in hyper-rule-empty"); :}; alternative ::= hypernotion:hyper COMMA alternative:alt {: RESULT =new SyntaxTree(",", hyper, alt); System.out.println("in alternative");:} | hypernotion:hyper {: RESULT =new SyntaxTree("hypernotion", hyper); System.out.println("in alternative-hypernotion"); :}; hypernotion ::= METANOTION:meta hypernotion:hyper {: RESULT=new SyntaxTree("hypernotion", new SyntaxTree(meta), hyper); System.out.println("metanotion hypernotion"); :} | PROTONOTION:pro hypernotion:hyper {: RESULT=new SyntaxTree("hypernotion", new SyntaxTree(pro), hyper); System.out.println("protonotion hypernotion"); :} | METANOTION:meta {: RESULT=new SyntaxTree(meta); System.out.println("metanotion"); :} | PROTONOTION:pro {: RESULT=new SyntaxTree(pro); System.out.println("protonotion"); :}; class_identifier ::= METANOTION:meta {: RESULT=new SyntaxTree(meta); :};