diff --git a/src/runtime/javascript/editor.html b/src/runtime/javascript/editor.html index ecbb62419..ccf23616b 100644 --- a/src/runtime/javascript/editor.html +++ b/src/runtime/javascript/editor.html @@ -10,7 +10,7 @@
");
}
else {
@@ -359,7 +359,7 @@ function editFrameKeyDown(me,lang,event) {
else
parseTrees = [new Fun(string)];
break;
- default: parseTrees = grammar.concretes[lang].parser.parseString(string, node.cat); break;
+ default: parseTrees = grammar.concretes[lang].parseString(string, node.cat); break;
}
if (parseTrees.length == 1) {
pushUndoClearRedo();
@@ -607,13 +607,8 @@ function showActions(caption) {
actions.push(createAction("Wrap", "action", "SingleWordCommand Wrap", "W"));
}
- for (var i in grammar.concretes) {
- if (grammar.concretes[i].parser) {
- actions.push(createAction("Parse", "action", "Command Parse IndefSgDet String_N", "P"));
- } else { actions.push(createAction("Parse", "unavailable", "Command Parse IndefSgDet String_N", "P")); }
- break;
- }
-
+ actions.push(createAction("Parse", "action", "Command Parse IndefSgDet String_N", "P"));
+
if (node && !abstractNode.isComplete()) {
actions.push(createAction("RandomNode", "action", "RandomlyCommand Refine DefSgDet Node", "N"));
}
diff --git a/src/runtime/javascript/gflib.js b/src/runtime/javascript/gflib.js
index 03df363a4..97e98aab2 100644
--- a/src/runtime/javascript/gflib.js
+++ b/src/runtime/javascript/gflib.js
@@ -20,20 +20,18 @@ GFGrammar.prototype.translate = function (input, fromLang, toLang) {
toConcs[toLang] = this.concretes[toLang];
}
for (var c1 in fromConcs) {
- var p = this.concretes[c1].parser;
- if (p) {
- var trees = p.parseString(input, this.abstract.startcat);
- if (trees.length > 0) {
- outputs[c1] = new Array();
- for (var i in trees) {
- outputs[c1][i] = new Object();
- for (var c2 in toConcs) {
- outputs[c1][i][c2] = this.concretes[c2].linearize(trees[i]);
- }
+ var concrete = this.concretes[c1];
+ var trees = concrete.parseString(input, this.abstract.startcat);
+ if (trees.length > 0) {
+ outputs[c1] = new Array();
+ for (var i in trees) {
+ outputs[c1][i] = new Object();
+ for (var c2 in toConcs) {
+ outputs[c1][i][c2] = this.concretes[c2].linearize(trees[i]);
}
}
}
- }
+ }
return outputs;
}
@@ -50,7 +48,10 @@ String.prototype.setTag = function (tag) { this.tag = tag; };
/* Abstract syntax trees */
function Fun(name) {
this.name = name;
- this.args = copy_arguments(arguments, 1);
+ this.args = new Array();
+ for (var i = 1; i < arguments.length; i++) {
+ this.args[i-1] = arguments[i];
+ }
}
Fun.prototype.print = function () { return this.show(0); } ;
Fun.prototype.show = function (prec) {
@@ -98,7 +99,18 @@ Fun.prototype.isComplete = function() {
}
} ;
Fun.prototype.isLiteral = function() {
- return (/^[\"\d]/).test(this.name);
+ return (/^[\"\-\d]/).test(this.name);
+} ;
+Fun.prototype.isString = function() {
+ return (/^\".*\"$/).test(this.name);
+} ;
+Fun.prototype.isInt = function() {
+ return (/^\-?\d+$/).test(this.name);
+} ;
+Fun.prototype.isFloat = function() {
+ return (/^\-?\d*(\.\d*)?$/).test(this.name) &&
+ this.name != "." &&
+ this.name != "-.";
} ;
Fun.prototype.isEqual = function(obj) {
if (this.name != obj.name)
@@ -112,93 +124,6 @@ Fun.prototype.isEqual = function(obj) {
return true;
}
-/* Concrete syntax terms */
-
-function Arr() { this.arr = copy_arguments(arguments, 0); }
-Arr.prototype.tokens = function() { return this.arr[0].tokens(); };
-Arr.prototype.sel = function(i) { return this.arr[i.toIndex()]; };
-Arr.prototype.setTag = function(tag) {
- for (var i = 0, j = this.arr.length; i < j; i++) {
- this.arr[i].setTag(tag);
- }
-};
-
-function Seq() { this.seq = copy_arguments(arguments, 0); }
-Seq.prototype.tokens = function() {
- var xs = new Array();
- for (var i in this.seq) {
- var ys = this.seq[i].tokens();
- for (var j in ys) {
- xs.push(ys[j]);
- }
- }
- return xs;
-};
-Seq.prototype.setTag = function(tag) {
- for (var i = 0, j = this.seq.length; i < j; i++) {
- this.seq[i].setTag(tag);
- }
-};
-
-function Variants() { this.variants = copy_arguments(arguments, 0); }
-Variants.prototype.tokens = function() { return this.variants[0].tokens(); };
-Variants.prototype.sel = function(i) { return this.variants[0].sel(i); };
-Variants.prototype.toIndex = function() { return this.variants[0].toIndex(); };
-Variants.prototype.setTag = function(tag) {
- for (var i = 0, j = this.variants.length; i < j; i++) {
- this.variants[i].setTag(tag);
- }
-};
-
-function Rp(index,value) { this.index = index; this.value = value; }
-Rp.prototype.tokens = function() { return new Array(this.index.tokens()); };
-Rp.prototype.sel = function(i) { return this.value.arr[i.toIndex()]; };
-Rp.prototype.toIndex = function() { return this.index.toIndex(); };
-Rp.prototype.setTag = function(tag) { this.index.setTag(tag) };
-
-function Suffix(prefix,suffix) {
- this.prefix = new String(prefix);
- if (prefix.tag) { this.prefix.tag = prefix.tag; }
- this.suffix = suffix;
-};
-Suffix.prototype.tokens = function() {
- var xs = this.suffix.tokens();
- for (var i in xs) {
- xs[i] = new String(this.prefix + xs[i]);
- xs[i].setTag(this.prefix.tag);
- }
- return xs;
-};
-Suffix.prototype.sel = function(i) { return new Suffix(this.prefix, this.suffix.sel(i)); };
-Suffix.prototype.setTag = function(tag) { if (!this.prefix.tag) { this.prefix.setTag(tag); } };
-
-function Meta() { }
-Meta.prototype.tokens = function() {
- var newString = new String("?");
- newString.setTag(this.tag);
- return new Array(newString);
-};
-Meta.prototype.toIndex = function() { return 0; };
-Meta.prototype.sel = function(i) { return this; };
-Meta.prototype.setTag = function(tag) { if (!this.tag) { this.tag = tag; } };
-
-function Str(value) { this.value = value; }
-Str.prototype.tokens = function() {
- var newString = new String(this.value);
- newString.setTag(this.tag);
- return new Array(newString);
-};
-Str.prototype.setTag = function(tag) { if (!this.tag) { this.tag = tag; } };
-
-function Int(value) { this.value = value; }
-Int.prototype.tokens = function() {
- var newString = new String(this.value.toString());
- newString.setTag(this.tag);
- return new Array(newString);
-};
-Int.prototype.toIndex = function() { return this.value; };
-Int.prototype.setTag = function(tag) { if (!this.tag) { this.tag = tag; } };
-
/* Type annotation */
function GFAbstract(startcat, types) {
@@ -284,47 +209,166 @@ function Type(args, cat) {
/* Linearization */
-function GFConcrete(flags, rules, parser) {
- this.flags = flags;
- this.rules = rules;
- if (parser) {
- this.parser = parser;
- } else {
- this.parser = undefined;
- }
+function GFConcrete(flags, productions, functions, sequences, startCats, totalFIds) {
+ this.flags = flags;
+ this.productions = productions;
+ this.functions = functions;
+ this.sequences = sequences;
+ this.startCats = startCats;
+ this.totalFIds = totalFIds;
+
+ this.pproductions = productions;
+ this.lproductions = new Object();
+
+ for (var fid in productions) {
+ for (var i in productions[fid]) {
+ var rule = productions[fid][i];
+
+ if (rule.id == "Apply") {
+ var fun = this.functions[rule.fun];
+ var lproductions = this.lproductions;
+
+ rule.fun = fun;
+
+ var register = function (args, key, i) {
+ if (i < args.length) {
+ var c = 0;
+ var arg = args[i].fid;
+
+ for (var k in productions[arg]) {
+ var rule = productions[arg][k];
+ if (rule.id == "Coerce") {
+ register(args,key + "_" + rule.arg,i+1);
+ c++;
+ }
+ }
+
+ if (c == 0)
+ register(args,key + "_" + arg,i+1);
+ } else {
+ var set = lproductions[key];
+ if (set == null) {
+ set = new Array();
+ lproductions[key] = set;
+ }
+ set.push({fun: fun, fid: fid});
+ }
+ }
+
+ register(rule.args,rule.fun.name,0);
+ }
+ }
+ }
+
+ for (var i in functions) {
+ var fun = functions[i];
+ for (var j in fun.lins) {
+ fun.lins[j] = sequences[fun.lins[j]];
+ }
+ }
}
-GFConcrete.prototype.rule = function (name, cs) {
- var r = this.rules[name];
- if (r) {
- return this.rules[name](cs);
+GFConcrete.prototype.linearizeSyms = function (tree, tag) {
+ var res = new Array();
+
+ if (tree.isString()) {
+ var sym = new SymKS(tree.name);
+ sym.tag = tag;
+ res.push({fid: -1, table: [[sym]]});
+ } else if (tree.isInt()) {
+ var sym = new SymKS(tree.name);
+ sym.tag = tag;
+ res.push({fid: -2, table: [[sym]]});
+ } else if (tree.isFloat()) {
+ var sym = new SymKS(tree.name);
+ sym.tag = tag;
+ res.push({fid: -3, table: [[sym]]});
+ } else if (tree.isMeta()) {
+ // TODO: Use lindef here
+ var cat = this.startCats[tree.type];
+
+ var sym = new SymKS(tree.name);
+ sym.tag = tag;
+
+ for (var fid = cat.s; fid <= cat.e; fid++) {
+ res.push({fid: fid, table: [[sym]]});
+ }
} else {
- window.alert("Missing rule " + name);
+ var cs = new Array();
+ for (var i in tree.args) {
+ // TODO: we should handle the case for nondeterministic linearization
+ cs.push(this.linearizeSyms(tree.args[i],tag + "-" + i)[0]);
+ }
+ var key = tree.name;
+ for (var i in cs) {
+ key = key + "_" + cs[i].fid
+ }
+
+ for (var i in this.lproductions[key]) {
+ var rule = this.lproductions[key][i];
+ var row = {fid: rule.fid, table: new Array()};
+ for (var j in rule.fun.lins) {
+ var lin = rule.fun.lins[j];
+ var toks = new Array();
+ row.table[j] = toks;
+
+ for (var k in lin) {
+ var sym = lin[k];
+ switch (sym.id) {
+ case "Arg":
+ case "Lit":
+ var ts = cs[sym.i].table[sym.label];
+ for (var l in ts) {
+ toks.push(ts[l]);
+ }
+ break;
+ case "KS":
+ case "KP":
+ toks.push(this.tagIt(sym,tag));
+ break;
+ }
+ }
+ }
+ res.push(row);
+ }
}
+
+ return res;
};
-GFConcrete.prototype.addRule = function (name, f) { this.rules[name] = f; };
-GFConcrete.prototype.lindef = function (cat, v) { return this.rules[cat]([new Str(v)]); } ;
-GFConcrete.prototype.linearize = function (tree) {
- return this.unlex(this.linearizeToTerm(tree).tokens());
+GFConcrete.prototype.syms2toks = function (syms) {
+ var ts = new Array();
+ for (var i in syms) {
+ var sym = syms[i];
+ switch (sym.id) {
+ case "KS":
+ for (var j in sym.tokens) {
+ ts.push(this.tagIt(sym.tokens[j],sym.tag));
+ }
+ break;
+ case "KP":
+ for (var j in sym.tokens) {
+ ts.push(this.tagIt(sym.tokens[j],sym.tag));
+ }
+ break;
+ }
+ }
+ return ts;
};
-GFConcrete.prototype.linearizeToTerm = function (tree) {
- if (tree.isMeta()) {
- if (isUndefined(tree.type)) {
- return new Meta();
- } else {
- return this.lindef(tree.type, tree.name);
- }
- } else {
- var cs = new Array();
- for (var i in tree.args) {
- cs.push(this.linearizeToTerm(tree.args[i]));
- }
- if (tree.isLiteral()) {
- return new Arr(new Str(tree.name));
- } else {
- return this.rule(tree.name, cs);
- }
- }
+GFConcrete.prototype.linearizeAll = function (tree) {
+ var res = this.linearizeSyms(tree,"0");
+ for (var l in res) {
+ res[l] = this.unlex(this.syms2toks(res[l].table[0]));
+ }
+
+ return res;
};
+GFConcrete.prototype.linearize = function (tree) {
+ var res = this.linearizeSyms(tree,"0");
+ return this.unlex(this.syms2toks(res[0].table[0]));
+}
+GFConcrete.prototype.tagAndLinearize = function (tree) {
+ var res = this.linearizeSyms(tree,"0");
+ return this.syms2toks(res[0].table[0]);
+}
GFConcrete.prototype.unlex = function (ts) {
if (ts.length == 0) {
return "";
@@ -345,29 +389,20 @@ GFConcrete.prototype.unlex = function (ts) {
}
return s;
};
-GFConcrete.prototype.tagAndLinearize = function (tree) {
- return this.tagAndLinearizeToTerm(tree, "0").tokens();
-};
-GFConcrete.prototype.tagAndLinearizeToTerm = function (tree, route) {
- if (tree.isMeta()) {
- if (isUndefined(tree.type)) {
- var newMeta = new Meta();
- newMeta.setTag(route);
- return newMeta;
- } else {
- var newTerm = this.lindef(tree.type, tree.name);
- newTerm.setTag(route);
- return newTerm;
- }
- } else {
- var cs = new Array();
- for (var i in tree.args) {
- cs.push(this.tagAndLinearizeToTerm(tree.args[i], route + "-" + i));
- }
- var newTerm = this.rule(tree.name, cs);
- newTerm.setTag(route);
- return newTerm;
- }
+GFConcrete.prototype.tagIt = function (obj, tag) {
+ if (isString(obj)) {
+ var o = new String(obj);
+ o.setTag(tag);
+ return o;
+ } else {
+ var me = arguments.callee;
+ if (arguments.length == 2) {
+ me.prototype = obj;
+ var o = new me();
+ o.tag = tag;
+ return o;
+ }
+ }
};
/* Utilities */
@@ -405,42 +440,12 @@ function dumpObject (obj) {
}
}
-
-function copy_arguments(args, start) {
- var arr = new Array();
- for (var i = 0; i < args.length - start; i++) {
- arr[i] = args[i + start];
- }
- return arr;
-}
-
/* ------------------------------------------------------------------------- */
/* -------------------------------- PARSING -------------------------------- */
/* ------------------------------------------------------------------------- */
-function Parser(productions, functions, sequences, startCats, totalCats) {
- this.productions = productions;
- this.functions = functions;
- this.sequences = sequences;
- this.startCats = startCats;
- this.totalCats = totalCats;
-
- for (var fid in productions) {
- for (var i in productions[fid]) {
- var rule = productions[fid][i];
- rule.fun = functions[rule.fun];
- }
- }
-
- for (var i in functions) {
- var fun = functions[i];
- for (var j in fun.lins) {
- fun.lins[j] = sequences[fun.lins[j]];
- }
- }
-}
-Parser.prototype.showRules = function () {
+GFConcrete.prototype.showRules = function () {
var ruleStr = new Array();
ruleStr.push("");
for (var i = 0, j = this.rules.length; i < j; i++) {
@@ -448,7 +453,7 @@ Parser.prototype.showRules = function () {
}
return ruleStr.join("");
};
-Parser.prototype.tokenize = function (string) {
+GFConcrete.prototype.tokenize = function (string) {
var inToken = false;
var start, end;
var tokens = new Array();
@@ -484,7 +489,7 @@ Parser.prototype.tokenize = function (string) {
}
return tokens;
};
-Parser.prototype.parseString = function (string, cat) {
+GFConcrete.prototype.parseString = function (string, cat) {
var tokens = this.tokenize(string);
var ps = new ParseState(this, cat);
@@ -497,7 +502,7 @@ Parser.prototype.parseString = function (string, cat) {
/**
* Generate list of suggestions given an input string
*/
-Parser.prototype.complete = function (input, cat) {
+GFConcrete.prototype.complete = function (input, cat) {
// Parameter defaults
if (input == null) input = "";
@@ -558,19 +563,19 @@ Parser.prototype.complete = function (input, cat) {
return { 'consumed' : tokens, 'suggestions' : suggs };
}
-// Rule Object Definition
+// Apply Object Definition
-function Rule(fun, args) {
- this.id = "Rule";
+function Apply(fun, args) {
+ this.id = "Apply";
this.fun = fun;
this.args = args;
}
-Rule.prototype.show = function (cat) {
+Apply.prototype.show = function (cat) {
var recStr = new Array();
recStr.push(cat, " -> ", fun.name, " [", this.args, "]");
return recStr.join("");
};
-Rule.prototype.isEqual = function (obj) {
+Apply.prototype.isEqual = function (obj) {
if (this.id != obj.id || this.fun != obj.fun || this.args.length != obj.args.length)
return false;
@@ -582,6 +587,12 @@ Rule.prototype.isEqual = function (obj) {
return true;
};
+function PArg() {
+ this.fid = arguments[arguments.length-1];
+ if (arguments.length > 1)
+ this.hypos = arguments.slice(0,arguments.length-1);
+}
+
// Coerce Object Definition
function Coerce(arg) {
@@ -618,7 +629,7 @@ Const.prototype.isEqual = function (obj) {
return true;
};
-function FFun(name,lins) {
+function CncFun(name,lins) {
this.name = name;
this.lins = lins;
}
@@ -626,39 +637,39 @@ function FFun(name,lins) {
// Definition of symbols present in linearization records
// Object to represent argument projections in grammar rules
-function Arg(i, label) {
+function SymCat(i, label) {
this.id = "Arg";
this.i = i;
this.label = label;
}
-Arg.prototype.getId = function () { return this.id; };
-Arg.prototype.getArgNum = function () { return this.i };
-Arg.prototype.show = function () {
+SymCat.prototype.getId = function () { return this.id; };
+SymCat.prototype.getArgNum = function () { return this.i };
+SymCat.prototype.show = function () {
var argStr = new Array();
argStr.push(this.i, this.label);
return argStr.join(".");
};
// Object to represent terminals in grammar rules
-function KS() {
+function SymKS() {
this.id = "KS";
this.tokens = arguments;
}
-KS.prototype.getId = function () { return this.id; };
-KS.prototype.show = function () {
+SymKS.prototype.getId = function () { return this.id; };
+SymKS.prototype.show = function () {
var terminalStr = new Array();
terminalStr.push('"', this.tokens, '"');
return terminalStr.join("");
};
// Object to represent pre in grammar rules
-function KP(tokens,alts) {
+function SymKP(tokens,alts) {
this.id = "KP";
this.tokens = tokens;
this.alts = alts;
}
-KP.prototype.getId = function () { return this.id; };
-KP.prototype.show = function () {
+SymKP.prototype.getId = function () { return this.id; };
+SymKP.prototype.show = function () {
var terminalStr = new Array();
terminalStr.push('"', this.tokens, '"');
return terminalStr.join("");
@@ -670,13 +681,13 @@ function Alt(tokens, prefixes) {
}
// Object to represent pre in grammar rules
-function Lit(i,label) {
+function SymLit(i,label) {
this.id = "Lit";
this.i = i;
this.label = label;
}
-Lit.prototype.getId = function () { return this.id; };
-Lit.prototype.show = function () {
+SymLit.prototype.getId = function () { return this.id; };
+SymLit.prototype.show = function () {
var argStr = new Array();
argStr.push(this.i, this.label);
return argStr.join(".");
@@ -729,15 +740,15 @@ Trie.prototype.isEmpty = function() {
return true;
}
-function ParseState(parser, startCat) {
- this.parser = parser;
+function ParseState(concrete, startCat) {
+ this.concrete = concrete;
this.startCat = startCat;
this.items = new Trie();
- this.chart = new Chart(parser);
+ this.chart = new Chart(concrete);
var items = new Array();
- var fids = parser.startCats[startCat];
+ var fids = concrete.startCats[startCat];
if (fids != null) {
var fid;
for (fid = fids.s; fid <= fids.e; fid++) {
@@ -841,11 +852,11 @@ ParseState.prototype.extractTrees = function() {
);
- var totalCats = this.parser.totalCats;
+ var totalFIds = this.concrete.totalFIds;
var forest = this.chart.forest;
function go(fid) {
- if (fid < totalCats) {
+ if (fid < totalFIds) {
return [new Fun("?")];
} else {
var trees = new Array();
@@ -861,7 +872,7 @@ ParseState.prototype.extractTrees = function() {
var arg_ts = new Array();
for (var k in rule.args) {
arg_ix[k] = 0;
- arg_ts[k] = go(rule.args[k]);
+ arg_ts[k] = go(rule.args[k].fid);
}
while (true) {
@@ -893,7 +904,7 @@ ParseState.prototype.extractTrees = function() {
var trees = new Array();
- var fids = this.parser.startCats[this.startCat];
+ var fids = this.concrete.startCats[this.startCat];
if (fids != null) {
var fid0;
for (fid0 = fids.s; fid0 <= fids.e; fid0++) {
@@ -936,7 +947,7 @@ ParseState.prototype.process = function (agenda,literalCallback,tokenCallback) {
if (item.dot < lin.length) {
var sym = lin[item.dot];
switch (sym.id) {
- case "Arg": var fid = item.args[sym.i];
+ case "Arg": var fid = item.args[sym.i].fid;
var label = sym.label;
var items = this.chart.lookupAC(fid,label);
@@ -975,7 +986,7 @@ ParseState.prototype.process = function (agenda,literalCallback,tokenCallback) {
tokenCallback(alt.tokens, pitem);
}
break;
- case "Lit": var fid = item.args[sym.i];
+ case "Lit": var fid = item.args[sym.i].fid;
var rules = this.chart.forest[fid];
if (rules != null) {
tokenCallback(rules[0].toks, item.shiftOverTokn());
@@ -1004,7 +1015,7 @@ ParseState.prototype.process = function (agenda,literalCallback,tokenCallback) {
}
this.chart.insertPC(item.fid,item.lbl,item.offset,fid);
- this.chart.forest[fid] = [new Rule(item.fun,item.args)];
+ this.chart.forest[fid] = [new Apply(item.fun,item.args)];
} else {
var labels = this.chart.labelsAC(fid);
if (labels != null) {
@@ -1014,7 +1025,7 @@ ParseState.prototype.process = function (agenda,literalCallback,tokenCallback) {
}
var rules = this.chart.forest[fid];
- var rule = new Rule(item.fun,item.args);
+ var rule = new Apply(item.fun,item.args);
var isMember = false;
for (var j in rules) {
@@ -1030,16 +1041,16 @@ ParseState.prototype.process = function (agenda,literalCallback,tokenCallback) {
}
}
-function Chart(parser) {
+function Chart(concrete) {
this.active = new Object();
this.actives = new Array();
this.passive = new Object();
this.forest = new Object();
- this.nextId = parser.totalCats;
+ this.nextId = concrete.totalFIds;
this.offset = 0;
- for (var fid in parser.productions) {
- this.forest[fid] = parser.productions[fid];
+ for (var fid in concrete.pproductions) {
+ this.forest[fid] = concrete.pproductions[fid];
}
}
Chart.prototype.lookupAC = function (fid,label) {
@@ -1096,7 +1107,7 @@ Chart.prototype.expandForest = function (fid) {
for (var i in rules0) {
var rule = rules0[i];
switch (rule.id) {
- case "Rule": rules.push(rule); break;
+ case "Apply": rules.push(rule); break;
case "Coerce": go(forest[rule.arg]); break;
}
}
@@ -1129,9 +1140,9 @@ ActiveItem.prototype.shiftOverArg = function (i,fid) {
for (var k in this.args) {
nargs[k] = this.args[k];
}
- nargs[i] = fid;
+ nargs[i] = new PArg(fid);
return new ActiveItem(this.offset,this.dot+1,this.fun,this.seq,nargs,this.fid,this.lbl);
}
ActiveItem.prototype.shiftOverTokn = function () {
return new ActiveItem(this.offset,this.dot+1,this.fun,this.seq,this.args,this.fid,this.lbl);
-}
\ No newline at end of file
+}
diff --git a/src/runtime/javascript/grammar.js b/src/runtime/javascript/grammar.js
index a5859bd46..9e246db50 100644
--- a/src/runtime/javascript/grammar.js
+++ b/src/runtime/javascript/grammar.js
@@ -1 +1 @@
-var Food = new GFGrammar(new GFAbstract("Comment",{Boring: new Type([], "Quality"), Cheese: new Type([], "Kind"), Delicious: new Type([], "Quality"), Expensive: new Type([], "Quality"), Fish: new Type([], "Kind"), Fresh: new Type([], "Quality"), Pred: new Type(["Item", "Quality"], "Comment"), Italian: new Type([], "Quality"), Mod: new Type(["Quality", "Kind"], "Kind"), That: new Type(["Kind"], "Item"), This: new Type(["Kind"], "Item"), Very: new Type(["Quality"], "Quality"), Warm: new Type([], "Quality"), Wine: new Type([], "Kind")}),{FoodEng: new GFConcrete({},{Boring: function(cs){return new Arr(new Str("boring"));}, Cheese: function(cs){return new Arr(new Str("cheese"));}, Delicious: function(cs){return new Arr(new Str("delicious"));}, Expensive: function(cs){return new Arr(new Str("expensive"));}, Fish: function(cs){return new Arr(new Str("fish"));}, Fresh: function(cs){return new Arr(new Str("fresh"));}, Pred: function(cs){return new Arr(new Seq(Food.concretes["FoodEng"].rule("_6", cs), new Str("is"), Food.concretes["FoodEng"].rule("_7", cs)));}, Italian: function(cs){return new Arr(new Str("Italian"));}, Mod: function(cs){return new Arr(new Seq(Food.concretes["FoodEng"].rule("_6", cs), Food.concretes["FoodEng"].rule("_7", cs)));}, That: function(cs){return new Arr(new Seq(new Str("that"), Food.concretes["FoodEng"].rule("_6", cs)));}, This: function(cs){return new Arr(new Seq(new Str("this"), Food.concretes["FoodEng"].rule("_6", cs)));}, Very: function(cs){return new Arr(new Seq(new Str("very"), Food.concretes["FoodEng"].rule("_6", cs)));}, Warm: function(cs){return new Arr(new Str("warm"));}, Wine: function(cs){return new Arr(new Str("wine"));}, _21: function(cs){return new Arr(cs[0]);}, _6: function(cs){return cs[0].sel(new Int(0));}, _7: function(cs){return cs[1].sel(new Int(0));}, Item: function(cs){return Food.concretes["FoodEng"].rule("_21", cs);}, Kind: function(cs){return Food.concretes["FoodEng"].rule("_21", cs);}, Comment: function(cs){return Food.concretes["FoodEng"].rule("_21", cs);}, Quality: function(cs){return Food.concretes["FoodEng"].rule("_21", cs);}, "Int": function(cs){return new Arr(cs[0]);}, "Float": function(cs){return new Arr(cs[0]);}, "String": function(cs){return new Arr(cs[0]);}}, new Parser({0:[new Rule(9,[1]), new Rule(10,[1])], 1:[new Rule(1,[]), new Rule(4,[]), new Rule(8,[3, 1]), new Rule(13,[])], 2:[new Rule(6,[0, 3])], 3:[new Rule(0,[]), new Rule(2,[]), new Rule(3,[]), new Rule(5,[]), new Rule(7,[]), new Rule(11,[3]), new Rule(12,[])]},[new FFun("Boring",[0]), new FFun("Cheese",[1]), new FFun("Delicious",[2]), new FFun("Expensive",[3]), new FFun("Fish",[4]), new FFun("Fresh",[5]), new FFun("Pred",[6]), new FFun("Italian",[7]), new FFun("Mod",[8]), new FFun("That",[9]), new FFun("This",[10]), new FFun("Very",[11]), new FFun("Warm",[12]), new FFun("Wine",[13])],[[new KS("boring")],[new KS("cheese")],[new KS("delicious")],[new KS("expensive")],[new KS("fish")],[new KS("fresh")],[new Arg(0, 0), new KS("is"), new Arg(1, 0)],[new KS("Italian")],[new Arg(0, 0), new Arg(1, 0)],[new KS("that"), new Arg(0, 0)],[new KS("this"), new Arg(0, 0)],[new KS("very"), new Arg(0, 0)],[new KS("warm")],[new KS("wine")]],{Float:{s: -3, e: -3}, Int:{s: -2, e: -2}, Item:{s: 0, e: 0}, Kind:{s: 1, e: 1}, Comment:{s: 2, e: 2}, Quality:{s: 3, e: 3}, String:{s: -1, e: -1}, __gfVar:{s: -4, e: -4}}, 5)), FoodIta: new GFConcrete({},{Boring: function(cs){return new Arr(new Str("noioso"));}, Cheese: function(cs){return new Arr(new Str("formaggio"));}, Delicious: function(cs){return new Arr(new Str("delizioso"));}, Expensive: function(cs){return new Arr(new Str("caro"));}, Fish: function(cs){return new Arr(new Str("pesce"));}, Fresh: function(cs){return new Arr(new Str("fresco"));}, Pred: function(cs){return new Arr(new Seq(Food.concretes["FoodIta"].rule("_6", cs), new Str("è"), Food.concretes["FoodIta"].rule("_7", cs)));}, Italian: function(cs){return new Arr(new Str("italiano"));}, Mod: function(cs){return new Arr(new Seq(Food.concretes["FoodIta"].rule("_7", cs), Food.concretes["FoodIta"].rule("_6", cs)));}, That: function(cs){return new Arr(new Seq(new Str("quel"), Food.concretes["FoodIta"].rule("_6", cs)));}, This: function(cs){return new Arr(new Seq(new Str("questo"), Food.concretes["FoodIta"].rule("_6", cs)));}, Very: function(cs){return new Arr(new Seq(new Str("molto"), Food.concretes["FoodIta"].rule("_6", cs)));}, Warm: function(cs){return new Arr(new Str("caldo"));}, Wine: function(cs){return new Arr(new Str("vino"));}, _21: function(cs){return new Arr(cs[0]);}, _6: function(cs){return cs[0].sel(new Int(0));}, _7: function(cs){return cs[1].sel(new Int(0));}, Item: function(cs){return Food.concretes["FoodIta"].rule("_21", cs);}, Kind: function(cs){return Food.concretes["FoodIta"].rule("_21", cs);}, Comment: function(cs){return Food.concretes["FoodIta"].rule("_21", cs);}, Quality: function(cs){return Food.concretes["FoodIta"].rule("_21", cs);}, "Int": function(cs){return new Arr(cs[0]);}, "Float": function(cs){return new Arr(cs[0]);}, "String": function(cs){return new Arr(cs[0]);}}, new Parser({0:[new Rule(9,[1]), new Rule(10,[1])], 1:[new Rule(1,[]), new Rule(4,[]), new Rule(8,[3, 1]), new Rule(13,[])], 2:[new Rule(6,[0, 3])], 3:[new Rule(0,[]), new Rule(2,[]), new Rule(3,[]), new Rule(5,[]), new Rule(7,[]), new Rule(11,[3]), new Rule(12,[])]},[new FFun("Boring",[0]), new FFun("Cheese",[1]), new FFun("Delicious",[2]), new FFun("Expensive",[3]), new FFun("Fish",[4]), new FFun("Fresh",[5]), new FFun("Pred",[6]), new FFun("Italian",[7]), new FFun("Mod",[8]), new FFun("That",[9]), new FFun("This",[10]), new FFun("Very",[11]), new FFun("Warm",[12]), new FFun("Wine",[13])],[[new KS("noioso")],[new KS("formaggio")],[new KS("delizioso")],[new KS("caro")],[new KS("pesce")],[new KS("fresco")],[new Arg(0, 0), new KS("è"), new Arg(1, 0)],[new KS("italiano")],[new Arg(1, 0), new Arg(0, 0)],[new KS("quel"), new Arg(0, 0)],[new KS("questo"), new Arg(0, 0)],[new KS("molto"), new Arg(0, 0)],[new KS("caldo")],[new KS("vino")]],{Float:{s: -3, e: -3}, Int:{s: -2, e: -2}, Item:{s: 0, e: 0}, Kind:{s: 1, e: 1}, Comment:{s: 2, e: 2}, Quality:{s: 3, e: 3}, String:{s: -1, e: -1}, __gfVar:{s: -4, e: -4}}, 5))});
+var Foods = new GFGrammar(new GFAbstract("Phrase",{Boring: new Type([], "Quality"), Cheese: new Type([], "Kind"), Delicious: new Type([], "Quality"), Expensive: new Type([], "Quality"), Fish: new Type([], "Kind"), Fresh: new Type([], "Quality"), Is: new Type(["Item", "Quality"], "Phrase"), Italian: new Type([], "Quality"), Pizza: new Type([], "Kind"), QKind: new Type(["Quality", "Kind"], "Kind"), That: new Type(["Kind"], "Item"), These: new Type(["Kind"], "Item"), This: new Type(["Kind"], "Item"), Those: new Type(["Kind"], "Item"), Very: new Type(["Quality"], "Quality"), Warm: new Type([], "Quality"), Wine: new Type([], "Kind")}),{FoodsEng: new GFConcrete({},{0:[new Apply(15,[new PArg(2)]), new Apply(17,[new PArg(2)])], 1:[new Apply(16,[new PArg(2)]), new Apply(18,[new PArg(2)])], 2:[new Apply(5,[]), new Apply(8,[]), new Apply(13,[]), new Apply(14,[new PArg(4), new PArg(2)]), new Apply(21,[])], 3:[new Apply(10,[new PArg(0), new PArg(4)]), new Apply(11,[new PArg(1), new PArg(4)])], 4:[new Apply(4,[]), new Apply(6,[]), new Apply(7,[]), new Apply(9,[]), new Apply(12,[]), new Apply(19,[new PArg(4)]), new Apply(20,[])]},[new CncFun("lindef Item",[0]), new CncFun("lindef Kind",[0, 0]), new CncFun("lindef Phrase",[0]), new CncFun("lindef Quality",[0]), new CncFun("Boring",[1]), new CncFun("Cheese",[2, 3]), new CncFun("Delicious",[4]), new CncFun("Expensive",[5]), new CncFun("Fish",[6, 6]), new CncFun("Fresh",[7]), new CncFun("Is",[8]), new CncFun("Is",[9]), new CncFun("Italian",[10]), new CncFun("Pizza",[11, 12]), new CncFun("QKind",[13, 14]), new CncFun("That",[15]), new CncFun("These",[16]), new CncFun("This",[17]), new CncFun("Those",[18]), new CncFun("Very",[19]), new CncFun("Warm",[20]), new CncFun("Wine",[21, 22])],[[new SymLit(0, 0)],[new SymKS("boring")],[new SymKS("cheese")],[new SymKS("cheeses")],[new SymKS("delicious")],[new SymKS("expensive")],[new SymKS("fish")],[new SymKS("fresh")],[new SymCat(0, 0), new SymKS("is"), new SymCat(1, 0)],[new SymCat(0, 0), new SymKS("are"), new SymCat(1, 0)],[new SymKS("Italian")],[new SymKS("pizza")],[new SymKS("pizzas")],[new SymCat(0, 0), new SymCat(1, 0)],[new SymCat(0, 0), new SymCat(1, 1)],[new SymKS("that"), new SymCat(0, 0)],[new SymKS("these"), new SymCat(0, 1)],[new SymKS("this"), new SymCat(0, 0)],[new SymKS("those"), new SymCat(0, 1)],[new SymKS("very"), new SymCat(0, 0)],[new SymKS("warm")],[new SymKS("wine")],[new SymKS("wines")]],{Float:{s: -3, e: -3}, Int:{s: -2, e: -2}, Item:{s: 0, e: 1}, Kind:{s: 2, e: 2}, Phrase:{s: 3, e: 3}, Quality:{s: 4, e: 4}, String:{s: -1, e: -1}, __gfVar:{s: -4, e: -4}}, 6)});