summaryrefslogtreecommitdiff
path: root/src/www/gfse/gf_abs.js
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-10-01 21:08:09 +0000
committerhallgren <hallgren@chalmers.se>2012-10-01 21:08:09 +0000
commit24f362ec00f176a7c1eaa91721be10acf0f09ed6 (patch)
tree245bb297f9fb0247f9b86b05c6b07c4f8afdc5b5 /src/www/gfse/gf_abs.js
parenta78220784155755b4734f2a847ab1186782cafff (diff)
gfse: adding a "row" view
Accessed by clicking on a function in the Abstract column in the matrix view.
Diffstat (limited to 'src/www/gfse/gf_abs.js')
-rw-r--r--src/www/gfse/gf_abs.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/www/gfse/gf_abs.js b/src/www/gfse/gf_abs.js
index 4ab02250b..69ca4d799 100644
--- a/src/www/gfse/gf_abs.js
+++ b/src/www/gfse/gf_abs.js
@@ -70,16 +70,23 @@ function all_inherited_funs(igs,df) {
return df;
}
-// Return the type of a named function in the abstract syntax
-// function_type :: Grammar -> FunId -> Type
-function function_type(g,fun) {
+// Return the index of the function the given name in the abstract syntax
+// find_function :: Grammar -> FunId -> (Int|null)
+function fun_index(g,fun) {
with(g.abstract)
- for(var i in funs) if(funs[i].name==fun) return funs[i].type
+ for(var i in funs) if(funs[i].name==fun) return i
return null;
}
+// Return the type of a named function in the abstract syntax
+// function_type :: Grammar -> FunId -> (Type|null)
+function function_type(g,fun) {
+ var ix=fun_index(g,fun)
+ return ix==null ? null : g.abstract.funs[ix].type
+}
+
// Return the lincat defined in a given concrete syntax for an abstract category
-// cat_lincat :: Concrete -> Cat -> Term
+// cat_lincat :: Concrete -> Cat -> (Term|null)
function cat_lincat(conc,cat) {
with(conc)
for(var i in lincats) if(lincats[i].cat==cat) return lincats[i].type
@@ -87,14 +94,14 @@ function cat_lincat(conc,cat) {
}
// Return the lin defined in a given concrete syntax for an abstract function
-// fun_lin :: Concrete -> FunId -> Lin
+// fun_lin :: Concrete -> FunId -> (Lin|null)
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
+// conc_index :: Grammar -> Id -> (Int|null)
function conc_index(g,langcode) {
var c=g.concretes;
for(var ix=0;ix<c.length;ix++)