-- File generated by the BNF Converter. -- Parser definition for use with Happy. { {-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-} {-# LANGUAGE PatternSynonyms #-} module ParGF ( happyError , myLexer , pGrammar , pListModDef , pModDef , pConcSpec , pListConcSpec , pConcExp , pListTransfer , pTransfer , pModType , pModBody , pListTopDef , pExtend , pListOpenDecl , pOpens , pOpenDecl , pComplMod , pQualOpen , pListIncluded , pIncluded , pDef , pTopDef , pCatDef , pFunDef , pDataDef , pDataConstr , pListDataConstr , pParDef , pParConstr , pPrintDef , pFlagDef , pListDef , pListCatDef , pListFunDef , pListDataDef , pListParDef , pListPrintDef , pListFlagDef , pListParConstr , pListIdent , pName , pListName , pLocDef , pListLocDef , pExp4 , pExp3 , pExp2 , pExp1 , pExp , pListExp , pExps , pPatt1 , pPatt , pPattAss , pLabel , pSort , pListPattAss , pPattAlt , pListPatt , pListPattAlt , pBind , pListBind , pDecl , pTupleComp , pPattTupleComp , pListTupleComp , pListPattTupleComp , pCase , pListCase , pEquation , pListEquation , pAltern , pListAltern , pDDecl , pListDDecl , pOldGrammar , pIncludeDecl , pFileName , pListFileName ) where import Prelude import qualified AbsGF import LexGF } %name pGrammar Grammar %name pListModDef ListModDef %name pModDef ModDef %name pConcSpec ConcSpec %name pListConcSpec ListConcSpec %name pConcExp ConcExp %name pListTransfer ListTransfer %name pTransfer Transfer %name pModType ModType %name pModBody ModBody %name pListTopDef ListTopDef %name pExtend Extend %name pListOpenDecl ListOpenDecl %name pOpens Opens %name pOpenDecl OpenDecl %name pComplMod ComplMod %name pQualOpen QualOpen %name pListIncluded ListIncluded %name pIncluded Included %name pDef Def %name pTopDef TopDef %name pCatDef CatDef %name pFunDef FunDef %name pDataDef DataDef %name pDataConstr DataConstr %name pListDataConstr ListDataConstr %name pParDef ParDef %name pParConstr ParConstr %name pPrintDef PrintDef %name pFlagDef FlagDef %name pListDef ListDef %name pListCatDef ListCatDef %name pListFunDef ListFunDef %name pListDataDef ListDataDef %name pListParDef ListParDef %name pListPrintDef ListPrintDef %name pListFlagDef ListFlagDef %name pListParConstr ListParConstr %name pListIdent ListIdent %name pName Name %name pListName ListName %name pLocDef LocDef %name pListLocDef ListLocDef %name pExp4 Exp4 %name pExp3 Exp3 %name pExp2 Exp2 %name pExp1 Exp1 %name pExp Exp %name pListExp ListExp %name pExps Exps %name pPatt1 Patt1 %name pPatt Patt %name pPattAss PattAss %name pLabel Label %name pSort Sort %name pListPattAss ListPattAss %name pPattAlt PattAlt %name pListPatt ListPatt %name pListPattAlt ListPattAlt %name pBind Bind %name pListBind ListBind %name pDecl Decl %name pTupleComp TupleComp %name pPattTupleComp PattTupleComp %name pListTupleComp ListTupleComp %name pListPattTupleComp ListPattTupleComp %name pCase Case %name pListCase ListCase %name pEquation Equation %name pListEquation ListEquation %name pAltern Altern %name pListAltern ListAltern %name pDDecl DDecl %name pListDDecl ListDDecl %name pOldGrammar OldGrammar %name pIncludeDecl IncludeDecl %name pFileName FileName %name pListFileName ListFileName %monad { Err } { (>>=) } { return } %tokentype {Token} %token '!' { PT _ (TS _ 1) } '$' { PT _ (TS _ 2) } '%' { PT _ (TS _ 3) } '(' { PT _ (TS _ 4) } ')' { PT _ (TS _ 5) } '*' { PT _ (TS _ 6) } '**' { PT _ (TS _ 7) } '+' { PT _ (TS _ 8) } '++' { PT _ (TS _ 9) } ',' { PT _ (TS _ 10) } '-' { PT _ (TS _ 11) } '->' { PT _ (TS _ 12) } '.' { PT _ (TS _ 13) } '/' { PT _ (TS _ 14) } ':' { PT _ (TS _ 15) } ';' { PT _ (TS _ 16) } '<' { PT _ (TS _ 17) } '=' { PT _ (TS _ 18) } '=>' { PT _ (TS _ 19) } '>' { PT _ (TS _ 20) } '?' { PT _ (TS _ 21) } '@' { PT _ (TS _ 22) } 'Lin' { PT _ (TS _ 23) } 'PType' { PT _ (TS _ 24) } 'Str' { PT _ (TS _ 25) } 'Strs' { PT _ (TS _ 26) } 'Tok' { PT _ (TS _ 27) } 'Type' { PT _ (TS _ 28) } '[' { PT _ (TS _ 29) } '\\' { PT _ (TS _ 30) } ']' { PT _ (TS _ 31) } '_' { PT _ (TS _ 32) } 'abstract' { PT _ (TS _ 33) } 'case' { PT _ (TS _ 34) } 'cat' { PT _ (TS _ 35) } 'concrete' { PT _ (TS _ 36) } 'data' { PT _ (TS _ 37) } 'def' { PT _ (TS _ 38) } 'flags' { PT _ (TS _ 39) } 'fn' { PT _ (TS _ 40) } 'fun' { PT _ (TS _ 41) } 'grammar' { PT _ (TS _ 42) } 'in' { PT _ (TS _ 43) } 'include' { PT _ (TS _ 44) } 'incomplete' { PT _ (TS _ 45) } 'instance' { PT _ (TS _ 46) } 'interface' { PT _ (TS _ 47) } 'let' { PT _ (TS _ 48) } 'lin' { PT _ (TS _ 49) } 'lincat' { PT _ (TS _ 50) } 'lindef' { PT _ (TS _ 51) } 'lintype' { PT _ (TS _ 52) } 'of' { PT _ (TS _ 53) } 'open' { PT _ (TS _ 54) } 'oper' { PT _ (TS _ 55) } 'out' { PT _ (TS _ 56) } 'package' { PT _ (TS _ 57) } 'param' { PT _ (TS _ 58) } 'pattern' { PT _ (TS _ 59) } 'pre' { PT _ (TS _ 60) } 'printname' { PT _ (TS _ 61) } 'resource' { PT _ (TS _ 62) } 'reuse' { PT _ (TS _ 63) } 'strs' { PT _ (TS _ 64) } 'table' { PT _ (TS _ 65) } 'tokenizer' { PT _ (TS _ 66) } 'transfer' { PT _ (TS _ 67) } 'union' { PT _ (TS _ 68) } 'var' { PT _ (TS _ 69) } 'variants' { PT _ (TS _ 70) } 'where' { PT _ (TS _ 71) } 'with' { PT _ (TS _ 72) } '{' { PT _ (TS _ 73) } '|' { PT _ (TS _ 74) } '}' { PT _ (TS _ 75) } L_Ident { PT _ (TV $$) } L_integ { PT _ (TI $$) } L_quoted { PT _ (TL $$) } L_LString { PT _ (T_LString $$) } %% Ident :: { AbsGF.Ident } Ident : L_Ident { AbsGF.Ident $1 } Integer :: { Integer } Integer : L_integ { (read $1 ) :: Integer } String :: { String } String : L_quoted { $1 } LString :: { AbsGF.LString } LString : L_LString { AbsGF.LString $1 } Grammar :: { AbsGF.Grammar } Grammar : ListModDef { AbsGF.Gr $1 } ListModDef :: { [AbsGF.ModDef] } ListModDef : {- empty -} { [] } | ModDef ListModDef { (:) $1 $2 } ModDef :: { AbsGF.ModDef } ModDef : 'grammar' Ident '=' '{' 'abstract' '=' Ident ';' ListConcSpec '}' { AbsGF.MMain $2 $7 $9 } | ComplMod ModType '=' ModBody { AbsGF.MModule $1 $2 $4 } | ModDef ';' { $1 } ConcSpec :: { AbsGF.ConcSpec } ConcSpec : Ident '=' ConcExp { AbsGF.ConcSpecC $1 $3 } ListConcSpec :: { [AbsGF.ConcSpec] } ListConcSpec : {- empty -} { [] } | ConcSpec { (:[]) $1 } | ConcSpec ';' ListConcSpec { (:) $1 $3 } ConcExp :: { AbsGF.ConcExp } ConcExp : Ident ListTransfer { AbsGF.ConcExpC $1 $2 } ListTransfer :: { [AbsGF.Transfer] } ListTransfer : {- empty -} { [] } | Transfer ListTransfer { (:) $1 $2 } Transfer :: { AbsGF.Transfer } Transfer : '(' 'transfer' 'in' OpenDecl ')' { AbsGF.TransferIn $4 } | '(' 'transfer' 'out' OpenDecl ')' { AbsGF.TransferOut $4 } ModType :: { AbsGF.ModType } ModType : 'abstract' Ident { AbsGF.MTAbstract $2 } | 'concrete' Ident 'of' Ident { AbsGF.MTConcrete $2 $4 } | 'instance' Ident 'of' Ident { AbsGF.MTInstance $2 $4 } | 'interface' Ident { AbsGF.MTInterface $2 } | 'resource' Ident { AbsGF.MTResource $2 } | 'transfer' Ident ':' OpenDecl '->' OpenDecl { AbsGF.MTTransfer $2 $4 $6 } ModBody :: { AbsGF.ModBody } ModBody : 'reuse' Ident { AbsGF.MReuse $2 } | 'union' ListIncluded { AbsGF.MUnion $2 } | Ident 'with' ListOpenDecl { AbsGF.MWith $1 $3 } | Extend Opens '{' ListTopDef '}' { AbsGF.MBody $1 $2 $4 } | ListIncluded '**' Ident 'with' ListOpenDecl { AbsGF.MWithE $1 $3 $5 } ListTopDef :: { [AbsGF.TopDef] } ListTopDef : {- empty -} { [] } | TopDef ListTopDef { (:) $1 $2 } Extend :: { AbsGF.Extend } Extend : {- empty -} { AbsGF.NoExt } | ListIncluded '**' { AbsGF.Ext $1 } ListOpenDecl :: { [AbsGF.OpenDecl] } ListOpenDecl : {- empty -} { [] } | OpenDecl { (:[]) $1 } | OpenDecl ',' ListOpenDecl { (:) $1 $3 } Opens :: { AbsGF.Opens } Opens : {- empty -} { AbsGF.NoOpens } | 'open' ListOpenDecl 'in' { AbsGF.OpenIn $2 } OpenDecl :: { AbsGF.OpenDecl } OpenDecl : '(' QualOpen Ident ')' { AbsGF.OQualQO $2 $3 } | '(' QualOpen Ident '=' Ident ')' { AbsGF.OQual $2 $3 $5 } | Ident { AbsGF.OName $1 } ComplMod :: { AbsGF.ComplMod } ComplMod : {- empty -} { AbsGF.CMCompl } | 'incomplete' { AbsGF.CMIncompl } QualOpen :: { AbsGF.QualOpen } QualOpen : {- empty -} { AbsGF.QOCompl } | 'incomplete' { AbsGF.QOIncompl } | 'interface' { AbsGF.QOInterface } ListIncluded :: { [AbsGF.Included] } ListIncluded : {- empty -} { [] } | Included { (:[]) $1 } | Included ',' ListIncluded { (:) $1 $3 } Included :: { AbsGF.Included } Included : Ident { AbsGF.IAll $1 } | Ident '-' '[' ListIdent ']' { AbsGF.IMinus $1 $4 } | Ident '[' ListIdent ']' { AbsGF.ISome $1 $3 } Def :: { AbsGF.Def } Def : Name ListPatt '=' Exp { AbsGF.DPatt $1 $2 $4 } | ListName ':' Exp { AbsGF.DDeclC $1 $3 } | ListName ':' Exp '=' Exp { AbsGF.DFull $1 $3 $5 } | ListName '=' Exp { AbsGF.DDef $1 $3 } TopDef :: { AbsGF.TopDef } TopDef : 'cat' ListCatDef { AbsGF.DefCat $2 } | 'data' ListDataDef { AbsGF.DefData $2 } | 'data' ListFunDef { AbsGF.DefFunData $2 } | 'def' ListDef { AbsGF.DefDef $2 } | 'flags' ListFlagDef { AbsGF.DefFlag $2 } | 'fun' ListFunDef { AbsGF.DefFun $2 } | 'lin' ListDef { AbsGF.DefLin $2 } | 'lincat' ListPrintDef { AbsGF.DefLincat $2 } | 'lindef' ListDef { AbsGF.DefLindef $2 } | 'lintype' ListDef { AbsGF.DefLintype $2 } | 'oper' ListDef { AbsGF.DefOper $2 } | 'package' Ident '=' '{' ListTopDef '}' ';' { AbsGF.DefPackage $2 $5 } | 'param' ListParDef { AbsGF.DefPar $2 } | 'pattern' ListDef { AbsGF.DefPattern $2 } | 'printname' 'cat' ListPrintDef { AbsGF.DefPrintCat $3 } | 'printname' 'fun' ListPrintDef { AbsGF.DefPrintFun $3 } | 'printname' ListPrintDef { AbsGF.DefPrintOld $2 } | 'tokenizer' Ident ';' { AbsGF.DefTokenizer $2 } | 'transfer' ListDef { AbsGF.DefTrans $2 } | 'var' ListDef { AbsGF.DefVars $2 } CatDef :: { AbsGF.CatDef } CatDef : '[' Ident ListDDecl ']' { AbsGF.ListCatDefC $2 $3 } | '[' Ident ListDDecl ']' '{' Integer '}' { AbsGF.ListSizeCatDef $2 $3 $6 } | Ident ListDDecl { AbsGF.SimpleCatDef $1 $2 } FunDef :: { AbsGF.FunDef } FunDef : ListIdent ':' Exp { AbsGF.FunDefC $1 $3 } DataDef :: { AbsGF.DataDef } DataDef : Ident '=' ListDataConstr { AbsGF.DataDefC $1 $3 } DataConstr :: { AbsGF.DataConstr } DataConstr : Ident { AbsGF.DataId $1 } | Ident '.' Ident { AbsGF.DataQId $1 $3 } ListDataConstr :: { [AbsGF.DataConstr] } ListDataConstr : {- empty -} { [] } | DataConstr { (:[]) $1 } | DataConstr '|' ListDataConstr { (:) $1 $3 } ParDef :: { AbsGF.ParDef } ParDef : Ident { AbsGF.ParDefAbs $1 } | Ident '=' '(' 'in' Ident ')' { AbsGF.ParDefIndir $1 $5 } | Ident '=' ListParConstr { AbsGF.ParDefDir $1 $3 } ParConstr :: { AbsGF.ParConstr } ParConstr : Ident ListDDecl { AbsGF.ParConstrC $1 $2 } PrintDef :: { AbsGF.PrintDef } PrintDef : ListName '=' Exp { AbsGF.PrintDefC $1 $3 } FlagDef :: { AbsGF.FlagDef } FlagDef : Ident '=' Ident { AbsGF.FlagDefC $1 $3 } ListDef :: { [AbsGF.Def] } ListDef : Def ';' { (:[]) $1 } | Def ';' ListDef { (:) $1 $3 } ListCatDef :: { [AbsGF.CatDef] } ListCatDef : CatDef ';' { (:[]) $1 } | CatDef ';' ListCatDef { (:) $1 $3 } ListFunDef :: { [AbsGF.FunDef] } ListFunDef : FunDef ';' { (:[]) $1 } | FunDef ';' ListFunDef { (:) $1 $3 } ListDataDef :: { [AbsGF.DataDef] } ListDataDef : DataDef ';' { (:[]) $1 } | DataDef ';' ListDataDef { (:) $1 $3 } ListParDef :: { [AbsGF.ParDef] } ListParDef : ParDef ';' { (:[]) $1 } | ParDef ';' ListParDef { (:) $1 $3 } ListPrintDef :: { [AbsGF.PrintDef] } ListPrintDef : PrintDef ';' { (:[]) $1 } | PrintDef ';' ListPrintDef { (:) $1 $3 } ListFlagDef :: { [AbsGF.FlagDef] } ListFlagDef : FlagDef ';' { (:[]) $1 } | FlagDef ';' ListFlagDef { (:) $1 $3 } ListParConstr :: { [AbsGF.ParConstr] } ListParConstr : {- empty -} { [] } | ParConstr { (:[]) $1 } | ParConstr '|' ListParConstr { (:) $1 $3 } ListIdent :: { [AbsGF.Ident] } ListIdent : Ident { (:[]) $1 } | Ident ',' ListIdent { (:) $1 $3 } Name :: { AbsGF.Name } Name : '[' Ident ']' { AbsGF.ListNameC $2 } | Ident { AbsGF.IdentName $1 } ListName :: { [AbsGF.Name] } ListName : Name { (:[]) $1 } | Name ',' ListName { (:) $1 $3 } LocDef :: { AbsGF.LocDef } LocDef : ListIdent ':' Exp { AbsGF.LDDecl $1 $3 } | ListIdent ':' Exp '=' Exp { AbsGF.LDFull $1 $3 $5 } | ListIdent '=' Exp { AbsGF.LDDef $1 $3 } ListLocDef :: { [AbsGF.LocDef] } ListLocDef : {- empty -} { [] } | LocDef { (:[]) $1 } | LocDef ';' ListLocDef { (:) $1 $3 } Exp4 :: { AbsGF.Exp } Exp4 : '%' Ident '%' { AbsGF.ECons $2 } | '(' 'in' Ident ')' { AbsGF.EIndir $3 } | '(' Exp ')' { $2 } | '<' Exp ':' Exp '>' { AbsGF.ETyped $2 $4 } | '<' ListTupleComp '>' { AbsGF.ETuple $2 } | '?' { AbsGF.EMeta } | '[' ']' { AbsGF.EEmpty } | '[' String ']' { AbsGF.EStrings $2 } | '[' Ident Exps ']' { AbsGF.EList $2 $3 } | 'data' { AbsGF.EData } | '{' Ident '}' { AbsGF.EConstr $2 } | '{' ListLocDef '}' { AbsGF.ERecord $2 } | Integer { AbsGF.EInt $1 } | String { AbsGF.EString $1 } | Ident { AbsGF.EIdent $1 } | LString { AbsGF.ELString $1 } | Sort { AbsGF.ESort $1 } Exp3 :: { AbsGF.Exp } Exp3 : '%' Ident '.' Ident { AbsGF.EQCons $2 $4 } | '{' Ident '.' Ident '}' { AbsGF.EQConstr $2 $4 } | Exp3 '.' Label { AbsGF.EProj $1 $3 } | Exp4 { $1 } Exp2 :: { AbsGF.Exp } Exp2 : 'Lin' Ident { AbsGF.ELin $2 } | 'case' Exp 'of' '{' ListCase '}' { AbsGF.ECase $2 $5 } | 'pre' '{' Exp ';' ListAltern '}' { AbsGF.EPre $3 $5 } | 'strs' '{' ListExp '}' { AbsGF.EStrs $3 } | 'table' '{' ListCase '}' { AbsGF.ETable $3 } | 'table' Exp4 '[' ListExp ']' { AbsGF.EVTable $2 $4 } | 'table' Exp4 '{' ListCase '}' { AbsGF.ETTable $2 $4 } | 'variants' '{' ListExp '}' { AbsGF.EVariants $3 } | Ident '@' Exp4 { AbsGF.EConAt $1 $3 } | Exp2 Exp3 { AbsGF.EApp $1 $2 } | Exp3 { $1 } Exp1 :: { AbsGF.Exp } Exp1 : Exp1 '!' Exp2 { AbsGF.ESelect $1 $3 } | Exp1 '*' Exp2 { AbsGF.ETupTyp $1 $3 } | Exp1 '**' Exp2 { AbsGF.EExtend $1 $3 } | Exp2 { $1 } Exp :: { AbsGF.Exp } Exp : '\\' '\\' ListBind '=>' Exp { AbsGF.ECTable $3 $5 } | '\\' ListBind '->' Exp { AbsGF.EAbstr $2 $4 } | 'fn' '{' ListEquation '}' { AbsGF.EEqs $3 } | 'let' '{' ListLocDef '}' 'in' Exp { AbsGF.ELet $3 $6 } | 'let' ListLocDef 'in' Exp { AbsGF.ELetb $2 $4 } | Decl '->' Exp { AbsGF.EProd $1 $3 } | Exp1 { $1 } | Exp1 '+' Exp { AbsGF.EGlue $1 $3 } | Exp1 '++' Exp { AbsGF.EConcat $1 $3 } | Exp1 '=>' Exp { AbsGF.ETType $1 $3 } | Exp1 'where' '{' ListLocDef '}' { AbsGF.EWhere $1 $4 } ListExp :: { [AbsGF.Exp] } ListExp : {- empty -} { [] } | Exp { (:[]) $1 } | Exp ';' ListExp { (:) $1 $3 } Exps :: { AbsGF.Exps } Exps : {- empty -} { AbsGF.NilExp } | Exp4 Exps { AbsGF.ConsExp $1 $2 } Patt1 :: { AbsGF.Patt } Patt1 : '(' Patt ')' { $2 } | '<' ListPattTupleComp '>' { AbsGF.PTup $2 } | '_' { AbsGF.PW } | '{' Ident '}' { AbsGF.PCon $2 } | '{' ListPattAss '}' { AbsGF.PR $2 } | Integer { AbsGF.PInt $1 } | String { AbsGF.PStr $1 } | Ident { AbsGF.PV $1 } | Ident '.' Ident { AbsGF.PQ $1 $3 } Patt :: { AbsGF.Patt } Patt : Ident '.' Ident ListPatt { AbsGF.PQC $1 $3 $4 } | Ident ListPatt { AbsGF.PC $1 $2 } | Patt1 { $1 } PattAss :: { AbsGF.PattAss } PattAss : ListIdent '=' Patt { AbsGF.PA $1 $3 } Label :: { AbsGF.Label } Label : '$' Integer { AbsGF.LVar $2 } | Ident { AbsGF.LIdent $1 } Sort :: { AbsGF.Sort } Sort : 'PType' { AbsGF.Sort_PType } | 'Str' { AbsGF.Sort_Str } | 'Strs' { AbsGF.Sort_Strs } | 'Tok' { AbsGF.Sort_Tok } | 'Type' { AbsGF.Sort_Type } ListPattAss :: { [AbsGF.PattAss] } ListPattAss : {- empty -} { [] } | PattAss { (:[]) $1 } | PattAss ';' ListPattAss { (:) $1 $3 } PattAlt :: { AbsGF.PattAlt } PattAlt : Patt { AbsGF.AltP $1 } ListPatt :: { [AbsGF.Patt] } ListPatt : Patt1 { (:[]) $1 } | Patt1 ListPatt { (:) $1 $2 } ListPattAlt :: { [AbsGF.PattAlt] } ListPattAlt : PattAlt { (:[]) $1 } | PattAlt '|' ListPattAlt { (:) $1 $3 } Bind :: { AbsGF.Bind } Bind : '_' { AbsGF.BWild } | Ident { AbsGF.BIdent $1 } ListBind :: { [AbsGF.Bind] } ListBind : {- empty -} { [] } | Bind { (:[]) $1 } | Bind ',' ListBind { (:) $1 $3 } Decl :: { AbsGF.Decl } Decl : '(' ListBind ':' Exp ')' { AbsGF.DDec $2 $4 } | Exp2 { AbsGF.DExp $1 } TupleComp :: { AbsGF.TupleComp } TupleComp : Exp { AbsGF.TComp $1 } PattTupleComp :: { AbsGF.PattTupleComp } PattTupleComp : Patt { AbsGF.PTComp $1 } ListTupleComp :: { [AbsGF.TupleComp] } ListTupleComp : {- empty -} { [] } | TupleComp { (:[]) $1 } | TupleComp ',' ListTupleComp { (:) $1 $3 } ListPattTupleComp :: { [AbsGF.PattTupleComp] } ListPattTupleComp : {- empty -} { [] } | PattTupleComp { (:[]) $1 } | PattTupleComp ',' ListPattTupleComp { (:) $1 $3 } Case :: { AbsGF.Case } Case : ListPattAlt '=>' Exp { AbsGF.CaseC $1 $3 } ListCase :: { [AbsGF.Case] } ListCase : Case { (:[]) $1 } | Case ';' ListCase { (:) $1 $3 } Equation :: { AbsGF.Equation } Equation : ListPatt '->' Exp { AbsGF.Equ $1 $3 } ListEquation :: { [AbsGF.Equation] } ListEquation : {- empty -} { [] } | Equation { (:[]) $1 } | Equation ';' ListEquation { (:) $1 $3 } Altern :: { AbsGF.Altern } Altern : Exp '/' Exp { AbsGF.Alt $1 $3 } ListAltern :: { [AbsGF.Altern] } ListAltern : {- empty -} { [] } | Altern { (:[]) $1 } | Altern ';' ListAltern { (:) $1 $3 } DDecl :: { AbsGF.DDecl } DDecl : '(' ListBind ':' Exp ')' { AbsGF.DDDec $2 $4 } | Exp4 { AbsGF.DDExp $1 } ListDDecl :: { [AbsGF.DDecl] } ListDDecl : {- empty -} { [] } | DDecl ListDDecl { (:) $1 $2 } OldGrammar :: { AbsGF.OldGrammar } OldGrammar : IncludeDecl ListTopDef { AbsGF.OldGr $1 $2 } IncludeDecl :: { AbsGF.IncludeDecl } IncludeDecl : {- empty -} { AbsGF.NoIncl } | 'include' ListFileName { AbsGF.Incl $2 } FileName :: { AbsGF.FileName } FileName : '-' FileName { AbsGF.FMinus $2 } | '.' FileName { AbsGF.FDot $2 } | '/' FileName { AbsGF.FSlash $2 } | String { AbsGF.FString $1 } | Ident { AbsGF.FIdent $1 } | Ident FileName { AbsGF.FAddId $1 $2 } ListFileName :: { [AbsGF.FileName] } ListFileName : FileName ';' { (:[]) $1 } | FileName ';' ListFileName { (:) $1 $3 } { type Err = Either String happyError :: [Token] -> Err a happyError ts = Left $ "syntax error at " ++ tokenPos ts ++ case ts of [] -> [] [Err _] -> " due to lexer error" t:_ -> " before `" ++ (prToken t) ++ "'" myLexer :: String -> [Token] myLexer = tokens }