Skip to content

Commit

Permalink
Обработка TO-(C|JS|JAVA|MOD|MODEF)
Browse files Browse the repository at this point in the history
  • Loading branch information
ComdivByZero authored and ComdivByZero committed Jan 3, 2022
1 parent 456800b commit 28970e3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
6 changes: 6 additions & 0 deletions demo-server/index.html
Expand Up @@ -44,6 +44,12 @@
VostokBox.addRootRunner(box, 'Hello.Come; Hello.Gone');
VostokBox.addRunner(box, 'Hello.Come');
VostokBox.addRunner(box, 'Hello.Gone');
VostokBox.addRunner(box, ':INFO');
VostokBox.addRunner(box, ':LIST');
VostokBox.addRunner(box, ':INFO log');
VostokBox.addRunner(box, ':TO-C');
VostokBox.addRunner(box, ':TO-JAVA');
VostokBox.addRunner(box, ':TO-JS');
</script>

</body>
Expand Down
7 changes: 5 additions & 2 deletions demo-server/server.go
Expand Up @@ -39,7 +39,8 @@ const (
webHelp =
"/INFO - show this help\n" +
"/LIST - list available modules\n" +
"/INFO ModuleName - show info about module\n"
"/INFO ModuleName - show info about module\n" +
"/TO-(C|JS|JAVA) - convert code to appropriate language\n"

teleHelp = webHelp +
`/O7: log.s("Script mode")` +
Expand Down Expand Up @@ -215,7 +216,9 @@ func toLang(source, vcmd string) (translated []byte) {
)
tmp, name, _, source, _ = saveSource(source, "");
cmd = exec.Command("vostok/result/ost", vcmd, name, "-",
"-m", tmp, "-infr", "vostok", "-cyrillic", "-multi-errors");
"-m", tmp, "-infr", "vostok", "-cyrillic-same", "-multi-errors", "-C11",
"-init", "noinit", "-no-array-index-check", "-no-nil-check",
"-no-arithmetic-overflow-check");
translated, _ = cmd.CombinedOutput();
os.RemoveAll(tmp);
return
Expand Down
30 changes: 18 additions & 12 deletions demo-server/vostokbox.js
Expand Up @@ -70,7 +70,7 @@ var VostokBox;
}

function addRunner(box, command, root) {
var div, inp, run, addel;
var div, inp, run, add, del;
div = box.doc.createElement('div');
inp = box.doc.createElement('input', 'type="text"');
inp.className = 'vostokbox-command-line';
Expand All @@ -80,23 +80,29 @@ var VostokBox;
run.onclick = function() {
requestRun(box, inp.value);
};
addel = box.doc.createElement('button');
add = box.doc.createElement('button');
box.script = inp;
add.innerText = 'Add';
add.onclick = function() {
addRunner(box, inp.value, false);
};
div.appendChild(inp);
div.appendChild(run);
div.appendChild(add);

del = box.doc.createElement('button');
if (root) {
box.script = inp;
addel.innerText = 'Add';
addel.onclick = function() {
addRunner(box, inp.value, false);
del.innerText = 'Cln';
del.onclick = function() {
box.log.innerHTML = '';
};
} else {
addel.innerText = 'Del';
addel.onclick = function() {
del.innerText = 'Del';
del.onclick = function() {
box.runners.removeChild(div);
};
}

div.appendChild(inp);
div.appendChild(run);
div.appendChild(addel);
div.appendChild(del);

box.runners.appendChild(div);
}
Expand Down

0 comments on commit 28970e3

Please sign in to comment.