Files
kraken/try.html
2020-09-13 19:03:44 -04:00

81 lines
2.9 KiB
HTML

<!doctype html>
<html lang="en-us">
<meta charset="UTF-8">
<head>
<style>
h1, h2 ,h3 { line-height:1.2; }
body {
max-width: 45em;
margin: 1em auto;
padding: 0 .62em;
font: 1.2em/1.62 sans-serif;
}
th { text-align: center; }
th, td { padding: 0.5em; }
table, td {
border: 1px solid #333;
text-align: right;
}
thead, tfoot {
background-color: #000;
color: #fff;
}
#try_editor { height: 70em; width: 70em; }
#try_output { height: 20em; width: 70em; }
</style>
</head>
<body>
<header><h2>Nathan Braswell's Current Programming Language / Compiler Research</h2></header>
Repository: <a title="Kraken on GitHub" href="https://github.com/limvot/kraken">https://github.com/limvot/kraken</a>
<h3> Try it:</h3>
<button onclick="executeKraken(try_editor.getValue(), 'try_output')"><b>Run</b></button> <br>
<div id="try_editor">; Of course
; Load for prelude so we get fun, lambda, if, quoting, etc
;(load-file "./k_prime_stdlib/prelude.kp")
; Load for method to get nicer lambda, objects, blocks, string interplation
;(load-file "./k_prime_stdlib/method.kp")
(println "Hello World")
; Just print 3
(println "Math works:" (+ 1 2))
</div>
<h4>Output:</h4>
<textarea id="try_output">Output will appear here</textarea>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/ace.min.js"></script>
<script>
ace.config.set('basePath', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/')
var try_editor = ace.edit("try_editor")
try_editor.session.setMode("ace/mode/clojure")
try_editor.setOption("displayIndentGuides", false)
try_editor.setShowPrintMargin(false)
if (window.location.hash) {
try_editor.setValue(decodeURIComponent(window.location.hash.slice(1)), -1)
}
var output_name = ""
var Module = {
noInitialRun: true,
onRuntimeInitialized: () => {
},
print: txt => {
document.getElementById(output_name).value += txt + "\n";
},
printErr: txt => {
document.getElementById(output_name).value += "STDERR:[" + txt + "]\n";
}
};
function executeKraken(code, new_output_name) {
window.location.hash = encodeURIComponent(code)
output_name = new_output_name
document.getElementById(new_output_name).value = "running...\n";
Module.callMain(["-C", code]);
}
</script>
<script type="text/javascript" src="k_prime.js"></script>
</body>
</html>