gfse: added a new "matrix view" of grammars

This commit is contained in:
hallgren
2012-09-21 10:45:10 +00:00
parent 29e2e8c9a4
commit 620207802f
3 changed files with 80 additions and 5 deletions

View File

@@ -20,9 +20,9 @@ type Concrete = { langcode: Id,
params: [{name: Id, rhs: String}],
lincats : [{ cat: Cat, type: Term}],
opers: [{name: Lhs, rhs: Term}],
lins: [{fun: FunId, args: [Id], lin: Term}]
lins: [Lin]
}
type Lin = {fun: FunId, args: [Id], lin: Term}
type Lhs = String -- name and type of oper,
-- e.g "regN : Str -> { s:Str,g:Gender} ="
@@ -85,6 +85,13 @@ function cat_lincat(conc,cat) {
return null;
}
// Return the lin defined in a given concrete syntax for an abstract function
// cat_lincat :: Concrete -> FunId -> Lin
function fun_lin(conc,fun) {
with(conc) for(var i in lins) if(lins[i].fun==fun) return lins[i]
return null;
}
// Return the index of the concrete syntax with a given langcode
// conc_index :: Grammar -> Id -> Int
function conc_index(g,langcode) {