1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
-- See <https://github.com/haskell/happy/issues/94> for more information
%name parse prod
%tokentype { Token }
%monad { P } { bindP } { returnP }
%error { error "parse error" }
%lexer { lexer } { EOF }
%token
IDENT { Identifier $$ }
%%
prod
: IDENT { () }
{
data Token = EOF | Identifier String
type P a = String -> (a, String)
bindP :: P a -> (a -> P b) -> P b
bindP p f s = let (x,s') = p s in f x s'
returnP :: a -> P a
returnP = (,)
lexer :: (Token -> P a) -> P a
lexer cont s = cont (case s of { "" -> EOF; _ -> Identifier s }) ""
main = return ()
}
|