mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-24 02:12:50 -06:00
gfse: support for opening RGL modules
This commit is contained in:
@@ -164,7 +164,7 @@ function add_concrete(g,el) {
|
|||||||
list.push(li([a(jsurl("add_concrete2("+g.index+",'"+c+"')"),
|
list.push(li([a(jsurl("add_concrete2("+g.index+",'"+c+"')"),
|
||||||
[text(l.name)])]));
|
[text(l.name)])]));
|
||||||
}
|
}
|
||||||
file.appendChild(text("Pick a language for the new concrete syntax:"));
|
file.appendChild(p(text("Pick a language for the new concrete syntax:")));
|
||||||
file.appendChild(node("ul",{},list));
|
file.appendChild(node("ul",{},list));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,13 +276,6 @@ function add_cat(g,el) {
|
|||||||
string_editor(el,"",add);
|
string_editor(el,"",add);
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_ix(old,ix) {
|
|
||||||
var a=[];
|
|
||||||
// for(var i=0;i<old.length;i++) if(i!=ix) a.push(old[i]);
|
|
||||||
for(var i in old) if(i!=ix) a.push(old[i]);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete_cat(g,ix) {
|
function delete_cat(g,ix) {
|
||||||
with(g.abstract) cats=delete_ix(cats,ix);
|
with(g.abstract) cats=delete_ix(cats,ix);
|
||||||
reload_grammar(g);
|
reload_grammar(g);
|
||||||
@@ -315,7 +308,6 @@ function draw_cats(g) {
|
|||||||
return ifError(defined[cat],"Same category named twice",el);
|
return ifError(defined[cat],"Same category named twice",el);
|
||||||
}
|
}
|
||||||
function del(i) { return function() { delete_cat(g,i); }}
|
function del(i) { return function() { delete_cat(g,i); }}
|
||||||
// for(var i=0; i<cs.length;i++) {
|
|
||||||
for(var i in cs) {
|
for(var i in cs) {
|
||||||
es.push(deletable(del(i),check(cs[i],eident(cs[i])),"Delete this category"));
|
es.push(deletable(del(i),check(cs[i],eident(cs[i])),"Delete this category"));
|
||||||
defined[cs[i]]=true;
|
defined[cs[i]]=true;
|
||||||
@@ -424,6 +416,7 @@ function draw_concrete(g,i) {
|
|||||||
return div_id("file",
|
return div_id("file",
|
||||||
[kw("concrete "),ident(g.basename+conc.langcode),
|
[kw("concrete "),ident(g.basename+conc.langcode),
|
||||||
kw(" of "),ident(g.basename),sep(" = "),
|
kw(" of "),ident(g.basename),sep(" = "),
|
||||||
|
indent([extensible([kw("open "),draw_opens(g,i)])]),
|
||||||
indent([extensible([kw("param"),draw_params(g,i)])]),
|
indent([extensible([kw("param"),draw_params(g,i)])]),
|
||||||
indent([kw("lincat"),draw_lincats(g,i)]),
|
indent([kw("lincat"),draw_lincats(g,i)]),
|
||||||
indent([extensible([kw("oper"),draw_opers(g,i)])]),
|
indent([extensible([kw("oper"),draw_opers(g,i)])]),
|
||||||
@@ -431,6 +424,58 @@ function draw_concrete(g,i) {
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var rgl_modules=["Paradigms","Syntax"];
|
||||||
|
|
||||||
|
function add_open(ci) {
|
||||||
|
return function (g,el) {
|
||||||
|
var conc=g.concretes[ci];
|
||||||
|
var os=conc.opens;
|
||||||
|
var ds={};
|
||||||
|
for(var i in os) ds[os[i]]=true;
|
||||||
|
var list=[]
|
||||||
|
for(var i in rgl_modules) {
|
||||||
|
var b=rgl_modules[i], m=b+conc.langcode;
|
||||||
|
if(!ds[m])
|
||||||
|
list.push(li([a(jsurl("add_open2("+g.index+","+ci+",'"+m+"')"),
|
||||||
|
[text(m)])]));
|
||||||
|
}
|
||||||
|
if(list.length>0) {
|
||||||
|
var file=element("file");
|
||||||
|
file.innerHTML="";
|
||||||
|
file.appendChild(p(text("Pick a resource library module to open:")));
|
||||||
|
file.appendChild(node("ul",{},list));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_open2(ix,ci,m) {
|
||||||
|
var g=local.get(ix);
|
||||||
|
var conc=g.concretes[ci];
|
||||||
|
conc.opens || (conc.opens=[]);
|
||||||
|
conc.opens.push(m);
|
||||||
|
save_grammar(g);
|
||||||
|
open_concrete(g,ci);
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_open(g,ci,ix) {
|
||||||
|
with(g.concretes[ci]) opens=delete_ix(opens,ix);
|
||||||
|
reload_grammar(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw_opens(g,ci) {
|
||||||
|
var conc=g.concretes[ci];
|
||||||
|
var os=conc.opens || [] ;
|
||||||
|
var es=[];
|
||||||
|
function del(i) { return function() { delete_open(g,ci,i); }}
|
||||||
|
var first=true;
|
||||||
|
for(var i in os) {
|
||||||
|
if(!first) es.push(sep(", "))
|
||||||
|
es.push(deletable(del(i),ident(os[i]),"Don't open this module"));
|
||||||
|
first=false;
|
||||||
|
}
|
||||||
|
es.push(more(g,add_open(ci),"Open more modules"));
|
||||||
|
return indent(es);
|
||||||
|
}
|
||||||
|
|
||||||
function draw_param(p,dp) {
|
function draw_param(p,dp) {
|
||||||
function check(el) {
|
function check(el) {
|
||||||
@@ -718,6 +763,13 @@ function hidden(name,value) {
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
function delete_ix(old,ix) {
|
||||||
|
var a=[];
|
||||||
|
// for(var i=0;i<old.length;i++) if(i!=ix) a.push(old[i]);
|
||||||
|
for(var i in old) if(i!=ix) a.push(old[i]);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
function sort_list(list,olditems,key) {
|
function sort_list(list,olditems,key) {
|
||||||
var items=[];
|
var items=[];
|
||||||
function find(fun) {
|
function find(fun) {
|
||||||
|
|||||||
@@ -176,8 +176,9 @@ function show_concretes(g) {
|
|||||||
|
|
||||||
function show_concrete(basename) {
|
function show_concrete(basename) {
|
||||||
return function(conc) {
|
return function(conc) {
|
||||||
return "concrete "+basename+conc.langcode+" of "+basename+" = {\n\n"
|
return "concrete "+basename+conc.langcode+" of "+basename+" ="
|
||||||
+"flags coding = utf8 ;\n\n"
|
+show_opens(conc.opens)
|
||||||
|
+" {\n\nflags coding = utf8 ;\n\n"
|
||||||
+show_params(conc.params)
|
+show_params(conc.params)
|
||||||
+show_lincats(conc.lincats)
|
+show_lincats(conc.lincats)
|
||||||
+show_opers(conc.opers)
|
+show_opers(conc.opers)
|
||||||
@@ -192,6 +193,10 @@ function show_list(kw,show1,list) {
|
|||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function show_opens(opens) {
|
||||||
|
return opens && opens.length>0 ? "\n\nopen "+opens.join(", ")+" in" : ""
|
||||||
|
}
|
||||||
|
|
||||||
function show_params(params) { return show_list("param",show_param,params); }
|
function show_params(params) { return show_list("param",show_param,params); }
|
||||||
function show_lincats(lincats) { return show_list("lincat",show_lincat,lincats); }
|
function show_lincats(lincats) { return show_list("lincat",show_lincat,lincats); }
|
||||||
function show_opers(opers) { return show_list("oper",show_oper,opers); }
|
function show_opers(opers) { return show_list("oper",show_oper,opers); }
|
||||||
|
|||||||
Reference in New Issue
Block a user