first steps towards PMCFG generation

This commit is contained in:
krangelov
2021-10-08 11:53:07 +02:00
parent e33d881ce8
commit 98f42051b1
14 changed files with 142 additions and 969 deletions

View File

@@ -7,38 +7,13 @@ module PGF2.Internal(-- * Access the internal structures
-- * Byte code
CodeLabel, Instr(..), IVal(..), TailInfo(..),
SeqId,LIndex,
FunId,Token,Production(..),PArg(..),Symbol(..),
unionPGF, writeConcr
) where
import PGF2.FFI
import PGF2.Expr
type Token = String
type LIndex = Int
data Symbol
= SymCat {-# UNPACK #-} !Int {-# UNPACK #-} !LIndex
| SymLit {-# UNPACK #-} !Int {-# UNPACK #-} !LIndex
| SymVar {-# UNPACK #-} !Int {-# UNPACK #-} !Int
| SymKS Token
| SymKP [Symbol] [([Symbol],[String])]
| SymBIND -- the special BIND token
| SymNE -- non exist
| SymSOFT_BIND -- the special SOFT_BIND token
| SymSOFT_SPACE -- the special SOFT_SPACE token
| SymCAPIT -- the special CAPIT token
| SymALL_CAPIT -- the special ALL_CAPIT token
deriving (Eq,Ord,Show)
data Production
= PApply {-# UNPACK #-} !FunId [PArg]
| PCoerce {-# UNPACK #-} !FId
deriving (Eq,Ord,Show)
type FunId = Int
type SeqId = Int
type FId = Int
data PArg = PArg [FId] {-# UNPACK #-} !FId deriving (Eq,Ord,Show)
fidString, fidInt, fidFloat, fidVar, fidStart :: FId
fidString = (-1)

View File

@@ -1,5 +1,7 @@
module PGF2.Transactions
( Transaction
-- abstract syntax
, modifyPGF
, branchPGF
, checkoutPGF
@@ -9,6 +11,9 @@ module PGF2.Transactions
, dropCategory
, setGlobalFlag
, setAbstractFlag
-- concrete syntax
, Token, LIndex, Symbol(..)
) where
import PGF2.FFI
@@ -144,3 +149,20 @@ setAbstractFlag name value = Transaction $ \c_db c_revision c_exn ->
bracket (newStablePtr value) freeStablePtr $ \c_value ->
withForeignPtr marshaller $ \m ->
pgf_set_abstract_flag c_db c_revision c_name c_value m c_exn
type Token = String
type LIndex = Int
data Symbol
= SymCat {-# UNPACK #-} !Int {-# UNPACK #-} !LIndex
| SymLit {-# UNPACK #-} !Int {-# UNPACK #-} !LIndex
| SymVar {-# UNPACK #-} !Int {-# UNPACK #-} !Int
| SymKS Token
| SymKP [Symbol] [([Symbol],[String])]
| SymBIND -- the special BIND token
| SymNE -- non exist
| SymSOFT_BIND -- the special SOFT_BIND token
| SymSOFT_SPACE -- the special SOFT_SPACE token
| SymCAPIT -- the special CAPIT token
| SymALL_CAPIT -- the special ALL_CAPIT token
deriving (Eq,Show)