mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-09-28 05:03:39 -06:00
Merge branch 'majestic' of github.com:GrammaticalFramework/gf-core into majestic
This commit is contained in:
@@ -77,8 +77,8 @@ class PGF_INTERNAL_DECL interval_map {
|
||||
Node *upd_node(Node *node, Node *left, Node *right)
|
||||
{
|
||||
node->sz = 1+size(left)+size(right);
|
||||
node->max = std::max((left == NULL) ? node->end : left->max,
|
||||
(right == NULL) ? node->end : right->max);
|
||||
node->max = std::max<size_t>((left == NULL) ? node->end : left->max,
|
||||
(right == NULL) ? node->end : right->max);
|
||||
node->left = left;
|
||||
node->right = right;
|
||||
return node;
|
||||
|
||||
@@ -14,6 +14,8 @@ PgfAbstractParser::PgfAbstractParser(ref<PgfConcr> concr)
|
||||
this->last_fid = concr->last_fid;
|
||||
}
|
||||
|
||||
PgfAbstractParser::ItemProbComparator PgfAbstractParser::item_prob_comp;
|
||||
|
||||
void PgfAbstractParser::get_info(CCat *ccat, ref<PgfConcrRule> *prule, size_t **pvalues)
|
||||
{
|
||||
if (ccat->fid <= concr->last_fid) {
|
||||
@@ -514,7 +516,7 @@ void PgfAbstractParser::combine(State *state, Item *item, CCat *ccat)
|
||||
state->push_item(item);
|
||||
}
|
||||
|
||||
bool PgfAbstractParser::ItemComparator::operator()(Item *item1, Item *item2)
|
||||
bool PgfAbstractParser::ItemComparator::operator()(Item *item1, Item *item2) const
|
||||
{
|
||||
if (item1->rule.as_object() < item2->rule.as_object())
|
||||
return true;
|
||||
@@ -860,6 +862,8 @@ PgfParser::PgfParser(ref<PgfConcr> concr, PgfText *sentence, bool case_sensitive
|
||||
this->allocated_size = sizeof(PgfText)+sentence->size+1;
|
||||
}
|
||||
|
||||
PgfParser::ExprStateComparator PgfParser::estate_comp;
|
||||
|
||||
PgfParser::~PgfParser()
|
||||
{
|
||||
free(sentence);
|
||||
|
||||
@@ -132,7 +132,7 @@ protected:
|
||||
} item_prob_comp;
|
||||
|
||||
struct ItemComparator : std::less<Item*> {
|
||||
bool operator()(Item *item1, Item *item2);
|
||||
bool operator()(Item *item1, Item *item2) const;
|
||||
};
|
||||
|
||||
struct Cont {
|
||||
|
||||
@@ -1870,7 +1870,7 @@ public:
|
||||
this->sym_index = (size_t) -1;
|
||||
this->alt_index = (size_t) -1;
|
||||
this->n_lindefs = n_rules;
|
||||
this->n_linrefs = n_linrefs;
|
||||
this->n_linrefs = 0;
|
||||
this->n_args = 1;
|
||||
this->rule_index = 0;
|
||||
this->syms = 0;
|
||||
|
||||
@@ -154,7 +154,9 @@ PgfProbspace probspace_delete_by_cat(PgfProbspace space, PgfText *cat,
|
||||
|
||||
return Node<PgfProbspaceEntry>::link(space,space->left,right);
|
||||
} else {
|
||||
itor->fn(itor, &space->value.fun->name, space->value.fun.as_object(), err);
|
||||
PgfText *name = textdup(&space->value.fun->name);
|
||||
itor->fn(itor, name, space->value.fun.as_object(), err);
|
||||
free(name);
|
||||
if (err->type != PGF_EXN_NONE)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ PgfType PgfTypechecker::marshall_type(Type *ty, PgfUnmarshaller *u)
|
||||
for (;;) {
|
||||
Pi *pi = ty->is_pi();
|
||||
if (pi) {
|
||||
hypos = (PgfTypeHypo *) realloc(hypos, n_hypos*sizeof(PgfTypeHypo));
|
||||
hypos = (PgfTypeHypo *) realloc(hypos, (n_hypos+1)*sizeof(PgfTypeHypo));
|
||||
PgfTypeHypo *hypo = &hypos[n_hypos++];
|
||||
hypo->bind_type = pi->bind_type;
|
||||
hypo->cid = &pi->var;
|
||||
|
||||
Binary file not shown.
@@ -19,48 +19,40 @@ concrete basic_cnc {
|
||||
lincat Float = [
|
||||
"s"
|
||||
]
|
||||
lindef Float(0) -> Float[String(0)] = [S0]
|
||||
linref String(0) -> Float[Float(0)] = [S0]
|
||||
lindef Float(0) -> Float[String(0)]; 0 : <0,0>
|
||||
linref String(0) -> Float[Float(0)]; 0 : <0,0>
|
||||
lincat Int = [
|
||||
"s"
|
||||
]
|
||||
lindef Int(0) -> Int[String(0)] = [S0]
|
||||
linref String(0) -> Int[Int(0)] = [S0]
|
||||
lindef Int(0) -> Int[String(0)]; 0 : <0,0>
|
||||
linref String(0) -> Int[Int(0)]; 0 : <0,0>
|
||||
lincat N = [
|
||||
"s"
|
||||
]
|
||||
lindef N(0) -> N[String(0)] = [S0]
|
||||
linref {i<2} . String(0) -> N[N(i)] = [S0]
|
||||
lindef N(0) -> N[String(0)]; 0 : <0,0>
|
||||
linref {i<2} String(0) -> N[N(i)]; 0 : <0,0>
|
||||
lincat P = [
|
||||
"s"
|
||||
]
|
||||
lindef P(0) -> P[String(0)] = [S0]
|
||||
linref String(0) -> P[P(0)] = [S0]
|
||||
lindef P(0) -> P[String(0)]; 0 : <0,0>
|
||||
linref String(0) -> P[P(0)]; 0 : <0,0>
|
||||
lincat S = [
|
||||
""
|
||||
]
|
||||
lindef S(0) -> S[String(0)] = [S0]
|
||||
linref String(0) -> S[S(0)] = [S0]
|
||||
lindef S(0) -> S[String(0)]; 0 : <0,0>
|
||||
linref String(0) -> S[S(0)]; 0 : <0,0>
|
||||
lincat String = [
|
||||
"s"
|
||||
]
|
||||
lindef String(0) -> String[String(0)] = [S0]
|
||||
linref String(0) -> String[String(0)] = [S0]
|
||||
lin {i<2} . S(0) -> c[N(i)] = [S0]
|
||||
lin S(0) -> floatLit[Float(0)] = [S0]
|
||||
lin {i<2} . P(0) -> ind[P(0),P(0),N(i)] = [S1]
|
||||
lin S(0) -> intLit[Int(0)] = [S0]
|
||||
lin {i<2} . P(0) -> nat[N(i)] = [S5]
|
||||
lin N(0) -> s[N(0)] = [S2]
|
||||
lin N(0) -> s[N(1)] = [S4]
|
||||
lin S(0) -> stringLit[String(0)] = [S0]
|
||||
lin N(1) -> z[] = [S3]
|
||||
sequences {
|
||||
S0 = <0,0>
|
||||
S1 = <0,0> "&" "λ" SOFT_BIND <1,$0> SOFT_BIND "," SOFT_BIND <1,$1> "." <1,0>
|
||||
S2 = <0,0> "+" "1"
|
||||
S3 = "0"
|
||||
S4 = "1"
|
||||
S5 = "nat" SOFT_BIND "(" SOFT_BIND <0,0> SOFT_BIND ")"
|
||||
}
|
||||
lindef String(0) -> String[String(0)]; 0 : <0,0>
|
||||
linref String(0) -> String[String(0)]; 0 : <0,0>
|
||||
lin {i<2} S(0) -> c[N(i)]; 0 : <0,0>
|
||||
lin S(0) -> floatLit[Float(0)]; 0 : <0,0>
|
||||
lin {i<2} P(0) -> ind[P(0),P(0),N(i)]; 0 : <0,0> "&" "λ" SOFT_BIND <1,$0> SOFT_BIND "," SOFT_BIND <1,$1> "." <1,0>
|
||||
lin S(0) -> intLit[Int(0)]; 0 : <0,0>
|
||||
lin {i<2} P(0) -> nat[N(i)]; 0 : "nat" SOFT_BIND "(" SOFT_BIND <0,0> SOFT_BIND ")"
|
||||
lin N(0) -> s[N(1)]; 0 : "1"
|
||||
lin N(0) -> s[N(0)]; 0 : <0,0> "+" "1"
|
||||
lin S(0) -> stringLit[String(0)]; 0 : <0,0>
|
||||
lin N(1) -> z[]; 0 : "0"
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ main = do
|
||||
,TestCase (assertInference "infer literal 3" gr (Right "String") "\"abc\"")
|
||||
,TestCase (assertInference "infer meta 1" gr (Left "Cannot infer the type of a meta variable") "?")
|
||||
,TestCase (assertInference "infer meta 2" gr (Right "N->N") "<? : N->N>")
|
||||
,TestCase (assertInference "infer lambda" gr (Left "Cannot infer the type of a lambda abstraction") "\\x->x")
|
||||
,TestCase (assertInference "infer lambda" gr (Left "Cannot infer the type of a lambda variable") "\\x->x")
|
||||
,TestCase (assertChecking "check fun 1" gr (Right "s") "s" "N->N")
|
||||
,TestCase (assertChecking "check fun 2" gr (Right "s z") "s z" "N")
|
||||
,TestCase (assertChecking "check fun 3" gr (Left "Types doesn't match") "s z" "N->N")
|
||||
|
||||
@@ -15,7 +15,7 @@ if on_windows:
|
||||
cpath = '../c/pgf/'
|
||||
extra_sources = [cpath+f for f in os.listdir(cpath) if f.endswith('.cxx')]
|
||||
includes+=["../c"]
|
||||
flags = ['/DCOMPILING_STATIC_PGF=1']
|
||||
flags = ['/DCOMPILING_STATIC_PGF=1', "/std:c++20"]
|
||||
else:
|
||||
extra_sources = []
|
||||
flags = ['-std=c99', '-Werror', '-Wno-error=unused-variable', '-Wno-comment']
|
||||
|
||||
Reference in New Issue
Block a user