Safe Haskell | None |
---|---|
Language | Haskell2010 |
GF
Description
GF, the Grammatical Framework, as a library
Synopsis
- main :: IO ()
- getOptions :: IO (Options, [FilePath])
- mainOpts :: Options -> [FilePath] -> IO ()
- mainGFI :: Options -> [FilePath] -> IO ()
- mainRunGFI :: Options -> [FilePath] -> IO ()
- mainServerGFI :: Options -> Int -> [FilePath] -> IO Server
- mainGFC :: Options -> [FilePath] -> IO ()
- linkGrammars :: Options -> (UTCTime, [(ModuleName, Grammar)]) -> IO ()
- writePGF :: Options -> PGF -> IOE ()
- writeOutputs :: Options -> PGF -> IOE ()
- compileToPGF :: Options -> [FilePath] -> IOE PGF
- link :: Options -> (ModuleName, Grammar) -> IOE PGF
- batchCompile :: Options -> [FilePath] -> IOE (UTCTime, (ModuleName, Grammar))
- srcAbsName :: Grammar -> ModuleName -> ModuleName
- parallelBatchCompile :: Maybe Int -> Options -> [FilePath] -> IO (UTCTime, [(ModuleName, Grammar)])
- exportPGF :: Options -> OutputFormat -> PGF -> [(FilePath, String)]
- type OneOutput = (Maybe FullPath, CompiledModule)
- type CompiledModule = Module
- compileOne :: (Output m, ErrorMonad m, MonadIO m, MonadFail m) => Options -> Grammar -> FullPath -> m OneOutput
- reuseGFO :: (Output m, ErrorMonad m, MonadIO m, MonadFail m) => Options -> Grammar -> FullPath -> m OneOutput
- useTheSource :: (Output m, ErrorMonad m, MonadIO m, MonadFail m) => Options -> Grammar -> FullPath -> m OneOutput
- getSourceModule :: (MonadIO m, ErrorMonad m) => Options -> FilePath -> m (ModuleName, ModuleInfo)
- getBNFCRules :: Options -> FilePath -> IOE [BNFCRule]
- getEBNFRules :: Options -> FilePath -> IOE [ERule]
- data Grammar
- data ModuleName
- type Module = (ModuleName, ModuleInfo)
- data ModuleInfo = ModInfo {
- mtype :: ModuleType
- mstatus :: ModuleStatus
- mflags :: Options
- mextend :: [(ModuleName, MInclude)]
- mwith :: Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)])
- mopens :: [OpenSpec]
- mexdeps :: [ModuleName]
- msrc :: FilePath
- mseqs :: Maybe (Array SeqId Sequence)
- jments :: Map Ident Info
- type SourceGrammar = Grammar
- type SourceModInfo = ModuleInfo
- type SourceModule = Module
- data ModuleType
- emptyGrammar :: Grammar
- mGrammar :: [Module] -> Grammar
- modules :: Grammar -> [Module]
- prependModule :: Grammar -> Module -> Grammar
- moduleMap :: Grammar -> Map ModuleName ModuleInfo
- data MInclude
- data OpenSpec
- extends :: ModuleInfo -> [ModuleName]
- isInherited :: MInclude -> Ident -> Bool
- inheritAll :: ModuleName -> (ModuleName, MInclude)
- openedModule :: OpenSpec -> ModuleName
- allDepsModule :: Grammar -> ModuleInfo -> [OpenSpec]
- partOfGrammar :: Grammar -> Module -> Grammar
- depPathModule :: ModuleInfo -> [OpenSpec]
- allExtends :: Grammar -> ModuleName -> [Module]
- allExtendsPlus :: Grammar -> ModuleName -> [ModuleName]
- lookupModule :: ErrorMonad m => Grammar -> ModuleName -> m ModuleInfo
- isModAbs :: ModuleInfo -> Bool
- isModRes :: ModuleInfo -> Bool
- isModCnc :: ModuleInfo -> Bool
- sameMType :: ModuleType -> ModuleType -> Bool
- isCompilableModule :: ModuleInfo -> Bool
- isCompleteModule :: ModuleInfo -> Bool
- allAbstracts :: Grammar -> [ModuleName]
- greatestAbstract :: Grammar -> Maybe ModuleName
- allResources :: Grammar -> [ModuleName]
- greatestResource :: Grammar -> Maybe ModuleName
- allConcretes :: Grammar -> ModuleName -> [ModuleName]
- allConcreteModules :: Grammar -> [ModuleName]
- abstractOfConcrete :: ErrorMonad m => Grammar -> ModuleName -> m ModuleName
- data ModuleStatus
- data Info
- = AbsCat (Maybe (L Context))
- | AbsFun (Maybe (L Type)) (Maybe Int) (Maybe [L Equation]) (Maybe Bool)
- | ResParam (Maybe (L [Param])) (Maybe [Term])
- | ResValue (L Type)
- | ResOper (Maybe (L Type)) (Maybe (L Term))
- | ResOverload [ModuleName] [(L Type, L Term)]
- | CncCat (Maybe (L Type)) (Maybe (L Term)) (Maybe (L Term)) (Maybe (L Term)) (Maybe PMCFG)
- | CncFun (Maybe (Ident, Context, Type)) (Maybe (L Term)) (Maybe (L Term)) (Maybe PMCFG)
- | AnyInd Bool ModuleName
- data Term
- = Vr Ident
- | Cn Ident
- | Con Ident
- | Sort Ident
- | EInt Int
- | EFloat Double
- | K String
- | Empty
- | App Term Term
- | Abs BindType Ident Term
- | Meta !MetaId
- | ImplArg Term
- | Prod BindType Ident Term Term
- | Typed Term Term
- | Example Term String
- | RecType [Labelling]
- | R [Assign]
- | P Term Label
- | ExtR Term Term
- | Table Term Term
- | T TInfo [Case]
- | V Type [Term]
- | S Term Term
- | Let LocalDef Term
- | Q QIdent
- | QC QIdent
- | C Term Term
- | Glue Term Term
- | EPatt Patt
- | EPattType Term
- | ELincat Ident Term
- | ELin Ident Term
- | AdHocOverload [Term]
- | FV [Term]
- | Alts Term [(Term, Term)]
- | Strs [Term]
- | Error String
- type Type = Term
- type Cat = QIdent
- type Fun = QIdent
- type QIdent = (ModuleName, Ident)
- data BindType
- data Patt
- data TInfo
- data Label
- type MetaId = Int
- type Hypo = (BindType, Ident, Term)
- type Context = [Hypo]
- type Equation = ([Patt], Term)
- type Labelling = (Label, Type)
- type Assign = (Label, (Maybe Type, Term))
- type Case = (Patt, Term)
- type LocalDef = (Ident, (Maybe Type, Term))
- type Param = (Ident, Context)
- type Altern = (Term, [(Term, Term)])
- type Substitution = [(Ident, Term)]
- varLabel :: Int -> Label
- tupleLabel :: Int -> Label
- linLabel :: Int -> Label
- theLinLabel :: Label
- ident2label :: Ident -> Label
- label2ident :: Label -> Ident
- data Location
- data L a = L Location a
- unLoc :: L a -> a
- noLoc :: a -> L a
- ppLocation :: FilePath -> Location -> Doc
- ppL :: (Pretty a1, Pretty a3) => L a3 -> a1 -> Doc
- data PMCFG = PMCFG [Production] (Array FunId (UArray LIndex SeqId))
- data Production = Production !FId !FunId [[FId]]
- type FId = Int
- type FunId = Int
- type SeqId = Int
- type LIndex = Int
- type Sequence = Array DotPos Symbol
- typeForm :: Type -> (Context, Cat, [Term])
- typeFormCnc :: Type -> (Context, Type)
- valCat :: Type -> Cat
- valType :: Type -> Type
- valTypeCnc :: Type -> Type
- typeSkeleton :: Type -> ([(Int, Cat)], Cat)
- catSkeleton :: Type -> ([Cat], Cat)
- funsToAndFrom :: Type -> (Cat, [(Cat, [Int])])
- isRecursiveType :: Type -> Bool
- isHigherOrderType :: Type -> Bool
- contextOfType :: Monad m => Type -> m Context
- termForm :: Monad m => Term -> m ([(BindType, Ident)], Term, [Term])
- termFormCnc :: Term -> ([(BindType, Ident)], Term)
- appForm :: Term -> (Term, [Term])
- mkProdSimple :: Context -> Term -> Term
- mkProd :: Context -> Term -> [Term] -> Term
- mkTerm :: ([(BindType, Ident)], Term, [Term]) -> Term
- mkApp :: Term -> [Term] -> Term
- mkAbs :: [(BindType, Ident)] -> Term -> Term
- appCons :: Ident -> [Term] -> Term
- mkLet :: [LocalDef] -> Term -> Term
- mkLetUntyped :: Context -> Term -> Term
- isVariable :: Term -> Bool
- uType :: Type
- assign :: Label -> Term -> Assign
- assignT :: Label -> Type -> Term -> Assign
- unzipR :: [Assign] -> ([Label], [Term])
- mkAssign :: [(Label, Term)] -> [Assign]
- projectRec :: Label -> [Assign] -> Term
- zipAssign :: [Label] -> [Term] -> [Assign]
- mapAssignM :: Monad m => (Term -> m c) -> [Assign] -> m [(Label, (Maybe c, c))]
- mkRecordN :: Int -> (Int -> Label) -> [Term] -> Term
- mkRecord :: (Int -> Label) -> [Term] -> Term
- mkRecTypeN :: Int -> (Int -> Label) -> [Type] -> Type
- mkRecType :: (Int -> Label) -> [Type] -> Type
- record2subst :: Term -> Err Substitution
- typeType :: Type
- typePType :: Type
- typeStr :: Type
- typeTok :: Type
- typeStrs :: Type
- typeString :: Type
- typeFloat :: Type
- typeInt :: Type
- typeInts :: Int -> Type
- typePBool :: Type
- typeError :: Type
- isTypeInts :: Type -> Maybe Int
- isPredefConstant :: Term -> Bool
- checkPredefError :: MonadFail m => Term -> m Term
- cnPredef :: Ident -> Term
- mkSelects :: Term -> [Term] -> Term
- mkTable :: [Term] -> Term -> Term
- mkCTable :: [(BindType, Ident)] -> Term -> Term
- mkHypo :: Term -> Hypo
- eqStrIdent :: Ident -> Ident -> Bool
- tuple2record :: [Term] -> [Assign]
- tuple2recordType :: [Term] -> [Labelling]
- tuple2recordPatt :: [Patt] -> [(Label, Patt)]
- mkCases :: Ident -> Term -> Term
- mkWildCases :: Term -> Term
- mkFunType :: [Type] -> Type -> Type
- plusRecType :: ErrorMonad m => Term -> Term -> m Term
- plusRecord :: ErrorMonad m => Term -> Term -> m Term
- defLinType :: Type
- mkFreshVar :: [Ident] -> Ident
- mkFreshVarX :: [Ident] -> Ident -> Ident
- maxVarIndex :: [Ident] -> Int
- mkFreshVars :: Int -> [Ident] -> [Ident]
- freshAsTerm :: String -> Term
- string2term :: String -> Term
- int2term :: Int -> Term
- float2term :: Double -> Term
- ident2terminal :: Ident -> Term
- symbolOfIdent :: Ident -> String
- symid :: Ident -> String
- justIdentOf :: Term -> Maybe Ident
- linTypeStr :: Type
- linAsStr :: String -> Term
- term2patt :: Term -> Err Patt
- patt2term :: Patt -> Term
- composSafeOp :: (Term -> Term) -> Term -> Term
- composOp :: Monad m => (Term -> m Term) -> Term -> m Term
- composSafePattOp :: (Patt -> Patt) -> Patt -> Patt
- composPattOp :: Monad m => (Patt -> m Patt) -> Patt -> m Patt
- collectOp :: Monoid m => (Term -> m) -> Term -> m
- mconcatMap :: Monoid c => (a -> c) -> [a] -> c
- collectPattOp :: (Patt -> [a]) -> Patt -> [a]
- redirectTerm :: ModuleName -> Term -> Term
- allCaseValues :: Term -> [([Patt], Term)]
- strsFromTerm :: Term -> Err [Str]
- getTableType :: TInfo -> Err Type
- changeTableType :: Monad m => (Type -> m Type) -> TInfo -> m TInfo
- wordsInTerm :: Term -> [String]
- noExist :: Term
- defaultLinType :: Type
- sortRec :: [(Label, a)] -> [(Label, a)]
- allDependencies :: (ModuleName -> Bool) -> Map Ident Info -> [(Ident, [Ident])]
- topoSortJments :: ErrorMonad m => SourceModule -> m [(Ident, Info)]
- topoSortJments2 :: ErrorMonad m => SourceModule -> m [[(Ident, Info)]]
- data TermPrintQual
- ppModule :: TermPrintQual -> SourceModule -> Doc
- ppJudgement :: Pretty a2 => TermPrintQual -> (a2, Info) -> Doc
- ppParams :: Pretty a1 => TermPrintQual -> [(a1, [(a, Ident, Term)])] -> Doc
- ppTerm :: (Ord t, Num t) => TermPrintQual -> t -> Term -> Doc
- ppPatt :: (Num a, Ord a) => TermPrintQual -> a -> Patt -> Doc
- ppValue :: TermPrintQual -> Int -> Val -> Doc
- ppConstrs :: Constraints -> [Doc]
- ppQIdent :: TermPrintQual -> QIdent -> Doc
- ppMeta :: MetaId -> Doc
- getAbs :: Term -> ([(BindType, Ident)], Term)
- newtype ModuleName = MN Ident
- moduleNameS :: String -> ModuleName
- data Ident
- ident2utf8 :: Ident -> ByteString
- showIdent :: Ident -> String
- prefixIdent :: String -> Ident -> Ident
- identS :: String -> Ident
- identC :: RawIdent -> Ident
- identW :: Ident
- identV :: RawIdent -> Int -> Ident
- identA :: RawIdent -> Int -> Ident
- identAV :: RawIdent -> Int -> Int -> Ident
- argIdent :: Int -> Ident -> Int -> Ident
- isArgIdent :: Ident -> Bool
- getArgIndex :: Ident -> Maybe Int
- varStr :: Ident
- varX :: Int -> Ident
- isWildIdent :: Ident -> Bool
- varIndex :: Ident -> Int
- data RawIdent
- rawIdentS :: String -> RawIdent
- rawIdentC :: ByteString -> RawIdent
- ident2raw :: Ident -> RawIdent
- prefixRawIdent :: RawIdent -> RawIdent -> RawIdent
- isPrefixOf :: RawIdent -> RawIdent -> Bool
- showRawIdent :: RawIdent -> String
- data VersionTagged a
- = Tagged {
- unV :: a
- | WrongVersion
- = Tagged {
- decodeModuleHeader :: MonadIO io => FilePath -> io (VersionTagged Module)
- decodeModule :: MonadIO io => FilePath -> io SourceModule
- encodeModule :: MonadIO io => FilePath -> SourceModule -> io ()
- grammar2canonical :: Options -> ModuleName -> Grammar -> Grammar
- abstract2canonical :: ModuleName -> Grammar -> Abstract
- concretes2canonical :: Options -> ModuleName -> Grammar -> [(FilePath, Concrete)]
- projection :: LinValue -> LabelId -> LinValue
- selection :: LinValue -> LinValue -> LinValue
Command line interface
Run the GF main program, taking arguments from the command line.
(It calls setConsoleEncoding
and getOptions
, then mainOpts
.)
Run gf --help
for usage info.
getOptions :: IO (Options, [FilePath]) Source #
Get and parse GF command line arguments. Fix relative paths.
Calls getArgs
and parseOptions
.
mainOpts :: Options -> [FilePath] -> IO () Source #
Run the GF main program with the given options and files. Depending on
the options it invokes mainGFC
, mainGFI
, mainRunGFI
, mainServerGFI
,
or it just prints version/usage info.
mainServerGFI :: Options -> Int -> [FilePath] -> IO Server Source #
Run the GF Server (gf -server
).
The Int
argument is the port number for the HTTP service.
mainGFC :: Options -> [FilePath] -> IO () Source #
Compile the given GF grammar files. The result is a number of .gfo
files
and, depending on the options, a .pgf
file. (gf -batch
, gf -make
)
linkGrammars :: Options -> (UTCTime, [(ModuleName, Grammar)]) -> IO () Source #
Create a .pgf
file (and possibly files in other formats, if specified
in the Options
) from the output of parallelBatchCompile
.
If a .pgf
file by the same name already exists and it is newer than the
source grammar files (as indicated by the UTCTime
argument), it is not
recreated. Calls writePGF
and writeOutputs
.
writePGF :: Options -> PGF -> IOE () Source #
Write the result of compiling a grammar (e.g. with compileToPGF
or
link
) to a .pgf
file.
A split PGF file is output if the -split-pgf
option is used.
writeOutputs :: Options -> PGF -> IOE () Source #
Export the PGF to the OutputFormat
s specified in the Options
.
Calls exportPGF
.
Compiling GF grammars
compileToPGF :: Options -> [FilePath] -> IOE PGF Source #
Compiles a number of source files and builds a PGF
structure for them.
This is a composition of link
and batchCompile
.
batchCompile :: Options -> [FilePath] -> IOE (UTCTime, (ModuleName, Grammar)) Source #
Compile the given grammar files and everything they depend on.
Compiled modules are stored in .gfo
files (unless the -tags
option is
used, in which case tags files are produced instead).
Existing .gfo
files are reused if they are up-to-date
(unless the option -src
aka -force-recomp
is used).
srcAbsName :: Grammar -> ModuleName -> ModuleName Source #
Returns the name of the abstract syntax corresponding to the named concrete syntax
parallelBatchCompile :: Maybe Int -> Options -> [FilePath] -> IO (UTCTime, [(ModuleName, Grammar)]) Source #
Compile the given grammar files and everything they depend on,
like batchCompile
. This function compiles modules in parallel.
It keeps modules compiled in present and alltenses mode apart,
storing the .gfo
files in separate subdirectories to avoid creating
the broken PGF files that can result from mixing different modes in the
same concrete syntax.
The first argument controls the number of jobs to run in
parallel. This works if GF was compiled with GHC>=7.6, otherwise you have to
use the GHC run-time flag +RTS -N -RTS
to enable parallelism.
Arguments
:: Options | |
-> OutputFormat | |
-> PGF | |
-> [(FilePath, String)] | List of recommended file names and contents. |
Export a PGF to the given OutputFormat
. For many output formats,
additional Options
can be used to control the output.
Compiling a single module
type CompiledModule = Module Source #
compileOne :: (Output m, ErrorMonad m, MonadIO m, MonadFail m) => Options -> Grammar -> FullPath -> m OneOutput Source #
Compile a given source file (or just load a .gfo file),
given a Grammar
containing everything it depends on.
Calls reuseGFO
or useTheSource
.
reuseGFO :: (Output m, ErrorMonad m, MonadIO m, MonadFail m) => Options -> Grammar -> FullPath -> m OneOutput Source #
Read a compiled GF module. Also undo common subexp optimization, to enable normal computations.
useTheSource :: (Output m, ErrorMonad m, MonadIO m, MonadFail m) => Options -> Grammar -> FullPath -> m OneOutput Source #
Compile GF module from source. It both returns the result and
stores it in a .gfo
file
(or a tags file, if running with the -tags
option)
Abstract syntax, parsing, pretty printing and serialisation
getSourceModule :: (MonadIO m, ErrorMonad m) => Options -> FilePath -> m (ModuleName, ModuleInfo) Source #
Read a source file and parse it (after applying preprocessors specified in the options)
Grammar modules
A grammar is a self-contained collection of grammar modules
data ModuleName Source #
Module names
Instances
Eq ModuleName Source # | |
Defined in GF.Infra.Ident | |
Ord ModuleName Source # | |
Defined in GF.Infra.Ident Methods compare :: ModuleName -> ModuleName -> Ordering # (<) :: ModuleName -> ModuleName -> Bool # (<=) :: ModuleName -> ModuleName -> Bool # (>) :: ModuleName -> ModuleName -> Bool # (>=) :: ModuleName -> ModuleName -> Bool # max :: ModuleName -> ModuleName -> ModuleName # min :: ModuleName -> ModuleName -> ModuleName # | |
Show ModuleName Source # | |
Defined in GF.Infra.Ident Methods showsPrec :: Int -> ModuleName -> ShowS # show :: ModuleName -> String # showList :: [ModuleName] -> ShowS # | |
Binary ModuleName Source # | |
Defined in GF.Grammar.Binary | |
Pretty ModuleName Source # | |
Defined in GF.Infra.Ident |
type Module = (ModuleName, ModuleInfo) Source #
Modules
data ModuleInfo Source #
Constructors
ModInfo | |
Fields
|
Instances
Binary ModuleInfo Source # | |
Defined in GF.Grammar.Binary | |
HasSourcePath ModuleInfo Source # | |
Defined in GF.Grammar.Grammar Methods sourcePath :: ModuleInfo -> FilePath Source # |
type SourceGrammar = Grammar Source #
type SourceModInfo = ModuleInfo Source #
type SourceModule = Module Source #
data ModuleType Source #
encoding the type of the module
Constructors
MTAbstract | |
MTResource | |
MTConcrete ModuleName | |
MTInterface | |
MTInstance (ModuleName, MInclude) |
Instances
Eq ModuleType Source # | |
Defined in GF.Grammar.Grammar | |
Show ModuleType Source # | |
Defined in GF.Grammar.Grammar Methods showsPrec :: Int -> ModuleType -> ShowS # show :: ModuleType -> String # showList :: [ModuleType] -> ShowS # | |
Binary ModuleType Source # | |
Defined in GF.Grammar.Binary |
moduleMap :: Grammar -> Map ModuleName ModuleInfo Source #
Constructors
OSimple ModuleName | |
OQualif ModuleName ModuleName |
extends :: ModuleInfo -> [ModuleName] Source #
inheritAll :: ModuleName -> (ModuleName, MInclude) Source #
openedModule :: OpenSpec -> ModuleName Source #
allDepsModule :: Grammar -> ModuleInfo -> [OpenSpec] Source #
all dependencies
partOfGrammar :: Grammar -> Module -> Grammar Source #
select just those modules that a given one depends on, including itself
depPathModule :: ModuleInfo -> [OpenSpec] Source #
initial dependency list
allExtends :: Grammar -> ModuleName -> [Module] Source #
all modules that a module extends, directly or indirectly, with restricts
allExtendsPlus :: Grammar -> ModuleName -> [ModuleName] Source #
the same as allExtends
plus that an instance extends its interface
lookupModule :: ErrorMonad m => Grammar -> ModuleName -> m ModuleInfo Source #
isModAbs :: ModuleInfo -> Bool Source #
isModRes :: ModuleInfo -> Bool Source #
isModCnc :: ModuleInfo -> Bool Source #
sameMType :: ModuleType -> ModuleType -> Bool Source #
isCompilableModule :: ModuleInfo -> Bool Source #
don't generate code for interfaces and for incomplete modules
isCompleteModule :: ModuleInfo -> Bool Source #
interface and "incomplete M" are not complete
allAbstracts :: Grammar -> [ModuleName] Source #
all abstract modules sorted from least to most dependent
greatestAbstract :: Grammar -> Maybe ModuleName Source #
the last abstract in dependency order (head of list)
allResources :: Grammar -> [ModuleName] Source #
all resource modules
greatestResource :: Grammar -> Maybe ModuleName Source #
the greatest resource in dependency order
allConcretes :: Grammar -> ModuleName -> [ModuleName] Source #
all concretes for a given abstract
allConcreteModules :: Grammar -> [ModuleName] Source #
all concrete modules for any abstract
abstractOfConcrete :: ErrorMonad m => Grammar -> ModuleName -> m ModuleName Source #
we store the module type with the identifier
data ModuleStatus Source #
Constructors
MSComplete | |
MSIncomplete |
Instances
Eq ModuleStatus Source # | |
Defined in GF.Grammar.Grammar | |
Ord ModuleStatus Source # | |
Defined in GF.Grammar.Grammar Methods compare :: ModuleStatus -> ModuleStatus -> Ordering # (<) :: ModuleStatus -> ModuleStatus -> Bool # (<=) :: ModuleStatus -> ModuleStatus -> Bool # (>) :: ModuleStatus -> ModuleStatus -> Bool # (>=) :: ModuleStatus -> ModuleStatus -> Bool # max :: ModuleStatus -> ModuleStatus -> ModuleStatus # min :: ModuleStatus -> ModuleStatus -> ModuleStatus # | |
Show ModuleStatus Source # | |
Defined in GF.Grammar.Grammar Methods showsPrec :: Int -> ModuleStatus -> ShowS # show :: ModuleStatus -> String # showList :: [ModuleStatus] -> ShowS # | |
Binary ModuleStatus Source # | |
Defined in GF.Grammar.Binary |
Judgements
the constructors are judgements in
- abstract syntax (ABS)
- resource (RES)
- concrete syntax (CNC)
and indirection to module (INDIR)
Constructors
AbsCat (Maybe (L Context)) | (ABS) context of a category |
AbsFun (Maybe (L Type)) (Maybe Int) (Maybe [L Equation]) (Maybe Bool) | (ABS) type, arrity and definition of a function |
ResParam (Maybe (L [Param])) (Maybe [Term]) | (RES) the second parameter is list of all possible values |
ResValue (L Type) | (RES) to mark parameter constructors for lookup |
ResOper (Maybe (L Type)) (Maybe (L Term)) | (RES) |
ResOverload [ModuleName] [(L Type, L Term)] | (RES) idents: modules inherited |
CncCat (Maybe (L Type)) (Maybe (L Term)) (Maybe (L Term)) (Maybe (L Term)) (Maybe PMCFG) | (CNC) lindef ini'zed, |
CncFun (Maybe (Ident, Context, Type)) (Maybe (L Term)) (Maybe (L Term)) (Maybe PMCFG) | (CNC) type info added at |
AnyInd Bool ModuleName | (INDIR) the |
Terms
Constructors
Vr Ident | variable |
Cn Ident | constant |
Con Ident | constructor |
Sort Ident | basic type |
EInt Int | integer literal |
EFloat Double | floating point literal |
K String | string literal or token: |
Empty | the empty string |
App Term Term | application: |
Abs BindType Ident Term | abstraction: |
Meta !MetaId | metavariable: |
ImplArg Term | placeholder for implicit argument |
Prod BindType Ident Term Term | function type: |
Typed Term Term | type-annotated term below this, the constructors are only for concrete syntax |
Example Term String | example-based term: @in M.C "foo" |
RecType [Labelling] | record type: |
R [Assign] | record: |
P Term Label | projection: |
ExtR Term Term | extension: |
Table Term Term | table type: |
T TInfo [Case] | table: |
V Type [Term] | table given as course of values: |
S Term Term | selection: |
Let LocalDef Term | local definition: |
Q QIdent | qualified constant from a package |
QC QIdent | qualified constructor from a package |
C Term Term | concatenation: |
Glue Term Term | agglutination: |
EPatt Patt | pattern (in macro definition): # p |
EPattType Term | pattern type: pattern T |
ELincat Ident Term | boxed linearization type of Ident |
ELin Ident Term | boxed linearization of type Ident |
AdHocOverload [Term] | ad hoc overloading generated in Rename |
FV [Term] | alternatives in free variation: |
Alts Term [(Term, Term)] | alternatives by prefix: |
Strs [Term] | conditioning prefix strings: |
Error String | error values returned by Predef.error |
type QIdent = (ModuleName, Ident) Source #
Patterns
Constructors
PC Ident [Patt] | constructor pattern: |
PP QIdent [Patt] | package constructor pattern: |
PV Ident | variable pattern: |
PW | wild card pattern: |
PR [(Label, Patt)] | record pattern: |
PString String | string literal pattern: |
PInt Int | integer literal pattern: |
PFloat Double | float literal pattern: |
PT Type Patt | type-annotated pattern |
PAs Ident Patt | as-pattern: x@p |
PImplArg Patt | placeholder for pattern for implicit argument |
PTilde Term | inaccessible pattern |
PNeg Patt | negated pattern: -p |
PAlt Patt Patt | disjunctive pattern: p1 | p2 |
PSeq Patt Patt | sequence of token parts: p + q |
PMSeq MPatt MPatt | sequence of token parts: p + q |
PRep Patt | repetition of token part: p* |
PChar | string of length one: ? |
PChars [Char] | character list: ["aeiou"] |
PMacro Ident | |
PM QIdent |
to guide computation and type checking of tables
Constructors
TRaw | received from parser; can be anything |
TTyped Type | type annontated, but can be anything |
TComp Type | expanded |
TWild Type | just one wild card pattern, no need to expand |
record label
type Substitution = [(Ident, Term)] Source #
tupleLabel :: Int -> Label Source #
theLinLabel :: Label Source #
ident2label :: Ident -> Label Source #
label2ident :: Label -> Ident Source #
Source locations
Attaching location information
PMCFG
data Production Source #
Constructors
Production !FId !FunId [[FId]] |
Instances
Eq Production Source # | |
Defined in GF.Grammar.Grammar | |
Ord Production Source # | |
Defined in GF.Grammar.Grammar Methods compare :: Production -> Production -> Ordering # (<) :: Production -> Production -> Bool # (<=) :: Production -> Production -> Bool # (>) :: Production -> Production -> Bool # (>=) :: Production -> Production -> Bool # max :: Production -> Production -> Production # min :: Production -> Production -> Production # | |
Show Production Source # | |
Defined in GF.Grammar.Grammar Methods showsPrec :: Int -> Production -> ShowS # show :: Production -> String # showList :: [Production] -> ShowS # | |
Binary Production Source # | |
Defined in GF.Grammar.Binary |
Functions for constructing and analysing source code terms.
valTypeCnc :: Type -> Type Source #
isRecursiveType :: Type -> Bool Source #
isHigherOrderType :: Type -> Bool Source #
isVariable :: Term -> Bool Source #
Assignment
Records
record2subst :: Term -> Err Substitution Source #
Types
typeString :: Type Source #
Terms
isPredefConstant :: Term -> Bool Source #
tuple2record :: [Term] -> [Assign] Source #
tuple2recordType :: [Term] -> [Labelling] Source #
mkWildCases :: Term -> Term Source #
plusRecType :: ErrorMonad m => Term -> Term -> m Term Source #
plusRecord :: ErrorMonad m => Term -> Term -> m Term Source #
defLinType :: Type Source #
default linearization type
mkFreshVar :: [Ident] -> Ident Source #
refreshing variables
maxVarIndex :: [Ident] -> Int Source #
freshAsTerm :: String -> Term Source #
quick hack for refining with var in editor
string2term :: String -> Term Source #
create a terminal for concrete syntax
float2term :: Double -> Term Source #
ident2terminal :: Ident -> Term Source #
create a terminal from identifier
symbolOfIdent :: Ident -> String Source #
linTypeStr :: Type Source #
Term and pattern conversion
Almost compositional
composOp :: Monad m => (Term -> m Term) -> Term -> m Term Source #
to define compositional term functions
mconcatMap :: Monoid c => (a -> c) -> [a] -> c Source #
collectPattOp :: (Patt -> [a]) -> Patt -> [a] Source #
Misc
redirectTerm :: ModuleName -> Term -> Term Source #
allCaseValues :: Term -> [([Patt], Term)] Source #
to gather ultimate cases in a table; preserves pattern list
strsFromTerm :: Term -> Err [Str] Source #
to get a string from a term that represents a sequence of terminals
wordsInTerm :: Term -> [String] Source #
to find the word items in a term
Dependencies
allDependencies :: (ModuleName -> Bool) -> Map Ident Info -> [(Ident, [Ident])] Source #
dependency check, detecting circularities and returning topo-sorted list
topoSortJments :: ErrorMonad m => SourceModule -> m [(Ident, Info)] Source #
topoSortJments2 :: ErrorMonad m => SourceModule -> m [[(Ident, Info)]] Source #
Pretty printing
data TermPrintQual Source #
Constructors
Terse | |
Unqualified | |
Qualified | |
Internal |
Instances
Eq TermPrintQual Source # | |
Defined in GF.Grammar.Printer Methods (==) :: TermPrintQual -> TermPrintQual -> Bool # (/=) :: TermPrintQual -> TermPrintQual -> Bool # |
ppModule :: TermPrintQual -> SourceModule -> Doc Source #
ppJudgement :: Pretty a2 => TermPrintQual -> (a2, Info) -> Doc Source #
Identifiers
newtype ModuleName Source #
Module names
Instances
Eq ModuleName Source # | |
Defined in GF.Infra.Ident | |
Ord ModuleName Source # | |
Defined in GF.Infra.Ident Methods compare :: ModuleName -> ModuleName -> Ordering # (<) :: ModuleName -> ModuleName -> Bool # (<=) :: ModuleName -> ModuleName -> Bool # (>) :: ModuleName -> ModuleName -> Bool # (>=) :: ModuleName -> ModuleName -> Bool # max :: ModuleName -> ModuleName -> ModuleName # min :: ModuleName -> ModuleName -> ModuleName # | |
Show ModuleName Source # | |
Defined in GF.Infra.Ident Methods showsPrec :: Int -> ModuleName -> ShowS # show :: ModuleName -> String # showList :: [ModuleName] -> ShowS # | |
Binary ModuleName Source # | |
Defined in GF.Grammar.Binary | |
Pretty ModuleName Source # | |
Defined in GF.Infra.Ident |
moduleNameS :: String -> ModuleName Source #
the constructors labelled INTERNAL are internal representation never returned by the parser
ident2utf8 :: Ident -> ByteString Source #
This function should be used with care, since the returned ByteString is UTF-8-encoded.
Normal identifiers (returned by the parser)
Special identifiers for internal use
isArgIdent :: Ident -> Bool Source #
isWildIdent :: Ident -> Bool Source #
Raw identifiers
Identifiers are stored as UTF-8-encoded bytestrings.
(It is also possible to use regular Haskell String
s, with somewhat
reduced performance and increased memory use.)
rawIdentC :: ByteString -> RawIdent Source #
showRawIdent :: RawIdent -> String Source #
Binary serialisation
data VersionTagged a Source #
Constructors
Tagged | |
Fields
| |
WrongVersion |
Instances
Functor VersionTagged Source # | |
Defined in GF.Grammar.Binary Methods fmap :: (a -> b) -> VersionTagged a -> VersionTagged b # (<$) :: a -> VersionTagged b -> VersionTagged a # | |
Binary a => Binary (VersionTagged a) Source # | |
Defined in GF.Grammar.Binary |
decodeModuleHeader :: MonadIO io => FilePath -> io (VersionTagged Module) Source #
Read just the module header, the returned Module
will have an empty body
decodeModule :: MonadIO io => FilePath -> io SourceModule Source #
encodeModule :: MonadIO io => FilePath -> SourceModule -> io () Source #
Canonical GF
grammar2canonical :: Options -> ModuleName -> Grammar -> Grammar Source #
Generate Canonical code for the named abstract syntax and all associated concrete syntaxes
abstract2canonical :: ModuleName -> Grammar -> Abstract Source #
Generate Canonical code for the named abstract syntax
concretes2canonical :: Options -> ModuleName -> Grammar -> [(FilePath, Concrete)] Source #
Generate Canonical code for the all concrete syntaxes associated with the named abstract syntax in given the grammar.