-- This Happy file was machine-generated by the BNF converter { {-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-} {-# LANGUAGE PatternSynonyms #-} module BNFC.Par ( happyError , myLexer , pGrammar , pListDef , pDef , pItem , pListItem , pCat , pListCat , pLabel , pArg , pListArg , pSeparation , pListString , pExp , pExp1 , pExp2 , pListExp , pListExp2 , pRHS , pListRHS , pMinimumSize , pReg , pReg1 , pReg2 , pReg3 ) where import Prelude import qualified BNFC.Abs import BNFC.Lex } %name pGrammar_internal Grammar %name pListDef_internal ListDef %name pDef_internal Def %name pItem_internal Item %name pListItem_internal ListItem %name pCat_internal Cat %name pListCat_internal ListCat %name pLabel_internal Label %name pArg_internal Arg %name pListArg_internal ListArg %name pSeparation_internal Separation %name pListString_internal ListString %name pExp_internal Exp %name pExp1_internal Exp1 %name pExp2_internal Exp2 %name pListExp_internal ListExp %name pListExp2_internal ListExp2 %name pRHS_internal RHS %name pListRHS_internal ListRHS %name pMinimumSize_internal MinimumSize %name pReg_internal Reg %name pReg1_internal Reg1 %name pReg2_internal Reg2 %name pReg3_internal Reg3 -- no lexer declaration %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) } 'char' { PT _ (TS _ 16) } 'coercions' { PT _ (TS _ 17) } 'comment' { PT _ (TS _ 18) } 'define' { PT _ (TS _ 19) } 'delimiters' { PT _ (TS _ 20) } 'digit' { PT _ (TS _ 21) } 'entrypoints' { PT _ (TS _ 22) } 'eps' { PT _ (TS _ 23) } 'internal' { PT _ (TS _ 24) } 'layout' { PT _ (TS _ 25) } 'letter' { PT _ (TS _ 26) } 'lower' { PT _ (TS _ 27) } 'nonempty' { PT _ (TS _ 28) } 'position' { PT _ (TS _ 29) } 'rules' { PT _ (TS _ 30) } 'separator' { PT _ (TS _ 31) } 'stop' { PT _ (TS _ 32) } 'terminator' { PT _ (TS _ 33) } 'token' { PT _ (TS _ 34) } 'toplevel' { PT _ (TS _ 35) } 'upper' { PT _ (TS _ 36) } '{' { PT _ (TS _ 37) } '|' { PT _ (TS _ 38) } '}' { PT _ (TS _ 39) } L_charac { PT _ (TC _) } L_doubl { PT _ (TD _) } L_integ { PT _ (TI _) } L_quoted { PT _ (TL _) } L_Identifier { PT _ (T_Identifier _) } %% Char :: { (BNFC.Abs.BNFC'Position, Char) } Char : L_charac { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), (read (tokenText $1)) :: Char) } Double :: { (BNFC.Abs.BNFC'Position, Double) } Double : L_doubl { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), (read (tokenText $1)) :: Double) } Integer :: { (BNFC.Abs.BNFC'Position, Integer) } Integer : L_integ { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), (read (tokenText $1)) :: Integer) } String :: { (BNFC.Abs.BNFC'Position, String) } String : L_quoted { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), ((\(PT _ (TL s)) -> s) $1)) } Identifier :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Identifier) } Identifier : L_Identifier { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Identifier (mkPosToken $1)) } Grammar :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Grammar) } Grammar : ListDef { (fst $1, BNFC.Abs.Grammar (fst $1) (snd $1)) } ListDef :: { (BNFC.Abs.BNFC'Position, [BNFC.Abs.Def]) } ListDef : {- empty -} { (BNFC.Abs.BNFC'NoPosition, []) } | Def { (fst $1, (:[]) (snd $1)) } | Def ';' ListDef { (fst $1, (:) (snd $1) (snd $3)) } | ';' ListDef { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), (snd $2)) } Def :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Def) } Def : Label '.' Cat '::=' RHS { (fst $1, BNFC.Abs.Rule (fst $1) (snd $1) (snd $3) (snd $5)) } | 'comment' String { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Comment (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } | 'comment' String String { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Comments (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $3)) } | 'internal' Label '.' Cat '::=' RHS { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Internal (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $4) (snd $6)) } | 'token' Identifier Reg { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Token (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $3)) } | 'position' 'token' Identifier Reg { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.PosToken (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $4)) } | 'entrypoints' ListCat { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Entryp (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } | 'separator' MinimumSize Cat String { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Separator (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $3) (snd $4)) } | 'terminator' MinimumSize Cat String { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Terminator (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $3) (snd $4)) } | 'delimiters' Cat String String Separation MinimumSize { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Delimiters (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $3) (snd $4) (snd $5) (snd $6)) } | 'coercions' Identifier Integer { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Coercions (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $3)) } | 'rules' Identifier '::=' ListRHS { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Rules (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $4)) } | 'define' Identifier ListArg '=' Exp { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Function (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $3) (snd $5)) } | 'layout' ListString { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Layout (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } | 'layout' 'stop' ListString { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.LayoutStop (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $3)) } | 'layout' 'toplevel' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.LayoutTop (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1))) } Item :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Item) } Item : String { (fst $1, BNFC.Abs.Terminal (fst $1) (snd $1)) } | Cat { (fst $1, BNFC.Abs.NTerminal (fst $1) (snd $1)) } ListItem :: { (BNFC.Abs.BNFC'Position, [BNFC.Abs.Item]) } ListItem : {- empty -} { (BNFC.Abs.BNFC'NoPosition, []) } | Item ListItem { (fst $1, (:) (snd $1) (snd $2)) } Cat :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Cat) } Cat : '[' Cat ']' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.ListCat (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } | Identifier { (fst $1, BNFC.Abs.IdCat (fst $1) (snd $1)) } ListCat :: { (BNFC.Abs.BNFC'Position, [BNFC.Abs.Cat]) } ListCat : {- empty -} { (BNFC.Abs.BNFC'NoPosition, []) } | Cat { (fst $1, (:[]) (snd $1)) } | Cat ',' ListCat { (fst $1, (:) (snd $1) (snd $3)) } Label :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Label) } Label : Identifier { (fst $1, BNFC.Abs.Id (fst $1) (snd $1)) } | '_' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.Wild (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1))) } | '[' ']' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.ListEmpty (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1))) } | '(' ':' ')' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.ListCons (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1))) } | '(' ':' '[' ']' ')' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.ListOne (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1))) } Arg :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Arg) } Arg : Identifier { (fst $1, BNFC.Abs.Arg (fst $1) (snd $1)) } ListArg :: { (BNFC.Abs.BNFC'Position, [BNFC.Abs.Arg]) } ListArg : {- empty -} { (BNFC.Abs.BNFC'NoPosition, []) } | Arg ListArg { (fst $1, (:) (snd $1) (snd $2)) } Separation :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Separation) } Separation : {- empty -} { (BNFC.Abs.BNFC'NoPosition, BNFC.Abs.SepNone BNFC.Abs.BNFC'NoPosition) } | 'terminator' String { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.SepTerm (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } | 'separator' String { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.SepSepar (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } ListString :: { (BNFC.Abs.BNFC'Position, [String]) } ListString : String { (fst $1, (:[]) (snd $1)) } | String ',' ListString { (fst $1, (:) (snd $1) (snd $3)) } Exp :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Exp) } Exp : Exp1 ':' Exp { (fst $1, BNFC.Abs.Cons (fst $1) (snd $1) (snd $3)) } | Exp1 { (fst $1, (snd $1)) } Exp1 :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Exp) } Exp1 : Identifier ListExp2 { (fst $1, BNFC.Abs.App (fst $1) (snd $1) (snd $2)) } | Exp2 { (fst $1, (snd $1)) } Exp2 :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Exp) } Exp2 : Identifier { (fst $1, BNFC.Abs.Var (fst $1) (snd $1)) } | Integer { (fst $1, BNFC.Abs.LitInteger (fst $1) (snd $1)) } | Char { (fst $1, BNFC.Abs.LitChar (fst $1) (snd $1)) } | String { (fst $1, BNFC.Abs.LitString (fst $1) (snd $1)) } | Double { (fst $1, BNFC.Abs.LitDouble (fst $1) (snd $1)) } | '[' ListExp ']' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.List (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } | '(' Exp ')' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), (snd $2)) } ListExp :: { (BNFC.Abs.BNFC'Position, [BNFC.Abs.Exp]) } ListExp : {- empty -} { (BNFC.Abs.BNFC'NoPosition, []) } | Exp { (fst $1, (:[]) (snd $1)) } | Exp ',' ListExp { (fst $1, (:) (snd $1) (snd $3)) } ListExp2 :: { (BNFC.Abs.BNFC'Position, [BNFC.Abs.Exp]) } ListExp2 : Exp2 { (fst $1, (:[]) (snd $1)) } | Exp2 ListExp2 { (fst $1, (:) (snd $1) (snd $2)) } RHS :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.RHS) } RHS : ListItem { (fst $1, BNFC.Abs.RHS (fst $1) (snd $1)) } ListRHS :: { (BNFC.Abs.BNFC'Position, [BNFC.Abs.RHS]) } ListRHS : RHS { (fst $1, (:[]) (snd $1)) } | RHS '|' ListRHS { (fst $1, (:) (snd $1) (snd $3)) } MinimumSize :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.MinimumSize) } MinimumSize : 'nonempty' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.MNonEmpty (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1))) } | {- empty -} { (BNFC.Abs.BNFC'NoPosition, BNFC.Abs.MEmpty BNFC.Abs.BNFC'NoPosition) } Reg :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Reg) } Reg : Reg '|' Reg1 { (fst $1, BNFC.Abs.RAlt (fst $1) (snd $1) (snd $3)) } | Reg1 { (fst $1, (snd $1)) } Reg1 :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Reg) } Reg1 : Reg1 '-' Reg2 { (fst $1, BNFC.Abs.RMinus (fst $1) (snd $1) (snd $3)) } | Reg2 { (fst $1, (snd $1)) } Reg2 :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Reg) } Reg2 : Reg2 Reg3 { (fst $1, BNFC.Abs.RSeq (fst $1) (snd $1) (snd $2)) } | Reg3 { (fst $1, (snd $1)) } Reg3 :: { (BNFC.Abs.BNFC'Position, BNFC.Abs.Reg) } Reg3 : Reg3 '*' { (fst $1, BNFC.Abs.RStar (fst $1) (snd $1)) } | Reg3 '+' { (fst $1, BNFC.Abs.RPlus (fst $1) (snd $1)) } | Reg3 '?' { (fst $1, BNFC.Abs.ROpt (fst $1) (snd $1)) } | 'eps' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.REps (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1))) } | Char { (fst $1, BNFC.Abs.RChar (fst $1) (snd $1)) } | '[' String ']' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.RAlts (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } | '{' String '}' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.RSeqs (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1)) (snd $2)) } | 'digit' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.RDigit (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1))) } | 'letter' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.RLetter (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1))) } | 'upper' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.RUpper (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1))) } | 'lower' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.RLower (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1))) } | 'char' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), BNFC.Abs.RAny (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1))) } | '(' Reg ')' { (uncurry BNFC.Abs.BNFC'Position (tokenLineCol $1), (snd $2)) } { 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 -- Entrypoints pGrammar :: [Token] -> Err BNFC.Abs.Grammar pGrammar = fmap snd . pGrammar_internal pListDef :: [Token] -> Err [BNFC.Abs.Def] pListDef = fmap snd . pListDef_internal pDef :: [Token] -> Err BNFC.Abs.Def pDef = fmap snd . pDef_internal pItem :: [Token] -> Err BNFC.Abs.Item pItem = fmap snd . pItem_internal pListItem :: [Token] -> Err [BNFC.Abs.Item] pListItem = fmap snd . pListItem_internal pCat :: [Token] -> Err BNFC.Abs.Cat pCat = fmap snd . pCat_internal pListCat :: [Token] -> Err [BNFC.Abs.Cat] pListCat = fmap snd . pListCat_internal pLabel :: [Token] -> Err BNFC.Abs.Label pLabel = fmap snd . pLabel_internal pArg :: [Token] -> Err BNFC.Abs.Arg pArg = fmap snd . pArg_internal pListArg :: [Token] -> Err [BNFC.Abs.Arg] pListArg = fmap snd . pListArg_internal pSeparation :: [Token] -> Err BNFC.Abs.Separation pSeparation = fmap snd . pSeparation_internal pListString :: [Token] -> Err [String] pListString = fmap snd . pListString_internal pExp :: [Token] -> Err BNFC.Abs.Exp pExp = fmap snd . pExp_internal pExp1 :: [Token] -> Err BNFC.Abs.Exp pExp1 = fmap snd . pExp1_internal pExp2 :: [Token] -> Err BNFC.Abs.Exp pExp2 = fmap snd . pExp2_internal pListExp :: [Token] -> Err [BNFC.Abs.Exp] pListExp = fmap snd . pListExp_internal pListExp2 :: [Token] -> Err [BNFC.Abs.Exp] pListExp2 = fmap snd . pListExp2_internal pRHS :: [Token] -> Err BNFC.Abs.RHS pRHS = fmap snd . pRHS_internal pListRHS :: [Token] -> Err [BNFC.Abs.RHS] pListRHS = fmap snd . pListRHS_internal pMinimumSize :: [Token] -> Err BNFC.Abs.MinimumSize pMinimumSize = fmap snd . pMinimumSize_internal pReg :: [Token] -> Err BNFC.Abs.Reg pReg = fmap snd . pReg_internal pReg1 :: [Token] -> Err BNFC.Abs.Reg pReg1 = fmap snd . pReg1_internal pReg2 :: [Token] -> Err BNFC.Abs.Reg pReg2 = fmap snd . pReg2_internal pReg3 :: [Token] -> Err BNFC.Abs.Reg pReg3 = fmap snd . pReg3_internal }