// -*- Java -*- This Cup file was machine-generated by BNFC package MiniJS; action code {: public java_cup.runtime.ComplexSymbolFactory.Location getLeftLocation( java_cup.runtime.ComplexSymbolFactory.Location ... locations) { for (java_cup.runtime.ComplexSymbolFactory.Location l : locations) { if (l != null) { return l; } } return null; } :} parser code {: public MiniJS.Absyn.Program pProgram() throws Exception { java_cup.runtime.Symbol res = parse(); return (MiniJS.Absyn.Program) res.value; } public > A cons_(B x, A xs) { xs.addFirst(x); return xs; } public void syntax_error(java_cup.runtime.Symbol cur_token) { report_error("Syntax Error, trying to recover and continue parse...", cur_token); } public void unrecovered_syntax_error(java_cup.runtime.Symbol cur_token) throws java.lang.Exception { throw new Exception("Unrecoverable Syntax Error"); } :} nonterminal MiniJS.Absyn.Program Program; nonterminal MiniJS.Absyn.Stm Stm; nonterminal MiniJS.Absyn.ListStm ListStm; nonterminal MiniJS.Absyn.Exp Exp2; nonterminal MiniJS.Absyn.Exp Exp1; nonterminal MiniJS.Absyn.Exp Exp; terminal _SYMB_0; // = terminal _SYMB_1; // console.log terminal _SYMB_2; // ( terminal _SYMB_3; // ) terminal _SYMB_4; // ; terminal _SYMB_5; // * terminal _SYMB_6; // / terminal _SYMB_7; // + terminal _SYMB_8; // - terminal Integer _INTEGER_; terminal Double _DOUBLE_; terminal String _IDENT_; start with Program; Program ::= ListStm:p_1 {: RESULT = new MiniJS.Absyn.Prg(p_1); :} ; Stm ::= _IDENT_:p_1 _SYMB_0:p_2 Exp:p_3 {: RESULT = new MiniJS.Absyn.SAssign(p_1,p_3); :} | _SYMB_1:p_1 _SYMB_2:p_2 Exp:p_3 _SYMB_3:p_4 {: RESULT = new MiniJS.Absyn.SPrint(p_3); :} ; ListStm ::= /* empty */ {: RESULT = new MiniJS.Absyn.ListStm(); :} | ListStm:p_1 Stm:p_2 _SYMB_4:p_3 {: RESULT = p_1; p_1.addLast(p_2); :} ; Exp2 ::= _IDENT_:p_1 {: RESULT = new MiniJS.Absyn.EVar(p_1); :} | _INTEGER_:p_1 {: RESULT = new MiniJS.Absyn.EInt(p_1); :} | _DOUBLE_:p_1 {: RESULT = new MiniJS.Absyn.EDouble(p_1); :} | _SYMB_2:p_1 Exp:p_2 _SYMB_3:p_3 {: RESULT = p_2; :} ; Exp1 ::= Exp1:p_1 _SYMB_5:p_2 Exp2:p_3 {: RESULT = new MiniJS.Absyn.ETimes(p_1,p_3); :} | Exp1:p_1 _SYMB_6:p_2 Exp2:p_3 {: RESULT = new MiniJS.Absyn.EDiv(p_1,p_3); :} | Exp2:p_1 {: RESULT = p_1; :} ; Exp ::= Exp:p_1 _SYMB_7:p_2 Exp1:p_3 {: RESULT = new MiniJS.Absyn.EPlus(p_1,p_3); :} | Exp:p_1 _SYMB_8:p_2 Exp1:p_3 {: RESULT = new MiniJS.Absyn.EMinus(p_1,p_3); :} | Exp1:p_1 {: RESULT = p_1; :} ;