{-# LANGUAGE CPP #-}
module Agda.Syntax.Concrete.Operators.Parser.Monad
( MemoKey(..), PrecedenceKey
, Parser
, parse
, sat'
, sat
, doc
, memoise
, memoiseIfPrinting
, grammar
) where
import Data.Hashable
import GHC.Generics (Generic)
import Text.PrettyPrint.HughesPJ
import Agda.Syntax.Common
import qualified Agda.Utils.Parser.MemoisedCPS as Parser
data MemoKey = NodeK PrecedenceKey
| PostLeftsK PrecedenceKey
| PreRightsK PrecedenceKey
| TopK
| AppK
| NonfixK
deriving (MemoKey -> MemoKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MemoKey -> MemoKey -> Bool
$c/= :: MemoKey -> MemoKey -> Bool
== :: MemoKey -> MemoKey -> Bool
$c== :: MemoKey -> MemoKey -> Bool
Eq, Int -> MemoKey -> ShowS
[MemoKey] -> ShowS
MemoKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MemoKey] -> ShowS
$cshowList :: [MemoKey] -> ShowS
show :: MemoKey -> String
$cshow :: MemoKey -> String
showsPrec :: Int -> MemoKey -> ShowS
$cshowsPrec :: Int -> MemoKey -> ShowS
Show, forall x. Rep MemoKey x -> MemoKey
forall x. MemoKey -> Rep MemoKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MemoKey x -> MemoKey
$cfrom :: forall x. MemoKey -> Rep MemoKey x
Generic)
type PrecedenceKey = Either PrecedenceLevel PrecedenceLevel
instance Hashable MemoKey
type Parser tok a =
#ifdef DEBUG
Parser.ParserWithGrammar
#else
Parser.Parser
#endif
MemoKey tok (MaybePlaceholder tok) a
parse :: forall tok a. Parser tok a -> [MaybePlaceholder tok] -> [a]
parse :: forall tok a. Parser tok a -> [MaybePlaceholder tok] -> [a]
parse = forall (p :: * -> *) k r tok a.
ParserClass p k r tok =>
p a -> [tok] -> [a]
Parser.parse
sat' :: (MaybePlaceholder tok -> Maybe a) -> Parser tok a
sat' :: forall tok a. (MaybePlaceholder tok -> Maybe a) -> Parser tok a
sat' = forall (p :: * -> *) k r tok a.
ParserClass p k r tok =>
(tok -> Maybe a) -> p a
Parser.sat'
sat :: (MaybePlaceholder tok -> Bool) ->
Parser tok (MaybePlaceholder tok)
sat :: forall tok.
(MaybePlaceholder tok -> Bool) -> Parser tok (MaybePlaceholder tok)
sat = forall (p :: * -> *) k r tok.
ParserClass p k r tok =>
(tok -> Bool) -> p tok
Parser.sat
doc :: Doc -> Parser tok a -> Parser tok a
doc :: forall tok a. Doc -> Parser tok a -> Parser tok a
doc = forall (p :: * -> *) k r tok a.
ParserClass p k r tok =>
Doc -> p a -> p a
Parser.doc
memoise :: MemoKey -> Parser tok tok -> Parser tok tok
memoise :: forall tok. MemoKey -> Parser tok tok -> Parser tok tok
memoise = forall (p :: * -> *) k r tok.
(ParserClass p k r tok, Eq k, Hashable k, Show k) =>
k -> p r -> p r
Parser.memoise
memoiseIfPrinting :: MemoKey -> Parser tok tok -> Parser tok tok
memoiseIfPrinting :: forall tok. MemoKey -> Parser tok tok -> Parser tok tok
memoiseIfPrinting = forall (p :: * -> *) k r tok.
(ParserClass p k r tok, Eq k, Hashable k, Show k) =>
k -> p r -> p r
Parser.memoiseIfPrinting
grammar :: Parser tok a -> Doc
grammar :: forall tok a. Parser tok a -> Doc
grammar = forall (p :: * -> *) k r tok a.
(ParserClass p k r tok, Show k) =>
p a -> Doc
Parser.grammar