summaryrefslogtreecommitdiff
path: root/src/runtime/c/pgf/data.h
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2013-02-11 13:51:12 +0000
committerkr.angelov <kr.angelov@gmail.com>2013-02-11 13:51:12 +0000
commit90c3304147e3829b9ea7f73085e54d9d0811ca8b (patch)
tree940fa49074899dcd6bbcc6da483671d56e52f968 /src/runtime/c/pgf/data.h
parent10ef298fa00bd100bc854c5c8570a550f470dde4 (diff)
remove the pgf2yaml tool which was both broken and redundant. The declarations for generic programming from data.c are removed as well
Diffstat (limited to 'src/runtime/c/pgf/data.h')
-rw-r--r--src/runtime/c/pgf/data.h349
1 files changed, 132 insertions, 217 deletions
diff --git a/src/runtime/c/pgf/data.h b/src/runtime/c/pgf/data.h
index 8c3919b8d..a726519a1 100644
--- a/src/runtime/c/pgf/data.h
+++ b/src/runtime/c/pgf/data.h
@@ -1,22 +1,3 @@
-/*
- * Copyright 2010 University of Helsinki.
- *
- * This file is part of libpgf.
- *
- * Libpgf is free software: you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or (at your
- * option) any later version.
- *
- * Libpgf is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with libpgf. If not, see <http://www.gnu.org/licenses/>.
- */
-
#ifndef PGF_DATA_H_
#define PGF_DATA_H_
@@ -29,112 +10,79 @@
#include <pgf/pgf.h>
typedef struct PgfCCat PgfCCat;
-typedef PgfCCat* PgfCCatId;
-extern GU_DECLARE_TYPE(PgfCCat, struct);
-extern GU_DECLARE_TYPE(PgfCCatId, shared);
-typedef GuList(PgfCCatId) PgfCCatIds;
-extern GU_DECLARE_TYPE(PgfCCatIds, GuList);
-typedef GuSeq PgfCCatSeq;
-extern GU_DECLARE_TYPE(PgfCCatSeq, GuSeq);
-
-typedef struct PgfAbstr PgfAbstr;
-extern GU_DECLARE_TYPE(PgfAbstr, struct);
-
-typedef struct PgfFunDecl PgfFunDecl;
-
-typedef int PgfLength;
-typedef struct GuVariant PgfSymbol;
-typedef struct PgfAlternative PgfAlternative;
-typedef struct PgfCncFun PgfCncFun;
-
+extern GU_DECLARE_TYPE(PgfCCat, abstract);
-typedef GuSeq PgfSequence; // -> PgfSymbol
+typedef GuList(PgfCCat*) PgfCCats;
-typedef PgfCncFun* PgfFunId; // key to PgfCncFuns
-extern GU_DECLARE_TYPE(PgfFunId, shared);
-typedef GuList(PgfCncFun*) PgfCncFuns;
-extern GU_DECLARE_TYPE(PgfCncFuns, GuList);
-typedef GuList(PgfFunId) PgfFunIds;
-extern GU_DECLARE_TYPE(PgfFunIds, GuList);
-// typedef GuStringMap PgfCIdMap; // PgfCId -> ?
#define PgfCIdMap GuStringMap
typedef PgfCIdMap PgfFlags; // PgfCId -> PgfLiteral
extern GU_DECLARE_TYPE(PgfFlags, GuMap);
-extern GU_DECLARE_TYPE(PgfType, struct);
-typedef GuVariant PgfProduction;
-typedef GuList(PgfProduction) PgfProductions;
-extern GU_DECLARE_TYPE(PgfProductions, GuList);
-typedef GuSeq PgfProductionSeq;
-extern GU_DECLARE_TYPE(PgfProductionSeq, GuSeq);
+// PgfPatt
-typedef struct PgfCatFun PgfCatFun;
-typedef struct PgfCncCat PgfCncCat;
-extern GU_DECLARE_TYPE(PgfCncCat, struct);
typedef GuVariant PgfPatt;
-typedef GuList(GuString) GuStringL;
-extern GU_DECLARE_TYPE(GuStringL, GuList);
-typedef GuSeq PgfTokens; // -> PgfToken
-extern GU_DECLARE_TYPE(PgfTokens, GuSeq);
-
-bool
-pgf_tokens_equal(PgfTokens t1, PgfTokens t2);
-
-
-
-typedef PgfExpr PgfTree;
-
-typedef struct PgfEquation PgfEquation;
-typedef GuSeq PgfEquations;
-typedef PgfEquations PgfEquationsM; // can be null
-extern GU_DECLARE_TYPE(PgfEquationsM, GuSeq);
-
-typedef struct PgfCat PgfCat;
-extern GU_DECLARE_TYPE(PgfCat, struct);
-
-typedef PgfSequence PgfSeqId; // shared reference
+typedef enum {
+ PGF_PATT_APP,
+ PGF_PATT_VAR,
+ PGF_PATT_AS,
+ PGF_PATT_WILD,
+ PGF_PATT_LIT,
+ PGF_PATT_IMPL_ARG,
+ PGF_PATT_TILDE,
+ PGF_PATT_NUM_TAGS
+} PgfPattTag;
-extern GU_DECLARE_TYPE(PgfSeqId, typedef);
+typedef struct {
+ PgfCId ctor;
+ GuLength n_args;
+ PgfPatt args[];
+} PgfPattApp;
-typedef GuList(PgfSequence) PgfSequences;
+typedef struct {
+ PgfLiteral lit;
+} PgfPattLit;
-extern GU_DECLARE_TYPE(PgfSequences, GuList);
+typedef struct {
+ PgfCId var;
+} PgfPattVar;
+typedef struct {
+ PgfCId var;
+ PgfPatt patt;
+} PgfPattAs;
+typedef void PgfPattWild;
+typedef struct {
+ PgfPatt patt;
+} PgfPattImplArg;
-struct PgfAbstr {
- PgfFlags* aflags;
- PgfCIdMap* funs; // |-> PgfFunDecl*
- PgfCIdMap* cats; // |-> PgfCat*
-};
+typedef struct {
+ PgfExpr expr;
+} PgfPattTilde;
-struct PgfPGF {
- uint16_t major_version;
- uint16_t minor_version;
- PgfFlags* gflags;
- PgfCId absname;
- PgfAbstr abstract;
- PgfCIdMap* concretes; // |-> PgfConcr*
- GuPool* pool;
-};
+typedef struct {
+ PgfExpr body;
+ GuLength n_patts;
+ PgfPatt patts[];
+} PgfEquation;
-extern GU_DECLARE_TYPE(PgfPGF, struct);
+typedef GuSeq PgfEquations;
-struct PgfFunDecl {
+typedef struct {
PgfType* type;
int arity;
- PgfEquationsM defns; // maybe null
+ PgfEquations defns; // maybe null
PgfExprProb ep;
-};
+} PgfAbsFun;
-extern GU_DECLARE_TYPE(PgfFunDecl, struct);
+extern GU_DECLARE_TYPE(PgfAbsFun, abstract);
typedef GuMap PgfMetaChildMap;
extern GU_DECLARE_TYPE(PgfMetaChildMap, GuMap);
-struct PgfCat {
+typedef struct {
PgfCId name;
PgfHypos context;
@@ -143,12 +91,29 @@ struct PgfCat {
PgfMetaChildMap* meta_child_probs;
GuBuf* functions; // -->PgfFunDecl
-};
+} PgfAbsCat;
+
+extern GU_DECLARE_TYPE(PgfAbsCat, abstract);
+
+typedef struct {
+ PgfFlags* aflags;
+ PgfCIdMap* funs; // |-> PgfAbsFun*
+ PgfCIdMap* cats; // |-> PgfAbsCat*
+} PgfAbstr;
+struct PgfPGF {
+ uint16_t major_version;
+ uint16_t minor_version;
+ PgfFlags* gflags;
+ PgfCId absname;
+ PgfAbstr abstract;
+ PgfCIdMap* concretes; // |-> PgfConcr*
+ GuPool* pool;
+};
-struct PgfCncCat {
- PgfCat *abscat;
- PgfCCatIds* cats;
+typedef struct {
+ PgfAbsCat *abscat;
+ PgfCCats* cats;
size_t n_lins;
GuString labels[];
@@ -158,39 +123,28 @@ struct PgfCncCat {
* field holds the labels that indicate which GF field or
* parameter (or their combination) each tuple element
* represents. */
-};
+} PgfCncCat;
-struct PgfCncFun {
- PgfCId name;
- PgfExprProb *ep;
- int funid;
- GuLength n_lins;
- PgfSeqId lins[];
-};
+extern GU_DECLARE_TYPE(PgfCncCat, abstract);
+
+typedef GuSeq PgfTokens; // -> PgfToken
+
+bool
+pgf_tokens_equal(PgfTokens t1, PgfTokens t2);
-struct PgfAlternative {
+typedef GuList(GuString) GuStringL;
+
+typedef struct {
PgfTokens form;
/**< The form of this variant as a list of tokens. */
GuStringL* prefixes;
/**< The prefixes of the following symbol that trigger this
* form. */
-};
+} PgfAlternative;
typedef struct PgfItemConts PgfItemConts;
-struct PgfCCat {
- PgfCncCat* cnccat;
- PgfFunIds* lindefs;
- size_t n_synprods;
- PgfProductionSeq prods;
- float viterbi_prob;
- int fid;
- PgfItemConts* conts;
-};
-
-extern PgfCCat pgf_ccat_string, pgf_ccat_int, pgf_ccat_float, pgf_ccat_var;
-
typedef PgfCIdMap PgfPrintNames;
extern GU_DECLARE_TYPE(PgfPrintNames, GuStringMap);
@@ -209,36 +163,17 @@ extern GU_DECLARE_TYPE(PgfLeftcornerCatIdx, GuMap);
typedef GuMap PgfLeftcornerTokIdx;
extern GU_DECLARE_TYPE(PgfLeftcornerTokIdx, GuMap);
-typedef struct PgfLiteralCallback PgfLiteralCallback;
-extern GU_DECLARE_TYPE(PgfLiteralCallback, struct);
-
typedef struct PgfItem PgfItem;
-struct PgfLiteralCallback {
+typedef struct {
bool (*match)(PgfConcr* concr, PgfItem* item, PgfToken tok,
PgfExprProb** out_ep, GuPool *pool);
-};
+} PgfLiteralCallback;
typedef GuMap PgfCallbacksMap;
extern GU_DECLARE_TYPE(PgfCallbacksMap, GuMap);
-struct PgfConcr {
- PgfFlags* cflags;
- PgfPrintNames* printnames;
- GuMap* ccats;
- PgfCncFunOverloadMap* fun_indices;
- PgfCncOverloadMap* coerce_idx;
- PgfProductionIdx* epsilon_idx;
- PgfLeftcornerCatIdx* leftcorner_cat_idx;
- PgfLeftcornerTokIdx* leftcorner_tok_idx;
- PgfCncFuns* cncfuns;
- PgfSequences* sequences;
- PgfCIdMap* cnccats;
- PgfCallbacksMap* callbacks;
- int total_cats;
-};
-
-extern GU_DECLARE_TYPE(PgfConcr, struct);
+typedef struct GuVariant PgfSymbol;
typedef enum {
PGF_SYMBOL_CAT,
@@ -248,12 +183,10 @@ typedef enum {
PGF_SYMBOL_KP
} PgfSymbolTag;
-typedef struct PgfSymbolIdx PgfSymbolIdx;
-
-struct PgfSymbolIdx {
+typedef struct {
int d;
int r;
-};
+} PgfSymbolIdx;
typedef PgfSymbolIdx PgfSymbolCat, PgfSymbolLit, PgfSymbolVar;
@@ -276,10 +209,42 @@ typedef struct PgfSymbolKP
} PgfSymbolKP;
+typedef GuSeq PgfSequence; // -> PgfSymbol
+typedef GuList(PgfSequence) PgfSequences;
+
+typedef struct {
+ PgfCId name;
+ PgfExprProb *ep;
+ int funid;
+ GuLength n_lins;
+ PgfSequence lins[];
+} PgfCncFun;
+
+typedef GuList(PgfCncFun*) PgfCncFuns;
+
+struct PgfConcr {
+ PgfFlags* cflags;
+ PgfPrintNames* printnames;
+ GuMap* ccats;
+ PgfCncFunOverloadMap* fun_indices;
+ PgfCncOverloadMap* coerce_idx;
+ PgfProductionIdx* epsilon_idx;
+ PgfLeftcornerCatIdx* leftcorner_cat_idx;
+ PgfLeftcornerTokIdx* leftcorner_tok_idx;
+ PgfCncFuns* cncfuns;
+ PgfSequences* sequences;
+ PgfCIdMap* cnccats;
+ PgfCallbacksMap* callbacks;
+ int total_cats;
+};
+
+extern GU_DECLARE_TYPE(PgfConcr, abstract);
// PgfProduction
+typedef GuVariant PgfProduction;
+
typedef enum {
PGF_PRODUCTION_APPLY,
PGF_PRODUCTION_COERCE,
@@ -287,21 +252,15 @@ typedef enum {
PGF_PRODUCTION_META
} PgfProductionTag;
-typedef struct PgfPArg PgfPArg;
-
-struct PgfPArg {
- PgfCCatId ccat;
- PgfCCatIds* hypos;
-};
-
-extern GU_DECLARE_TYPE(PgfPArg, struct);
+typedef struct {
+ PgfCCat* ccat;
+ PgfCCats* hypos;
+} PgfPArg;
typedef GuSeq PgfPArgs;
-extern GU_DECLARE_TYPE(PgfPArgs, GuSeq);
-
typedef struct {
- PgfFunId fun;
+ PgfCncFun* fun;
PgfPArgs args;
} PgfProductionApply;
@@ -310,7 +269,7 @@ typedef struct PgfProductionCoerce
* another FId. This allows common subsets of productions to be
* shared. */
{
- PgfCCatId coerce;
+ PgfCCat* coerce;
} PgfProductionCoerce;
typedef struct {
@@ -324,61 +283,17 @@ typedef struct {
PgfPArgs args;
} PgfProductionMeta;
-extern GU_DECLARE_TYPE(PgfPatt, GuVariant);
-
-extern GU_DECLARE_TYPE(PgfProduction, GuVariant);
-extern GU_DECLARE_TYPE(PgfBindType, enum);
-extern GU_DECLARE_TYPE(PgfLiteral, GuVariant);
-
-
-// PgfPatt
-
-typedef enum {
- PGF_PATT_APP,
- PGF_PATT_VAR,
- PGF_PATT_AS,
- PGF_PATT_WILD,
- PGF_PATT_LIT,
- PGF_PATT_IMPL_ARG,
- PGF_PATT_TILDE,
- PGF_PATT_NUM_TAGS
-} PgfPattTag;
-
-typedef struct {
- PgfCId ctor;
- GuLength n_args;
- PgfPatt args[];
-} PgfPattApp;
-
-typedef struct {
- PgfLiteral lit;
-} PgfPattLit;
-
-typedef struct {
- PgfCId var;
-} PgfPattVar;
-
-typedef struct {
- PgfCId var;
- PgfPatt patt;
-} PgfPattAs;
-
-typedef void PgfPattWild;
-
-typedef struct {
- PgfPatt patt;
-} PgfPattImplArg;
-
-typedef struct {
- PgfExpr expr;
-} PgfPattTilde;
+typedef GuSeq PgfProductionSeq;
+extern GU_DECLARE_TYPE(PgfProductionSeq, GuSeq);
-struct PgfEquation {
- PgfExpr body;
- GuLength n_patts;
- PgfPatt patts[];
+struct PgfCCat {
+ PgfCncCat* cnccat;
+ PgfCncFuns* lindefs;
+ size_t n_synprods;
+ PgfProductionSeq prods;
+ float viterbi_prob;
+ int fid;
+ PgfItemConts* conts;
};
-
-
-#endif /* PGF_PRIVATE_H_ */
+#endif