// -*- Java -*- This Cup file was machine-generated by BNFC package se.chalmers.cs.gf.GFCC; parser code {: public se.chalmers.cs.gf.GFCC.Absyn.Grammar pGrammar() throws Exception { java_cup.runtime.Symbol res = parse(); return (se.chalmers.cs.gf.GFCC.Absyn.Grammar) res.value; } public > A cons_(B x, A xs) { xs.addFirst(x); return xs; } public se.chalmers.cs.gf.GFCC.Absyn.Exp trA_ (se.chalmers.cs.gf.GFCC.Absyn.Atom a_) { return new se.chalmers.cs.gf.GFCC.Absyn.Tr(a_, new se.chalmers.cs.gf.GFCC.Absyn.ListExp()); } 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 se.chalmers.cs.gf.GFCC.Absyn.Grammar Grammar; nonterminal se.chalmers.cs.gf.GFCC.Absyn.Header Header; nonterminal se.chalmers.cs.gf.GFCC.Absyn.Abstract Abstract; nonterminal se.chalmers.cs.gf.GFCC.Absyn.Concrete Concrete; nonterminal se.chalmers.cs.gf.GFCC.Absyn.AbsDef AbsDef; nonterminal se.chalmers.cs.gf.GFCC.Absyn.CncDef CncDef; nonterminal se.chalmers.cs.gf.GFCC.Absyn.Type Type; nonterminal se.chalmers.cs.gf.GFCC.Absyn.Exp Exp; nonterminal se.chalmers.cs.gf.GFCC.Absyn.Atom Atom; nonterminal se.chalmers.cs.gf.GFCC.Absyn.Term Term; nonterminal se.chalmers.cs.gf.GFCC.Absyn.Tokn Tokn; nonterminal se.chalmers.cs.gf.GFCC.Absyn.Variant Variant; nonterminal se.chalmers.cs.gf.GFCC.Absyn.ListConcrete ListConcrete; nonterminal se.chalmers.cs.gf.GFCC.Absyn.ListAbsDef ListAbsDef; nonterminal se.chalmers.cs.gf.GFCC.Absyn.ListCncDef ListCncDef; nonterminal se.chalmers.cs.gf.GFCC.Absyn.ListCId ListCId; nonterminal se.chalmers.cs.gf.GFCC.Absyn.ListTerm ListTerm; nonterminal se.chalmers.cs.gf.GFCC.Absyn.ListExp ListExp; nonterminal se.chalmers.cs.gf.GFCC.Absyn.ListString ListString; nonterminal se.chalmers.cs.gf.GFCC.Absyn.ListVariant ListVariant; terminal _SYMB_0; // ; terminal _SYMB_1; // ( terminal _SYMB_2; // ) terminal _SYMB_3; // { terminal _SYMB_4; // } terminal _SYMB_5; // : terminal _SYMB_6; // = terminal _SYMB_7; // -> terminal _SYMB_8; // ? terminal _SYMB_9; // [ terminal _SYMB_10; // ] terminal _SYMB_11; // ! terminal _SYMB_12; // $ terminal _SYMB_13; // [| terminal _SYMB_14; // |] terminal _SYMB_15; // + terminal _SYMB_16; // @ terminal _SYMB_17; // # terminal _SYMB_18; // / terminal _SYMB_19; // , terminal _SYMB_20; // abstract terminal _SYMB_21; // concrete terminal _SYMB_22; // grammar terminal _SYMB_23; // pre terminal String _STRING_; terminal Integer _INTEGER_; terminal Double _DOUBLE_; terminal String CId; start with Grammar; Grammar ::= Header:p_1 _SYMB_0 Abstract:p_3 _SYMB_0 ListConcrete:p_5 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.Grm(p_1,p_3,p_5); :} ; Header ::= _SYMB_22 CId:p_2 _SYMB_1 ListCId:p_4 _SYMB_2 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.Hdr(p_2,p_4); :} ; Abstract ::= _SYMB_20 _SYMB_3 ListAbsDef:p_3 _SYMB_4 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.Abs(p_3); :} ; Concrete ::= _SYMB_21 CId:p_2 _SYMB_3 ListCncDef:p_4 _SYMB_4 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.Cnc(p_2,p_4); :} ; AbsDef ::= CId:p_1 _SYMB_5 Type:p_3 _SYMB_6 Exp:p_5 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.Fun(p_1,p_3,p_5); :} ; CncDef ::= CId:p_1 _SYMB_6 Term:p_3 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.Lin(p_1,p_3); :} ; Type ::= ListCId:p_1 _SYMB_7 CId:p_3 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.Typ(p_1,p_3); :} ; Exp ::= _SYMB_1 Atom:p_2 ListExp:p_3 _SYMB_2 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.Tr(p_2,p_3); :} | Atom:p_1 {: RESULT = parser.trA_(p_1); :} ; Atom ::= CId:p_1 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.AC(p_1); :} | _STRING_:p_1 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.AS(p_1); :} | _INTEGER_:p_1 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.AI(p_1); :} | _DOUBLE_:p_1 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.AF(p_1); :} | _SYMB_8 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.AM(); :} ; Term ::= _SYMB_9 ListTerm:p_2 _SYMB_10 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.R(p_2); :} | _SYMB_1 Term:p_2 _SYMB_11 Term:p_4 _SYMB_2 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.P(p_2,p_4); :} | _SYMB_1 ListTerm:p_2 _SYMB_2 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.S(p_2); :} | Tokn:p_1 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.K(p_1); :} | _SYMB_12 _INTEGER_:p_2 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.V(p_2); :} | _INTEGER_:p_1 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.C(p_1); :} | CId:p_1 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.F(p_1); :} | _SYMB_13 ListTerm:p_2 _SYMB_14 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.FV(p_2); :} | _SYMB_1 _STRING_:p_2 _SYMB_15 Term:p_4 _SYMB_2 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.W(p_2,p_4); :} | _SYMB_1 Term:p_2 _SYMB_16 Term:p_4 _SYMB_2 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.RP(p_2,p_4); :} | _SYMB_8 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.TM(); :} | _SYMB_1 CId:p_2 _SYMB_7 Term:p_4 _SYMB_2 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.L(p_2,p_4); :} | _SYMB_17 CId:p_2 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.BV(p_2); :} ; Tokn ::= _STRING_:p_1 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.KS(p_1); :} | _SYMB_9 _SYMB_23 ListString:p_3 _SYMB_9 ListVariant:p_5 _SYMB_10 _SYMB_10 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.KP(p_3,p_5); :} ; Variant ::= ListString:p_1 _SYMB_18 ListString:p_3 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.Var(p_1,p_3); :} ; ListConcrete ::= /* empty */ {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.ListConcrete(); :} | ListConcrete:p_1 Concrete:p_2 _SYMB_0 {: RESULT = p_1; p_1.addLast(p_2); :} ; ListAbsDef ::= /* empty */ {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.ListAbsDef(); :} | ListAbsDef:p_1 AbsDef:p_2 _SYMB_0 {: RESULT = p_1; p_1.addLast(p_2); :} ; ListCncDef ::= /* empty */ {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.ListCncDef(); :} | ListCncDef:p_1 CncDef:p_2 _SYMB_0 {: RESULT = p_1; p_1.addLast(p_2); :} ; ListCId ::= /* empty */ {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.ListCId(); :} | CId:p_1 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.ListCId(); RESULT.addLast(p_1); :} | CId:p_1 _SYMB_19 ListCId:p_3 {: RESULT = p_3; p_3.addFirst(p_1); :} ; ListTerm ::= /* empty */ {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.ListTerm(); :} | Term:p_1 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.ListTerm(); RESULT.addLast(p_1); :} | Term:p_1 _SYMB_19 ListTerm:p_3 {: RESULT = p_3; p_3.addFirst(p_1); :} ; ListExp ::= /* empty */ {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.ListExp(); :} | ListExp:p_1 Exp:p_2 {: RESULT = p_1; p_1.addLast(p_2); :} ; ListString ::= /* empty */ {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.ListString(); :} | ListString:p_1 _STRING_:p_2 {: RESULT = p_1; p_1.addLast(p_2); :} ; ListVariant ::= /* empty */ {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.ListVariant(); :} | Variant:p_1 {: RESULT = new se.chalmers.cs.gf.GFCC.Absyn.ListVariant(); RESULT.addLast(p_1); :} | Variant:p_1 _SYMB_19 ListVariant:p_3 {: RESULT = p_3; p_3.addFirst(p_1); :} ;