Agda-2.5.2: A dependently typed functional programming language and proof assistant

Safe Haskell | None
Language | Haskell2010

Agda.Syntax.Concrete.Operators.Parser.Monad

Description

The parser monad used by the operator parser

Synopsis

- data MemoKey
  - = NodeK (Either Integer Integer)
  - | PostLeftsK (Either Integer Integer)
  - | PreRightsK (Either Integer Integer)
  - | TopK
  - | AppK
  - | NonfixK
- type Parser tok a = Parser MemoKey tok (MaybePlaceholder tok) a
- parse :: forall tok a. Parser tok a -> [MaybePlaceholder tok] -> [a]
- token :: Parser tok (MaybePlaceholder tok)
- sat :: (MaybePlaceholder tok -> Bool) -> Parser tok (MaybePlaceholder tok)
- tok :: (Eq tok, Show tok) => MaybePlaceholder tok -> Parser tok (MaybePlaceholder tok)
- annotate :: (Doc -> Doc) -> Parser tok a -> Parser tok a
- memoise :: MemoKey -> Parser tok tok -> Parser tok tok
- memoiseIfPrinting :: MemoKey -> Parser tok tok -> Parser tok tok
- grammar :: Parser tok a -> Doc

# Documentation

data MemoKey #

Memoisation keys.

Constructors

NodeK (Either Integer Integer) |
PostLeftsK (Either Integer Integer) |
PreRightsK (Either Integer Integer) |
TopK |
AppK |
NonfixK |

Instances

Eq MemoKey # |
Methods (==) :: MemoKey -> MemoKey -> Bool # (/=) :: MemoKey -> MemoKey -> Bool #
Show MemoKey # |
Methods showsPrec :: Int -> MemoKey -> ShowS # show :: MemoKey -> String # showList :: [MemoKey] -> ShowS #
Generic MemoKey # |
Associated Types type Rep MemoKey :: * -> * # Methods from :: MemoKey -> Rep MemoKey x # to :: Rep MemoKey x -> MemoKey #
Hashable MemoKey # |
Methods hashWithSalt :: Int -> MemoKey -> Int # hash :: MemoKey -> Int #
type Rep MemoKey # |
type Rep MemoKey = D1 (MetaData "MemoKey" "Agda.Syntax.Concrete.Operators.Parser.Monad" "Agda-2.5.2-BvXz1IFuA8Y7bbv0poFInq" False) ((:+:) ((:+:) (C1 (MetaCons "NodeK" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Either Integer Integer)))) ((:+:) (C1 (MetaCons "PostLeftsK" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Either Integer Integer)))) (C1 (MetaCons "PreRightsK" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Either Integer Integer)))))) ((:+:) (C1 (MetaCons "TopK" PrefixI False) U1) ((:+:) (C1 (MetaCons "AppK" PrefixI False) U1) (C1 (MetaCons "NonfixK" PrefixI False) U1))))

type Parser tok a = Parser MemoKey tok (MaybePlaceholder tok) a #

The parser monad.

parse :: forall tok a. Parser tok a -> [MaybePlaceholder tok] -> [a] #

Runs the parser.

token :: Parser tok (MaybePlaceholder tok) #

Parses a single token.

sat :: (MaybePlaceholder tok -> Bool) -> Parser tok (MaybePlaceholder tok) #

Parses a token satisfying the given predicate.

tok :: (Eq tok, Show tok) => MaybePlaceholder tok -> Parser tok (MaybePlaceholder tok) #

Parses a given token.

annotate :: (Doc -> Doc) -> Parser tok a -> Parser tok a #

Uses the given function to modify the printed representation (if any) of the given parser.

memoise :: MemoKey -> Parser tok tok -> Parser tok tok #

Memoises the given parser.

Every memoised parser must be annotated with a unique key. (Parametrised parsers must use distinct keys for distinct inputs.)

memoiseIfPrinting :: MemoKey -> Parser tok tok -> Parser tok tok #

Memoises the given parser, but only if printing, not if parsing.

Every memoised parser must be annotated with a unique key. (Parametrised parsers must use distinct keys for distinct inputs.)

grammar :: Parser tok a -> Doc #

Tries to print the parser, or returns `empty`, depending on the implementation. This function might not terminate.