mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
Updated JS editor to the latest version from Moises.
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<link rel="stylesheet" type="text/css" href="style.css" />
|
||||
<script type="text/javascript" src="gflib.js"></script>
|
||||
<script type="text/javascript" src="editorGrammar.js"></script>
|
||||
<script type="text/javascript" src="grammar.js"></script>
|
||||
<script type="text/javascript" src="gfjseditor.js"></script>
|
||||
<title>Web-based Syntax Editor</title>
|
||||
</head>
|
||||
<body onload="mkEditor('editor', Food)" onkeydown="hotKeys(event)">
|
||||
<div id="editor">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<link rel="stylesheet" type="text/css" href="style.css" />
|
||||
<script type="text/javascript" src="gflib.js"></script>
|
||||
<script type="text/javascript" src="editorGrammar.js"></script>
|
||||
<script type="text/javascript" src="grammar.js"></script>
|
||||
<script type="text/javascript" src="gfjseditor.js"></script>
|
||||
<title>Web-based Syntax Editor</title>
|
||||
</head>
|
||||
<body onload="mkEditor('editor', Restaurant)" onkeydown="hotKeys(event)">
|
||||
<div id="editor">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -6,9 +6,11 @@ expColImg[0] = new Image(12,12);
|
||||
expColImg[0].src = "minus.png";
|
||||
expColImg[1] = new Image(12,12);
|
||||
expColImg[1].src = "plus.png";
|
||||
|
||||
// Grammars
|
||||
var grammar = undefined;
|
||||
expColImg[2] = new Image(12,12);
|
||||
expColImg[2].src = "empty.png";
|
||||
|
||||
// Grammars
|
||||
var grammar = undefined;
|
||||
var editorGrammar = Editor;
|
||||
|
||||
var selectedLanguage = "EditorEng";
|
||||
@@ -47,7 +49,6 @@ keys ["27"] = function() { clickEsc(); };
|
||||
|
||||
function state(selectedNode, tree, collapseBuffer) {
|
||||
this.selectedNode = selectedNode;
|
||||
// this.tree = myAbstract.copyTree(tree);
|
||||
this.tree = grammar.abstract.copyTree(tree);
|
||||
this.collapseBuffer = collapseBuffer;
|
||||
return this;
|
||||
@@ -70,10 +71,15 @@ treeNode.prototype.hasChildren = function() {
|
||||
return this.children.length;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* ----------------------------- GUI functions ----------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
// Creates an instance of the editor and stores it in the given HTML container.
|
||||
// Previous content is destroyed.
|
||||
function mkEditor(container, myGrammar) {
|
||||
grammar = myGrammar;
|
||||
function mkEditor(container, myGrammar) {
|
||||
grammar = myGrammar;
|
||||
myTree = treeFromAbstract(grammar.abstract.annotate(abstractTree, grammar.abstract.startcat), "0");
|
||||
var holder = document.getElementById(container);
|
||||
holder.innerHTML = "<div id='wrapper'><div id='absFrame'></div><div id='conFrame'></div><div id='actFrame'></div><div id='refFrame'></div><div id='messageFrame'></div><div id='clipboardFrame'></div></div>";
|
||||
@@ -370,18 +376,17 @@ function nodeClick(name) {
|
||||
function showLanguages() {
|
||||
var languages = new Array();
|
||||
languages.push("<table class='language' id='languagesTable'>",
|
||||
"<tr id='langs' class='language'>",
|
||||
"<tr id='langs' class='language'>",
|
||||
"<td class='language' id='EditorDan' title='Label Bulgarian' onclick='clickLanguage(\"\")'>Bulgarian</td>",
|
||||
"<td class='language' id='EditorDan' title='Label Danish' onclick='clickLanguage(\"\")'>Danish</td>",
|
||||
"<td class='language' id='EditorEng' title='Label English' onclick='clickLanguage(\"EditorEng\")'>English</td>",
|
||||
"<td class='language' id='EditorFin' title='Label Finnish' onclick='clickLanguage(\"\")'>Finnish</td>",
|
||||
"<td class='language' id='EditorFre' title='Label French' onclick='clickLanguage(\"\")'>French</td>",
|
||||
"<td class='language' id='EditorFre' title='Label French' onclick='clickLanguage(\"EditorFre\")'>French</td>",
|
||||
"<td class='language' id='EditorGer' title='Label German' onclick='clickLanguage(\"\")'>German</td>",
|
||||
"<td class='language' id='EditorIta' title='Label Italian' onclick='clickLanguage(\"\")'>Italian</td>",
|
||||
"<td class='language' id='EditorNor' title='Label Norwegian' onclick='clickLanguage(\"\")'>Norwegian</td>",
|
||||
"<td class='language' id='EditorRus' title='Label Russian' onclick='clickLanguage(\"\")'>Russian</td>",
|
||||
// "<td class='language' id='EditorSpa' title='Label Spanish' onclick='clickLanguage(\"EditorSpa\")'>Spanish</td>",
|
||||
"<td class='language' id='EditorSpa' title='Label Spanish' onclick='clickLanguage(\"\")'>Spanish</td>",
|
||||
"<td class='language' id='EditorSpa' title='Label Spanish' onclick='clickLanguage(\"EditorSpa\")'>Spanish</td>",
|
||||
"<td class='language' id='EditorSwe' title='Label Swedish' onclick='clickLanguage(\"EditorSwe\")'>Swedish</td></tr>",
|
||||
"</table>");
|
||||
return languages.join("");
|
||||
@@ -406,6 +411,7 @@ function applyLanguage() {
|
||||
for (var i = 0, j = langsToLinearize.length; i < j; i++) {
|
||||
var absStr = langsToLinearize[i].getAttribute("title");
|
||||
var lin = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree(absStr, editorGrammar.abstract.startcat));
|
||||
lin = lin.substring(0,1).toUpperCase().concat(lin.substring(1))
|
||||
if (!langsToLinearize[i].firstChild) {
|
||||
var txt = document.createTextNode(lin);
|
||||
langsToLinearize[i].appendChild(txt);
|
||||
@@ -416,9 +422,10 @@ function applyLanguage() {
|
||||
}
|
||||
var actionsToLinearize = document.getElementById("actionsTable").getElementsByTagName("td");
|
||||
for (var i = 0, j = actionsToLinearize.length; i < j; i++) {
|
||||
if (actionsToLinearize[i].getAttribute("class") == "action") {
|
||||
if (actionsToLinearize[i].className == "action") {
|
||||
var absStr = actionsToLinearize[i].getAttribute("title");
|
||||
var lin = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree(absStr, editorGrammar.abstract.startcat));
|
||||
lin = lin.substring(0,1).toUpperCase().concat(lin.substring(1))
|
||||
if (!actionsToLinearize[i].firstChild) {
|
||||
var txt = document.createTextNode(lin);
|
||||
actionsToLinearize[i].appendChild(txt);
|
||||
@@ -430,23 +437,28 @@ function applyLanguage() {
|
||||
}
|
||||
var messageToLinearize = document.getElementById("refgenRefRandom");
|
||||
if (messageToLinearize) {
|
||||
messageToLinearize.firstChild.firstChild.nodeValue = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("RandomlyCommand Select IndefSgDet Refinement", editorGrammar.abstract.startcat));
|
||||
var msg = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("RandomlyCommand Select IndefSgDet Refinement", editorGrammar.abstract.startcat));
|
||||
messageToLinearize.firstChild.firstChild.nodeValue = msg.substring(0,1).toUpperCase().concat(msg.substring(1));
|
||||
}
|
||||
var messageToLinearize = document.getElementById("nextRefsNext");
|
||||
if (messageToLinearize) {
|
||||
messageToLinearize.firstChild.firstChild.nodeValue = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("CommandAdj Show DefSgDet Next Page", editorGrammar.abstract.startcat));
|
||||
var msg = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("CommandAdj Show DefSgDet Next Page", editorGrammar.abstract.startcat));
|
||||
messageToLinearize.firstChild.firstChild.nodeValue = msg.substring(0,1).toUpperCase().concat(msg.substring(1));
|
||||
}
|
||||
messageToLinearize = document.getElementById("nextRefsPrevious");
|
||||
if (messageToLinearize) {
|
||||
messageToLinearize.firstChild.firstChild.nodeValue = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("CommandAdj Show DefSgDet Previous Page", editorGrammar.abstract.startcat));
|
||||
if (messageToLinearize) {
|
||||
var msg = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("CommandAdj Show DefSgDet Previous Page", editorGrammar.abstract.startcat));
|
||||
messageToLinearize.firstChild.firstChild.nodeValue = msg.substring(0,1).toUpperCase().concat(msg.substring(1));
|
||||
}
|
||||
var messageToLinearize = document.getElementById("nextWrapsNext");
|
||||
if (messageToLinearize) {
|
||||
messageToLinearize.firstChild.firstChild.nodeValue = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("CommandAdj Show DefSgDet Next Page", editorGrammar.abstract.startcat));
|
||||
var msg = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("CommandAdj Show DefSgDet Next Page", editorGrammar.abstract.startcat));
|
||||
messageToLinearize.firstChild.firstChild.nodeValue = msg.substring(0,1).toUpperCase().concat(msg.substring(1));
|
||||
}
|
||||
messageToLinearize = document.getElementById("nextWrapsPrevious");
|
||||
if (messageToLinearize) {
|
||||
messageToLinearize.firstChild.firstChild.nodeValue = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("CommandAdj Show DefSgDet Previous Page", editorGrammar.abstract.startcat));
|
||||
var msg = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("CommandAdj Show DefSgDet Previous Page", editorGrammar.abstract.startcat));
|
||||
messageToLinearize.firstChild.firstChild.nodeValue = msg.substring(0,1).toUpperCase().concat(msg.substring(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,12 +485,12 @@ function showActions(caption) {
|
||||
actions.push(createAction("Delete", "unavailable", "SingleWordCommand Delete", "D"));
|
||||
actions.push(createAction("Refine", "action", "SingleWordCommand Refine", "R"));
|
||||
actions.push(createAction("Replace", "unavailable", "SingleWordCommand Replace", "E"));
|
||||
actions.push(createAction("Wrap", "unavailable", "SingleWordCommand Wrap", "W"));
|
||||
for (var i in grammar.concretes) {
|
||||
actions.push(createAction("Wrap", "unavailable", "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"));
|
||||
} else { actions.push(createAction("Parse", "unavailable", "Command Parse IndefSgDet String_N", "P")); }
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (node.caption) {
|
||||
@@ -529,18 +541,21 @@ function clickRefine(actName) {
|
||||
switch(node.type)
|
||||
{
|
||||
case "String":
|
||||
newType = prompt(editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("Command Enter IndefSgDet String_N", editorGrammar.abstract.startcat)),'String');
|
||||
var msg = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("Command Enter IndefSgDet String_N", editorGrammar.abstract.startcat));
|
||||
newType = prompt(msg.substring(0,1).toUpperCase().concat(msg.substring(1)),'String');
|
||||
if (!newType) { newType = "AutoString"; }
|
||||
break;
|
||||
case "Int":
|
||||
while (isNaN(newType) || (newType && newType.indexOf(".") != -1)) {
|
||||
newType = prompt(editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("Command Enter IndefSgDet Integer_N", editorGrammar.abstract.startcat)),'Int');
|
||||
var msg = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("Command Enter IndefSgDet Integer_N", editorGrammar.abstract.startcat));
|
||||
newType = prompt(msg.substring(0,1).toUpperCase().concat(msg.substring(1)),'Int');
|
||||
}
|
||||
if (!newType) { newType = "8"; }
|
||||
break;
|
||||
case "Float":
|
||||
while (isNaN(newType)) {
|
||||
newType = prompt(editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("Command Enter IndefSgDet Float_N", editorGrammar.abstract.startcat)),'Float');
|
||||
var msg = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("Command Enter IndefSgDet Float_N", editorGrammar.abstract.startcat));
|
||||
newType = prompt(msg.substring(0,1).toUpperCase().concat(msg.substring(1)),'Float');
|
||||
}
|
||||
if (!newType) { newType = "8.0"; }
|
||||
if (newType.indexOf(".") == -1) { newType += ".0"; }
|
||||
@@ -553,7 +568,7 @@ function clickRefine(actName) {
|
||||
}
|
||||
if (!grammar.abstract.types[newTypeCat]) {
|
||||
grammar.abstract.addType(newTypeCat, [], node.type);
|
||||
for (var i in grammar.concretes) {
|
||||
for (var i in grammar.concretes) {
|
||||
grammar.concretes[i].addRule(newTypeCat, function(cs){ return new Arr(new Str(newType));});
|
||||
}
|
||||
}
|
||||
@@ -593,7 +608,6 @@ function pushUndoClearRedo() {
|
||||
|
||||
// Gets the refinements to display
|
||||
function showRefinements(nodeName) {
|
||||
// var refs = getAvailableRefinements(nodeName);
|
||||
var refs = getAvailableRefinements(nodeName, abstractTree, grammar);
|
||||
var rowsPerPage = 9;
|
||||
var pages = Math.floor(refs.length / rowsPerPage);
|
||||
@@ -623,7 +637,7 @@ function showRefinements(nodeName) {
|
||||
refinements.push("</table>");
|
||||
return refinements.join("");
|
||||
}
|
||||
|
||||
|
||||
// Creates an HTML representation of a Refinement/Wrap
|
||||
function ref_wrapToHtml(funct, name, className, arg, hotKeyPos, caption) {
|
||||
var ref_wrapHtml = new Array();
|
||||
@@ -755,7 +769,7 @@ function selectNextMeta() {
|
||||
nodeClick(pathToNextMeta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Expands the ascendants of a given node
|
||||
function expandAscendants(nodeName) {
|
||||
var nodePath = nodeName.split("-");
|
||||
@@ -780,7 +794,7 @@ function clickPaste(actName) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// When the "Delete" action is selected, deletes the selected node
|
||||
function clickDelete(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
@@ -794,7 +808,7 @@ function clickDelete(actName) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// When the "Replace" action is selected, replaces the selected node with another refinement
|
||||
function clickReplace(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
@@ -822,7 +836,8 @@ function clickWrap(actName) {
|
||||
var wrappers = showWrappers(node.caption);
|
||||
document.getElementById("refFrame").innerHTML = wrappers;
|
||||
if (wrappers.length <= 31) {
|
||||
alert(editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("ErrorMessage Available Wrapper", editorGrammar.abstract.startcat)));
|
||||
var lin = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("ErrorMessage Available Wrapper", editorGrammar.abstract.startcat));
|
||||
alert(lin.substring(0,1).toUpperCase().concat(lin.substring(1)));
|
||||
document.getElementById("actFrame").innerHTML = showActions();
|
||||
nodeClick(selectedNode);
|
||||
}
|
||||
@@ -834,7 +849,6 @@ function clickWrap(actName) {
|
||||
function showWrappers(nodeCaption) {
|
||||
var nodeType = grammar.abstract.types[nodeCaption].cat;
|
||||
var rowsPerPage = 10;
|
||||
// var availWrappers = getAvailableWrappers(nodeType);
|
||||
var availWrappers = getAvailableWrappers(nodeType, grammar, selectedNode);
|
||||
var pages = Math.floor(availWrappers.length / rowsPerPage);
|
||||
var upperLimit;
|
||||
@@ -860,7 +874,7 @@ function showWrappers(nodeCaption) {
|
||||
wrappers.push("</table>");
|
||||
return wrappers.join("");
|
||||
}
|
||||
|
||||
|
||||
// Creates the function to be used by a "numeric" hot key
|
||||
function mkWrapHotKey(wrapName, argPos) {
|
||||
return function() { if (document.getElementById("wrap" + wrapName)) { wrapClick(wrapName, argPos); } }
|
||||
@@ -876,15 +890,16 @@ function mkWrapNextRefsHotKey(wrapName) {
|
||||
function clickParse(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
highlightSelectedAction(actName);
|
||||
var node = getNode(selectedNode, myTree);
|
||||
var node = getNode(selectedNode, myTree);
|
||||
if (selectedNode) {
|
||||
refPageCounter = 0;
|
||||
parseTrees = undefined;
|
||||
var string = prompt(editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("Command Enter IndefSgDet String_N", editorGrammar.abstract.startcat)),'String');
|
||||
if (string || string == "") {
|
||||
for (var i in grammar.concretes) {
|
||||
var msg = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("Command Enter IndefSgDet String_N", editorGrammar.abstract.startcat));
|
||||
var string = prompt(msg.substring(0,1).toUpperCase().concat(msg.substring(1)),'String');
|
||||
if (string || string == "") {
|
||||
for (var i in grammar.concretes) {
|
||||
parseTrees = grammar.concretes[i].parser.parseString(string, node.cat);
|
||||
if (parseTrees.length == 1) {
|
||||
if (parseTrees.length == 1) {
|
||||
pushUndoClearRedo();
|
||||
abstractTree = insertNode(abstractTree, selectedNode, "0", grammar.abstract.copyTree(grammar.abstract.handleLiterals(parseTrees[0], node.cat)));
|
||||
document.getElementById("actFrame").innerHTML = showActions();
|
||||
@@ -895,10 +910,11 @@ function clickParse(actName) {
|
||||
} else if (parseTrees.length > 1) {
|
||||
document.getElementById("refFrame").innerHTML = showTrees();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { nodeClick(selectedNode); return false; }
|
||||
alert(editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("ErrorMessage Available Tree", editorGrammar.abstract.startcat)));
|
||||
var lin = editorGrammar.concretes[selectedLanguage].linearize(editorGrammar.abstract.parseTree("ErrorMessage Available Tree", editorGrammar.abstract.startcat));
|
||||
alert(lin.substring(0,1).toUpperCase().concat(lin.substring(1)));
|
||||
}
|
||||
nodeClick(selectedNode);
|
||||
}
|
||||
@@ -965,7 +981,7 @@ function clickRandomNode(actName) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// When the "RandomTree" action is selected, refines the tree at random
|
||||
function clickRandomTree(actName) {
|
||||
if (document.getElementById(actName).className == "action") {
|
||||
@@ -980,7 +996,6 @@ function clickRandomTree(actName) {
|
||||
function refClick(refName) {
|
||||
if (selectedNode) {
|
||||
if (refName == "genRefRandom") {
|
||||
// var refs = getAvailableRefinements(selectedNode);
|
||||
var refs = getAvailableRefinements(selectedNode, abstractTree, grammar);
|
||||
refName = refs[Math.floor(refs.length * Math.random())];
|
||||
}
|
||||
@@ -991,7 +1006,7 @@ function refClick(refName) {
|
||||
concludeAction();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Creates a tree from an abstract tree
|
||||
function treeFromAbstract(abstractNode, name) {
|
||||
var node = new treeNode(name, abstractNode.name);
|
||||
@@ -1040,7 +1055,7 @@ function wrapClick(wrapName, argPos) {
|
||||
|
||||
// Wraps a refinement around a node
|
||||
function treeClick(i) {
|
||||
if (selectedNode) {
|
||||
if (selectedNode) {
|
||||
pushUndoClearRedo();
|
||||
var node = getNode(selectedNode, myTree);
|
||||
var tempNode = grammar.abstract.copyTree(grammar.abstract.handleLiterals(parseTrees[i], node.cat));
|
||||
@@ -1090,11 +1105,11 @@ function nextTreesClick(treeName) {
|
||||
clearHotKeys();
|
||||
document.getElementById("refFrame").innerHTML = showTrees();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* ---------- GUI independent functions to handle syntax editing ---------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* ---------- GUI independent functions to handle syntax editing ---------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
// Gets the node rooted at the indicated path (route) in the tree absNode
|
||||
function getNodeFromAbstract(absNode, route, currRoute) {
|
||||
if (route == currRoute) {
|
||||
@@ -1107,7 +1122,7 @@ function getNodeFromAbstract(absNode, route, currRoute) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Gets the first metavariable from the abstract tree rooted at the path route
|
||||
function getNextMetaFromAbstract(node, route) {
|
||||
if (node.isMeta()) { return route; }
|
||||
@@ -1116,7 +1131,7 @@ function getNextMetaFromAbstract(node, route) {
|
||||
if (found) { return found; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Inserts the node into the abstract tree absNode at the path route
|
||||
function insertNode(absNode, route, currRoute, node) {
|
||||
if (route == currRoute) {
|
||||
@@ -1129,7 +1144,7 @@ function insertNode(absNode, route, currRoute, node) {
|
||||
return absNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Deletes the node rooted at the path route from the abstract tree absNode
|
||||
function deleteNode(absNode, route, currRoute) {
|
||||
if (route == currRoute) {
|
||||
@@ -1142,8 +1157,8 @@ function deleteNode(absNode, route, currRoute) {
|
||||
return absNode;
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the available refinements for the node nodeName, which is in the tree
|
||||
|
||||
// Gets the available refinements for the node nodeName, which is in the tree
|
||||
// abstractTree, from those found in the grammar.
|
||||
function getAvailableRefinements(nodeName, abstractTree, grammar) {
|
||||
var node = getNodeFromAbstract(abstractTree, nodeName, "0");
|
||||
@@ -1156,8 +1171,8 @@ function getAvailableRefinements(nodeName, abstractTree, grammar) {
|
||||
}
|
||||
return refinements;
|
||||
}
|
||||
|
||||
// It refines the node rooted at the path route in the abstract tree absNode
|
||||
|
||||
// It refines the node rooted at the path route in the abstract tree absNode
|
||||
// with the refinement refName. Returns the refined abstract tree.
|
||||
function refineAbstractTree(absNode, route, currRoute, refName) {
|
||||
if (route == currRoute && absNode.isMeta()) {
|
||||
@@ -1170,17 +1185,17 @@ function refineAbstractTree(absNode, route, currRoute, refName) {
|
||||
return absNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Creates a node of type refName object with the appropriate number of arguments
|
||||
function createRefinement(refName) {
|
||||
var newRef = new Fun(refName);
|
||||
var newRef = new Fun(refName);
|
||||
for (var i = 0, j = grammar.abstract.types[refName].args.length; i < j; i++) {
|
||||
newRef.setArg(i, new Fun("?"));
|
||||
}
|
||||
return newRef;
|
||||
}
|
||||
|
||||
// Gets the available wrappers for a node of type nodeType found in the grammar
|
||||
|
||||
// Gets the available wrappers for a node of type nodeType found in the grammar
|
||||
function getAvailableWrappers(nodeType, grammar, top) {
|
||||
var wrappers = new Array();
|
||||
for (var fun in grammar.abstract.types) {
|
||||
@@ -1200,11 +1215,11 @@ function getAvailableWrappers(nodeType, grammar, top) {
|
||||
}
|
||||
return wrappers;
|
||||
}
|
||||
|
||||
// Instantiates metavariables found in the tree abstractTree with refinements
|
||||
|
||||
// Instantiates metavariables found in the tree abstractTree with refinements
|
||||
// selected at random from those found in the grammar
|
||||
function fillSubTree(abstractTree, grammar) {
|
||||
while (!abstractTree.isComplete()) {
|
||||
function fillSubTree(abstractTree, grammar) {
|
||||
while (!abstractTree.isComplete()) {
|
||||
var nodeToRefine = getNextMetaFromAbstract(abstractTree, "0");
|
||||
if (nodeToRefine) {
|
||||
var refs = getAvailableRefinements(nodeToRefine, abstractTree, grammar);
|
||||
@@ -1247,6 +1262,6 @@ function fillSubTree(abstractTree, grammar) {
|
||||
abstractTree = grammar.abstract.annotate(abstractTree, grammar.abstract.startcat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return abstractTree;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,12 +187,6 @@ Int.prototype.setTag = function(tag) { if (!this.tag) { this.tag = tag; } };
|
||||
|
||||
/* Type annotation */
|
||||
|
||||
/*
|
||||
function Abstract(startcat) {
|
||||
this.types = new Array();
|
||||
this.startcat = startcat;
|
||||
}
|
||||
*/
|
||||
function GFAbstract(startcat, types) {
|
||||
this.startcat = startcat;
|
||||
this.types = types;
|
||||
@@ -275,15 +269,9 @@ function Type(args, cat) {
|
||||
}
|
||||
|
||||
/* Linearization */
|
||||
/*
|
||||
function Concrete(abstr) {
|
||||
this.abstr = abstr;
|
||||
this.rules = new Array();
|
||||
this.parser = undefined;
|
||||
}
|
||||
*/
|
||||
|
||||
function GFConcrete(flags, rules, parser) {
|
||||
this.flags = flags;
|
||||
this.flags = flags;
|
||||
this.rules = rules;
|
||||
if (parser) {
|
||||
this.parser = parser;
|
||||
@@ -761,7 +749,7 @@ function rangeConcatLin (lin1, lin2) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Performs range concatenation on a linarization row
|
||||
// Performs range concatenation on a linearization row
|
||||
function rangeConcatLins (lins) {
|
||||
var newLins = new Array();
|
||||
newLins.push(lins.shift());
|
||||
@@ -779,7 +767,7 @@ function rangeConcatLins (lins) {
|
||||
return newLins;
|
||||
}
|
||||
|
||||
// Performs range restriction on an element of a linarization row
|
||||
// Performs range restriction on an element of a linearization row
|
||||
// while keeping track of the tokens that have been used
|
||||
function rangeRestLinTerm(tokens, lin, rangesNotConsumed) {
|
||||
if (lin.id == "argProj") { return new Array(lin); }
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,234 +1,241 @@
|
||||
body {
|
||||
font-family:arial,helvetica,sans-serif;
|
||||
font-size:12px;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
width:740px;
|
||||
height:520px;
|
||||
margin:auto 50px;
|
||||
border:1px solid gray;
|
||||
padding:10px;
|
||||
|
||||
}
|
||||
|
||||
#absFrame {
|
||||
width:250px;
|
||||
height:250px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#conFrame {
|
||||
width:436px;
|
||||
height:250px;
|
||||
margin-left:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
white-space: normal;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#actFrame {
|
||||
width:250px;
|
||||
height:170px;
|
||||
margin-top:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#refFrame {
|
||||
width:436px;
|
||||
height:170px;
|
||||
margin-left:10px;
|
||||
margin-top:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#messageFrame {
|
||||
width:506px;
|
||||
height:15px;
|
||||
margin-top:10px;
|
||||
margin-right:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
#clipboardFrame {
|
||||
width:180px;
|
||||
height:15px;
|
||||
margin-top:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#tree {
|
||||
left: -10px;
|
||||
top: -10px;
|
||||
width: 230px;
|
||||
height: 250px;
|
||||
margin: 0px;
|
||||
padding: 10px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
ul {
|
||||
position: relative;
|
||||
list-style: none;
|
||||
margin-left: 20px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
li {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
img.tree-menu {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
a.tree:link, a.tree:visited, a.tree:active {
|
||||
color: black;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.tree:hover {
|
||||
color: blue;
|
||||
background-color: white;
|
||||
text-decoration: underline;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeSelected:link, a.treeSelected:visited, a.treeSelected:active {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeSelected:hover {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: underline;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeGray:link, a.treeGray:visited, a.treeGray:active {
|
||||
color: silver;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeGray:hover {
|
||||
color: silver;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
table.action, table.refinement, table.wrapper, table.tree, table.language {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
border-style: none;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0px;
|
||||
}
|
||||
|
||||
tr.selected {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
tr.unavailable, tr.closed {
|
||||
color: silver;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
tr.unavailable:hover {
|
||||
color: silver;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
tr.action, tr.refinement, tr.wrapper, tr.tree {
|
||||
color: black;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
tr.action:hover, tr.refinement:hover, tr.wrapper:hover, tr.tree:hover {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
td.action {
|
||||
width: 220px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
td.refinement, td.wrapper, td.tree {
|
||||
width: 515px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
td.hotKey {
|
||||
width: 30px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.language {
|
||||
color: black;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
td.language:hover {
|
||||
color: blue;
|
||||
background-color: white;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
td.selected {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
td.selected:hover {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 40px;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
span.normal {
|
||||
color: black;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
span.selected {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: none;
|
||||
}
|
||||
body {
|
||||
font-family:arial,helvetica,sans-serif;
|
||||
font-size:12px;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
width:740px;
|
||||
height:520px;
|
||||
margin:auto 50px;
|
||||
border:1px solid gray;
|
||||
padding:10px;
|
||||
|
||||
}
|
||||
|
||||
#absFrame {
|
||||
width:250px;
|
||||
height:250px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#conFrame {
|
||||
width:436px;
|
||||
height:250px;
|
||||
margin-left:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
white-space: normal;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#actFrame {
|
||||
width:250px;
|
||||
height:170px;
|
||||
margin-top:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#refFrame {
|
||||
width:436px;
|
||||
height:170px;
|
||||
margin-left:10px;
|
||||
margin-top:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#messageFrame {
|
||||
width:506px;
|
||||
height:15px;
|
||||
margin-top:10px;
|
||||
margin-right:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
#clipboardFrame {
|
||||
width:180px;
|
||||
height:15px;
|
||||
margin-top:10px;
|
||||
padding:10px;
|
||||
border:1px solid gray;
|
||||
float:left;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#tree {
|
||||
left: -10px;
|
||||
top: -10px;
|
||||
width: 250px;
|
||||
height: 250px;
|
||||
margin: 0px;
|
||||
padding: 10px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
ul {
|
||||
position: relative;
|
||||
list-style: none;
|
||||
margin-left: 20px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
li {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
img.tree-menu {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
a.tree:link, a.tree:visited, a.tree:active {
|
||||
color: black;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.tree:hover {
|
||||
color: blue;
|
||||
background-color: white;
|
||||
text-decoration: underline;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeSelected:link, a.treeSelected:visited, a.treeSelected:active {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeSelected:hover {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: underline;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeGray:link, a.treeGray:visited, a.treeGray:active {
|
||||
color: silver;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
a.treeGray:hover {
|
||||
color: silver;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
table.action, table.refinement, table.wrapper, table.tree, table.language {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
border-style: none;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0px;
|
||||
}
|
||||
|
||||
tr.selected {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
tr.unavailable, tr.closed {
|
||||
color: silver;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
tr.unavailable:hover {
|
||||
color: silver;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
tr.action, tr.refinement, tr.wrapper, tr.tree {
|
||||
color: black;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
tr.action:hover, tr.refinement:hover, tr.wrapper:hover, tr.tree:hover {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
}
|
||||
|
||||
td.action {
|
||||
width: 220px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
td.refinement, td.wrapper, td.tree {
|
||||
width: 515px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
td.hotKey {
|
||||
width: 30px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td.language {
|
||||
color: black;
|
||||
background-color: white;
|
||||
margin: 1px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
td.language:hover {
|
||||
color: blue;
|
||||
background-color: white;
|
||||
text-decoration: underline;
|
||||
margin: 1px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
td.selected {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
margin: 1px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
td.selected:hover {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: underline;
|
||||
margin: 1px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
span.normal {
|
||||
color: black;
|
||||
background-color: white;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
span.selected {
|
||||
color: white;
|
||||
background-color: #3366CC;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user