-- This Happy file was machine-generated by the BNF converter { module ParDep where import AbsDep import LexDep import ErrM } %name pModule Module %name pDecl Decl %monad { Err } { thenM } { returnM } %tokentype { Token } %token ';' { PT _ (TS ";") } ':' { PT _ (TS ":") } '=' { PT _ (TS "=") } '(' { PT _ (TS "(") } ')' { PT _ (TS ")") } '_' { PT _ (TS "_") } '\\' { PT _ (TS "\\") } '->' { PT _ (TS "->") } '?' { PT _ (TS "?") } 'Type' { PT _ (TS "Type") } 'import' { PT _ (TS "import") } 'in' { PT _ (TS "in") } 'let' { PT _ (TS "let") } L_ident { PT _ (TV $$) } L_err { _ } %% Ident : L_ident { Ident $1 } Module :: { Module } Module : ListImport ListDecl { Module (reverse $1) (reverse $2) } ListImport :: { [Import] } ListImport : {- empty -} { [] } | ListImport Import ';' { flip (:) $1 $2 } ListDecl :: { [Decl] } ListDecl : {- empty -} { [] } | ListDecl Decl ';' { flip (:) $1 $2 } Import :: { Import } Import : 'import' Ident { Import $2 } Decl :: { Decl } Decl : Ident ':' EExp { TypeDecl $1 $3 } | Ident ListPattern '=' EExp { PattDecl $1 (reverse $2) $4 } ListPattern :: { [Pattern] } ListPattern : {- empty -} { [] } | ListPattern Pattern { flip (:) $1 $2 } Pattern :: { Pattern } Pattern : '(' Ident ListPattern ')' { PCons $2 (reverse $3) } | Ident { PVar $1 } | 'Type' { PType } | '_' { PWild } EExp :: { EExp } EExp : 'let' Ident '=' EExp ':' EExp 'in' EExp { ELet $2 $4 $6 $8 } | EExp1 { $1 } EExp2 :: { EExp } EExp2 : '\\' Ident '->' EExp { EAbs $2 $4 } | '(' Ident ':' EExp ')' EExp2 { EPi $2 $4 $6 } | EExp3 { $1 } EExp3 :: { EExp } EExp3 : EExp3 EExp4 { EApp $1 $2 } | EExp4 { $1 } EExp4 :: { EExp } EExp4 : Ident { EVar $1 } | 'Type' { EType } | '?' { EMeta } | '(' EExp ')' { $2 } EExp1 :: { EExp } EExp1 : EExp2 { $1 } { returnM :: a -> Err a returnM = return thenM :: Err a -> (a -> Err b) -> Err b thenM = (>>=) happyError :: [Token] -> Err a happyError ts = Bad $ "syntax error at " ++ tokenPos ts ++ if null ts then [] else (" before " ++ unwords (map prToken (take 4 ts))) myLexer = tokens }