-- This Happy file was machine-generated by the BNF converter { module ParHao where import AbsHao import LexHao import ErrM } %name pListOp ListOp %name pListTerm ListTerm %name pListIdent ListIdent %name pListCase ListCase %name pListGuard ListGuard %name pListFixity ListFixity %name pListExport ListExport %name pModule Module %name pExport Export %name pQIdent QIdent %name pQInfix QInfix %name pSymbol Symbol %name pOp Op %name pTerm Term %name pTerm1 Term1 %name pTerm2 Term2 %name pTerm3 Term3 %name pTerm4 Term4 %name pCase Case %name pGuard Guard %name pAssoc Assoc %name pFixity Fixity %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 "|") } ':' { PT _ (TS ":") } '`' { PT _ (TS "`") } 'case' { PT _ (TS "case") } 'default' { PT _ (TS "default") } 'export' { PT _ (TS "export") } 'left' { PT _ (TS "left") } 'module' { PT _ (TS "module") } 'operator' { PT _ (TS "operator") } 'precedes' { PT _ (TS "precedes") } 'right' { PT _ (TS "right") } 'succeeds' { PT _ (TS "succeeds") } L_ident { PT _ (TV $$) } L_Infix { PT _ (T_Infix $$) } L_err { _ } %% Ident : L_ident { Ident $1 } Infix : L_Infix { Infix $1 } ListOp :: { [Op] } ListOp : {- empty -} { [] } | Op { (:[]) $1 } | Op ',' ListOp { (:) $1 $3 } ListTerm :: { [Term] } ListTerm : {- empty -} { [] } | Term { (:[]) $1 } | Term ',' ListTerm { (:) $1 $3 } ListIdent :: { [Ident] } ListIdent : Ident '::' { (:[]) $1 } | Ident '::' ListIdent { (:) $1 $3 } ListCase :: { [Case] } ListCase : {- empty -} { [] } | ListCase Case { flip (:) $1 $2 } ListGuard :: { [Guard] } ListGuard : {- empty -} { [] } | ListGuard Guard { flip (:) $1 $2 } ListFixity :: { [Fixity] } ListFixity : {- empty -} { [] } | ListFixity Fixity { flip (:) $1 $2 } ListExport :: { [Export] } ListExport : {- empty -} { [] } | ListExport Export ';' { flip (:) $1 $2 } Module :: { Module } Module : 'module' ListIdent ';' ListExport Term { Module $2 (reverse $4) $5 } Export :: { Export } Export : 'export' Symbol { Export $2 } QIdent :: { QIdent } QIdent : ListIdent Ident { FQIdent $1 $2 } QInfix :: { QInfix } QInfix : ListIdent Infix { FQInfix $1 $2 } Symbol :: { Symbol } Symbol : QIdent { IdSym $1 } | '(' Op ')' { OpSym $2 } Op :: { Op } Op : QInfix { InfOp $1 } | '`' Symbol '`' { IdOp $2 } Term :: { Term } Term : Term1 { $1 } | Term ';' Term1 { Seq $1 $3 } Term1 :: { Term } Term1 : Term2 { $1 } | Term4 '=' Term1 { Binding $1 $3 } Term2 :: { Term } Term2 : Term3 { $1 } | Term2 Op Term3 { OpApp $1 $2 $3 } Term3 :: { Term } Term3 : Term4 { $1 } | Term3 Term4 { App $1 $2 } Term4 :: { Term } Term4 : Symbol { Var $1 } | '{' ListCase '}' { Form (reverse $2) } | '{' Term '}' { Block $2 } | '(' ListTerm ')' { Tuple $2 } | 'operator' Op Assoc ListFixity { OpDecl $2 $3 (reverse $4) } Case :: { Case } Case : 'case' Term ListGuard { PatCase $2 (reverse $3) } Guard :: { Guard } Guard : '|' Term ':' Term { NormGuard $2 $4 } | '|' 'default' ':' Term { DefaultGuard $4 } Assoc :: { Assoc } Assoc : 'left' { LeftAssoc } | 'right' { RightAssoc } | {- empty -} { NoAssoc } Fixity :: { Fixity } Fixity : 'precedes' '(' ListOp ')' { GtFixity $3 } | 'succeeds' '(' ListOp ')' { LtFixity $3 } { 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 }