{-# LANGUAGE TypeOperators, FlexibleInstances #-}
module GLL.Combinators.BinaryInterface (
term_parser, satisfy,
keychar, keyword, int_lit, float_lit, bool_lit, char_lit, string_lit, alt_id_lit, id_lit, token,
char,
(<**>),
(<||>),
(<$$>),
(<:=>),(<::=>),chooses,chooses_prec,
BNF, SymbExpr, toSymb, mkRule,
Token(..), Parseable(..), SubsumesToken(..), unlexTokens, unlexToken,
grammarOf, parse, printParseData, evaluatorWithParseData,
parseWithOptions, parseWithParseOptions, printParseDataWithOptions, evaluatorWithParseDataAndOptions,printGrammarData,
CombinatorOptions, CombinatorOption,
GLL.Combinators.Options.maximumErrors, throwErrors,
maximumPivot, maximumPivotAtNt, leftBiased,
fullSPPF, allNodes, packedNodesOnly, strictBinarisation,
GLL.Parser.noSelectTest,
parseWithOptionsAndError, parseWithParseOptionsAndError,
parseResult, parseResultWithOptions,ParseResult(..),
default_lexer,
lexer, LexerSettings(..), emptyLanguage,
mkNt,
(<$$), (**>), (<**),
optional, preferably, reluctantly, optionalWithDef,
multiple, multiple1, multipleSepBy, multipleSepBy1,
multipleSepBy2, within, parens, braces, brackets, angles,
(<:=), (<::=),(<<<**>), (<**>>>), (<<**>), (<<<**), (**>>>), (<**>>),
longest_match,shortest_match,
many, many1, some, some1,
manySepBy, manySepBy1, manySepBy2,
someSepBy, someSepBy1,someSepBy2,
memo, newMemoTable, memClear, MemoTable, MemoRef, useMemoisation,
module GLL.Combinators.Interface
) where
import GLL.Combinators.Interface hiding (within, (**>), (<**>), (<**), (<<<**>), (<<<**), (**>>>), (<**>>>), satisfy, (<||>), (<||), (||>), (<$$>), (<$$), (<:=>), (<:=),(<::=>), (<::=), mkNt, manySepBy, manySepBy1, manySepBy2, multiple, multipleSepBy, many, multipleSepBy1, multipleSepBy2, someSepBy, someSepBy1, someSepBy2, some, memo, some1, many1, multiple1, shortest_match, longest_match, (<**>>), (<<**>), angles, braces, brackets, parens, within, optional, optionalWithDef, preferably, reluctantly, chooses, chooses_prec)
import qualified GLL.Combinators.Interface as IF
import GLL.Combinators.Options
import GLL.Combinators.Visit.Join
import GLL.Combinators.Visit.Sem (emptyAncestors)
import GLL.Combinators.Memoisation
import GLL.Combinators.Lexer
import GLL.Types.Grammar
import GLL.Parser hiding (parse, parseWithOptions)
import qualified GLL.Parser as GLL
import GLL.Types.TypeCompose (OO(..))
import Control.Arrow
import qualified Data.Array as A
import qualified Data.IntMap as IM
import qualified Data.Map as M
import Data.Text (pack)
import Data.IORef
import Data.Time.Clock
import System.IO.Unsafe
infixl 2 <:=>
(<:=>) :: (Show t, Ord t) => String -> BNF t a -> BNF t a
String
n <:=> :: forall t a. (Show t, Ord t) => String -> BNF t a -> BNF t a
<:=> BNF t a
p = String
n forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
String -> b t a -> SymbExpr t a
IF.<:=> BNF t a
p
infixl 2 <::=>
(<::=>) :: (Show t, Ord t) => String -> BNF t a -> BNF t a
String
n <::=> :: forall t a. (Show t, Ord t) => String -> BNF t a -> BNF t a
<::=> BNF t a
p = String
n forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
String -> b t a -> SymbExpr t a
IF.<::=> BNF t a
p
chooses :: (Show t, Ord t) => String -> [BNF t a] -> BNF t a
chooses :: forall t a. (Show t, Ord t) => String -> [BNF t a] -> BNF t a
chooses String
p [BNF t a]
alts = forall t (alt :: * -> * -> *) a.
(Show t, Ord t, IsAltExpr alt) =>
String -> [alt t a] -> SymbExpr t a
IF.chooses String
p [BNF t a]
alts
chooses_prec :: (Show t, Ord t) => String -> [BNF t a] -> BNF t a
chooses_prec :: forall t a. (Show t, Ord t) => String -> [BNF t a] -> BNF t a
chooses_prec String
p [BNF t a]
alts = forall t (alt :: * -> * -> *) a.
(Show t, Ord t, IsAltExpr alt) =>
String -> [alt t a] -> SymbExpr t a
IF.chooses_prec String
p [BNF t a]
alts
infixl 4 <$$>
(<$$>) :: (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
a -> b
f <$$> :: forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p' = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
IF.toSymb (a -> b
f forall t (s :: * -> * -> *) a b.
(Show t, Ord t, IsSymbExpr s) =>
(a -> b) -> s t a -> AltExpr t b
IF.<$$> BNF t a
p')
infixl 4 <**>,<<<**>,<**>>>
(<**>) :: (Show t, Ord t) => BNF t (a -> b) -> BNF t a -> BNF t b
BNF t (a -> b)
pl' <**> :: forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF t a
pr' = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
IF.toSymb (BNF t (a -> b)
pl' forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t (a -> b) -> s t a -> AltExpr t b
IF.<**> BNF t a
pr')
(<**>>>) :: (Show t, Ord t) => BNF t (a -> b) -> BNF t a -> BNF t b
BNF t (a -> b)
pl' <**>>> :: forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**>>> BNF t a
pr' = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
IF.toSymb (BNF t (a -> b)
pl' forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t (a -> b) -> s t a -> AltExpr t b
IF.<**>>> BNF t a
pr')
(<<<**>) :: (Show t, Ord t) => BNF t (a -> b) -> BNF t a -> BNF t b
BNF t (a -> b)
pl' <<<**> :: forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<<<**> BNF t a
pr' = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
IF.toSymb (BNF t (a -> b)
pl' forall t (i :: * -> * -> *) (s :: * -> * -> *) a b.
(Show t, Ord t, IsAltExpr i, IsSymbExpr s) =>
i t (a -> b) -> s t a -> AltExpr t b
IF.<<<**> BNF t a
pr')
infixr 3 <||>
(<||>) :: (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
BNF t a
l' <||> :: forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> BNF t a
r' = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
IF.toSymb (BNF t a
l' forall t (i :: * -> * -> *) (b :: * -> * -> *) a.
(Show t, Ord t, IsAltExpr i, HasAlts b) =>
i t a -> b t a -> AltExprs t a
IF.<||> BNF t a
r')
longest_match :: (Show t, Ord t) => BNF t a -> BNF t a
longest_match :: forall t a. (Show t, Ord t) => BNF t a -> BNF t a
longest_match BNF t a
isalt = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
IF.toSymb (forall t (alt :: * -> * -> *) a.
(Show t, Ord t, IsAltExpr alt) =>
alt t a -> AltExpr t a
IF.longest_match BNF t a
isalt)
shortest_match :: (Show t, Ord t) => BNF t a -> BNF t a
shortest_match :: forall t a. (Show t, Ord t) => BNF t a -> BNF t a
shortest_match BNF t a
isalt = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
IF.toSymb (forall t (alt :: * -> * -> *) a.
(Show t, Ord t, IsAltExpr alt) =>
alt t a -> AltExpr t a
IF.shortest_match BNF t a
isalt)
satisfy :: (Show t, Ord t ) => a -> BNF t a
satisfy :: forall t a. (Show t, Ord t) => a -> BNF t a
satisfy a
a = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
IF.toSymb (forall t a. (Show t, Ord t) => a -> AltExpr t a
IF.satisfy a
a)
memo :: (Ord t, Show t) => MemoRef [a] -> BNF t a -> BNF t a
memo :: forall t a. (Ord t, Show t) => MemoRef [a] -> BNF t a -> BNF t a
memo MemoRef [a]
ref BNF t a
p' = forall t (s :: * -> * -> *) a.
(Ord t, Show t, IsSymbExpr s) =>
MemoRef [a] -> s t a -> SymbExpr t a
IF.memo MemoRef [a]
ref BNF t a
p'
mkNt :: (Show t, Ord t) => BNF t a -> String -> String
mkNt :: forall t a. (Show t, Ord t) => BNF t a -> String -> String
mkNt BNF t a
p String
str = forall t (s :: * -> * -> *) a.
(Show t, Ord t, IsSymbExpr s) =>
s t a -> String -> String
IF.mkNt BNF t a
p String
str
(<$$) :: (Show t, Ord t) => b -> BNF t a -> BNF t b
b
f <$$ :: forall t b a. (Show t, Ord t) => b -> BNF t a -> BNF t b
<$$ BNF t a
p = forall a b. a -> b -> a
const b
f forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p
infixl 4 <$$
infixl 4 **>, <<**>, **>>>
(**>) :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t b
BNF t a
l **> :: forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t b
**> BNF t b
r = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b. a -> b -> a
const forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
l forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF t b
r
(**>>>) :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t b
BNF t a
l **>>> :: forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t b
**>>> BNF t b
r = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b. a -> b -> a
const forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
l forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**>>> BNF t b
r
(<<**>) :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t b
BNF t a
l <<**> :: forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t b
<<**>BNF t b
r = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b. a -> b -> a
const forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
l forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<<<**> BNF t b
r
infixl 4 <**, <<<**, <**>>
(<**) :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
BNF t a
l <** :: forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** BNF t b
r = forall a b. a -> b -> a
const forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
l forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF t b
r
(<**>>) :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
BNF t a
l <**>> :: forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<**>> BNF t b
r = forall a b. a -> b -> a
const forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
l forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**>>> BNF t b
r
(<<<**) :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
BNF t a
l <<<** :: forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<<<** BNF t b
r = forall a b. a -> b -> a
const forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
l forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<<<**> BNF t b
r
String
x <::= :: String -> b t a -> SymbExpr t a
<::= b t a
altPs = String
x forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
String -> b t a -> SymbExpr t a
IF.<::= b t a
altPs
infixl 2 <::=
String
x <:= :: String -> b t a -> SymbExpr t a
<:= b t a
altPs = String
x forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
String -> b t a -> SymbExpr t a
IF.<:= b t a
altPs
infixl 2 <:=
many :: (Show t, Ord t) => BNF t a -> BNF t [a]
many :: forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
many = forall {t} {t} {a} {a}.
(Show t, Ord t, Show t, Ord t) =>
(BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a])
-> BNF t a -> BNF t [a]
multiple_ forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
(<<<**>)
many1 :: (Show t, Ord t) => BNF t a -> BNF t [a]
many1 :: forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
many1 = forall {t} {t} {a} {a}.
(Show t, Ord t, Show t, Ord t) =>
(BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a])
-> BNF t a -> BNF t [a]
multiple1_ forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
(<<<**>)
some :: (Show t, Ord t) => BNF t a -> BNF t [a]
some :: forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
some = forall {t} {t} {a} {a}.
(Show t, Ord t, Show t, Ord t) =>
(BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a])
-> BNF t a -> BNF t [a]
multiple_ forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
(<**>>>)
some1 :: (Show t, Ord t) => BNF t a -> BNF t [a]
some1 :: forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
some1 = forall {t} {t} {a} {a}.
(Show t, Ord t, Show t, Ord t) =>
(BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a])
-> BNF t a -> BNF t [a]
multiple1_ forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
(<**>>>)
multiple :: (Show t, Ord t) => BNF t a -> BNF t [a]
multiple :: forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple = forall {t} {t} {a} {a}.
(Show t, Ord t, Show t, Ord t) =>
(BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a])
-> BNF t a -> BNF t [a]
multiple_ forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
(<**>)
multiple1 :: (Show t, Ord t) => BNF t a -> BNF t [a]
multiple1 :: forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple1 = forall {t} {t} {a} {a}.
(Show t, Ord t, Show t, Ord t) =>
(BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a])
-> BNF t a -> BNF t [a]
multiple1_ forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
(<**>)
multiple_ :: (BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a])
-> BNF t a -> BNF t [a]
multiple_ BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a]
disa BNF t a
p = let fresh :: String
fresh = forall t a. (Show t, Ord t) => BNF t a -> String -> String
mkNt BNF t a
p String
"*"
in String
fresh forall t a. (Show t, Ord t) => String -> BNF t a -> BNF t a
<::=> ((:) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p) BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a]
`disa` ((BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a])
-> BNF t a -> BNF t [a]
multiple_ BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a]
disa BNF t a
p) forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy []
multiple1_ :: (BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a])
-> BNF t a -> BNF t [a]
multiple1_ BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a]
disa BNF t a
p = let fresh :: String
fresh = forall t a. (Show t, Ord t) => BNF t a -> String -> String
mkNt BNF t a
p String
"+"
in String
fresh forall t a. (Show t, Ord t) => String -> BNF t a -> BNF t a
<::=> ((:) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p) BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a]
`disa` (forall {t} {t} {a} {a}.
(Show t, Ord t, Show t, Ord t) =>
(BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a])
-> BNF t a -> BNF t [a]
multiple_ BNF t ([a] -> [a]) -> BNF t [a] -> BNF t [a]
disa BNF t a
p)
manySepBy :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
manySepBy :: forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
manySepBy = forall t a b.
(Show t, Ord t) =>
(BNF t a -> BNF t [a]) -> BNF t a -> BNF t b -> BNF t [a]
sepBy forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
many
manySepBy1 :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
manySepBy1 :: forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
manySepBy1 = forall t a b.
(Show t, Ord t) =>
(BNF t a -> BNF t [a]) -> BNF t a -> BNF t b -> BNF t [a]
sepBy1 forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
many
someSepBy :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
someSepBy :: forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
someSepBy = forall t a b.
(Show t, Ord t) =>
(BNF t a -> BNF t [a]) -> BNF t a -> BNF t b -> BNF t [a]
sepBy forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
some
someSepBy1 :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
someSepBy1 :: forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
someSepBy1 = forall t a b.
(Show t, Ord t) =>
(BNF t a -> BNF t [a]) -> BNF t a -> BNF t b -> BNF t [a]
sepBy1 forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
some
multipleSepBy :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
multipleSepBy :: forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
multipleSepBy = forall t a b.
(Show t, Ord t) =>
(BNF t a -> BNF t [a]) -> BNF t a -> BNF t b -> BNF t [a]
sepBy forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple
multipleSepBy1 :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
multipleSepBy1 :: forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
multipleSepBy1 = forall t a b.
(Show t, Ord t) =>
(BNF t a -> BNF t [a]) -> BNF t a -> BNF t b -> BNF t [a]
sepBy1 forall t a. (Show t, Ord t) => BNF t a -> BNF t [a]
multiple
sepBy :: (Show t, Ord t) => (BNF t a -> BNF t [a]) -> BNF t a -> BNF t b -> BNF t [a]
sepBy :: forall t a b.
(Show t, Ord t) =>
(BNF t a -> BNF t [a]) -> BNF t a -> BNF t b -> BNF t [a]
sepBy BNF t a -> BNF t [a]
mult BNF t a
p BNF t b
c = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
mkRule forall a b. (a -> b) -> a -> b
$ forall t a. (Show t, Ord t) => a -> BNF t a
satisfy [] forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> (:) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF t a -> BNF t [a]
mult (BNF t b
c forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t b
**> BNF t a
p)
sepBy1 :: (Show t, Ord t) => (BNF t a -> BNF t [a]) -> BNF t a -> BNF t b -> BNF t [a]
sepBy1 :: forall t a b.
(Show t, Ord t) =>
(BNF t a -> BNF t [a]) -> BNF t a -> BNF t b -> BNF t [a]
sepBy1 BNF t a -> BNF t [a]
mult BNF t a
p BNF t b
c = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
mkRule forall a b. (a -> b) -> a -> b
$ (:) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> BNF t a -> BNF t [a]
mult (BNF t b
c forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t b
**> BNF t a
p)
multipleSepBy2 :: BNF t a -> BNF t b -> BNF t [a]
multipleSepBy2 BNF t a
p BNF t b
s = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
mkRule forall a b. (a -> b) -> a -> b
$
(:) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** BNF t b
s forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
multipleSepBy1 BNF t a
p BNF t b
s
someSepBy2 :: BNF t a -> BNF t b -> BNF t [a]
someSepBy2 BNF t a
p BNF t b
s = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
mkRule forall a b. (a -> b) -> a -> b
$
(:) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** BNF t b
s forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
someSepBy1 BNF t a
p BNF t b
s
manySepBy2 :: BNF t a -> BNF t b -> BNF t [a]
manySepBy2 BNF t a
p BNF t b
s = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
mkRule forall a b. (a -> b) -> a -> b
$
(:) forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** BNF t b
s forall t a b.
(Show t, Ord t) =>
BNF t (a -> b) -> BNF t a -> BNF t b
<**> forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t [a]
manySepBy1 BNF t a
p BNF t b
s
optional :: (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
optional :: forall t a. (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
optional BNF t a
p = String
fresh
forall t a. (Show t, Ord t) => String -> BNF t a -> BNF t a
<:=> forall a. a -> Maybe a
Just forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p
forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy forall a. Maybe a
Nothing
where fresh :: String
fresh = forall t a. (Show t, Ord t) => BNF t a -> String -> String
mkNt BNF t a
p String
"?"
preferably :: (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
preferably :: forall t a. (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
preferably BNF t a
p = String
fresh
forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
String -> b t a -> SymbExpr t a
<:= forall a. a -> Maybe a
Just forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p
forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy forall a. Maybe a
Nothing
where fresh :: String
fresh = forall t a. (Show t, Ord t) => BNF t a -> String -> String
mkNt BNF t a
p String
"?"
reluctantly :: (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
reluctantly :: forall t a. (Show t, Ord t) => BNF t a -> BNF t (Maybe a)
reluctantly BNF t a
p = String
fresh
forall t (b :: * -> * -> *) a.
(Show t, Ord t, HasAlts b) =>
String -> b t a -> SymbExpr t a
<:= forall t a. (Show t, Ord t) => a -> BNF t a
satisfy forall a. Maybe a
Nothing
forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall a. a -> Maybe a
Just forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p
where fresh :: String
fresh = forall t a. (Show t, Ord t) => BNF t a -> String -> String
mkNt BNF t a
p String
"?"
optionalWithDef :: (Show t, Ord t) => BNF t a -> a -> BNF t a
optionalWithDef :: forall t a. (Show t, Ord t) => BNF t a -> a -> BNF t a
optionalWithDef BNF t a
p a
def = forall t a. (Show t, Ord t) => BNF t a -> String -> String
mkNt BNF t a
p String
"?" forall t a. (Show t, Ord t) => String -> BNF t a -> BNF t a
<:=> forall a. a -> a
id forall t a b. (Show t, Ord t) => (a -> b) -> BNF t a -> BNF t b
<$$> BNF t a
p forall t a. (Show t, Ord t) => BNF t a -> BNF t a -> BNF t a
<||> forall t a. (Show t, Ord t) => a -> BNF t a
satisfy a
def
within :: (Show t, Ord t) => BNF t a -> BNF t b -> BNF t c -> BNF t b
within :: forall t a b c.
(Show t, Ord t) =>
BNF t a -> BNF t b -> BNF t c -> BNF t b
within BNF t a
l BNF t b
p BNF t c
r = forall (a :: * -> * -> *) t b.
(IsSymbExpr a, Show t, Ord t) =>
a t b -> SymbExpr t b
IF.toSymb (BNF t a
l forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t b
**> BNF t b
p forall t a b. (Show t, Ord t) => BNF t a -> BNF t b -> BNF t a
<** BNF t c
r)
parens :: BNF t b -> BNF t b
parens BNF t b
p = forall t a b c.
(Show t, Ord t) =>
BNF t a -> BNF t b -> BNF t c -> BNF t b
within (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
'(') BNF t b
p (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
')')
braces :: BNF t b -> BNF t b
braces BNF t b
p = forall t a b c.
(Show t, Ord t) =>
BNF t a -> BNF t b -> BNF t c -> BNF t b
within (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
'{') BNF t b
p (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
'}')
brackets :: BNF t b -> BNF t b
brackets BNF t b
p = forall t a b c.
(Show t, Ord t) =>
BNF t a -> BNF t b -> BNF t c -> BNF t b
within (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
'[') BNF t b
p (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
']')
angles :: BNF t b -> BNF t b
angles BNF t b
p = forall t a b c.
(Show t, Ord t) =>
BNF t a -> BNF t b -> BNF t c -> BNF t b
within (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
'<') BNF t b
p (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
'>')
quotes :: BNF t b -> BNF t b
quotes BNF t b
p = forall t a b c.
(Show t, Ord t) =>
BNF t a -> BNF t b -> BNF t c -> BNF t b
within (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
'\'') BNF t b
p (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
'\'')
dquotes :: BNF t b -> BNF t b
dquotes BNF t b
p = forall t a b c.
(Show t, Ord t) =>
BNF t a -> BNF t b -> BNF t c -> BNF t b
within (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
'"') BNF t b
p (forall t. SubsumesToken t => Char -> SymbExpr t Char
keychar Char
'"')