2023-11-26 15:54:17 -08:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
2023-11-26 16:25:23 -08:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
2023-11-26 15:54:17 -08:00
|
|
|
<title>Main</title>
|
|
|
|
<script type="module" src="https://unpkg.com/@navsnpm/katex-expression/dist/katex-expression/katex-expression.esm.js"></script>
|
|
|
|
<script nomodule="" src="https://unpkg.com/@navsnpm/katex-expression/dist/katex-expression/katex-expression.js"></script>
|
|
|
|
<style>body { padding: 0; margin: 0; }</style>
|
2023-11-26 16:25:23 -08:00
|
|
|
<style>
|
|
|
|
textarea {
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
height: 10em;
|
|
|
|
resize: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
input[type="text"] {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.rule-list {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.rule-list katex-expression {
|
|
|
|
margin-left: .5em;
|
|
|
|
margin-right: .5em;
|
|
|
|
flex-grow: 1;
|
|
|
|
flex-basis: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.elm-root {
|
|
|
|
max-width: 800px;
|
|
|
|
margin: auto;
|
|
|
|
padding: 1em;
|
|
|
|
border: 1px solid #c3c3c3;
|
|
|
|
border-radius: 0.5em;
|
2023-11-26 16:32:27 -08:00
|
|
|
margin-top: 1em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.elm-root h2 {
|
|
|
|
margin-bottom: 0.5em;
|
2023-11-26 20:48:48 -08:00
|
|
|
font-family: sans-serif;
|
|
|
|
font-weight: normal;
|
2023-11-26 16:25:23 -08:00
|
|
|
}
|
|
|
|
</style>
|
2023-11-26 15:54:17 -08:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<div id="elm"></div>
|
|
|
|
<script src="index.js"></script>
|
2024-09-07 22:23:04 -07:00
|
|
|
<script src="language.js"></script>
|
2023-11-26 15:54:17 -08:00
|
|
|
<script>
|
2024-09-07 22:23:04 -07:00
|
|
|
const objectLang = Elm.Bergamot.ObjectLanguage.init({});
|
|
|
|
|
2024-09-07 21:06:57 -07:00
|
|
|
(async () => {
|
|
|
|
var rulesResponse = await fetch("./demorules.bergamot");
|
|
|
|
var rules = await rulesResponse.text();
|
|
|
|
var renderRulesResponse = await fetch("./renderrules.bergamot");
|
|
|
|
var renderRules = await renderRulesResponse.text();
|
|
|
|
console.log(rules);
|
|
|
|
var app = Elm.Main.init({
|
|
|
|
node: document.getElementById('elm'),
|
|
|
|
flags: {
|
|
|
|
inputModes: {
|
2024-09-07 22:23:04 -07:00
|
|
|
"Language Term": { "custom": "langterm" },
|
2024-09-07 21:06:57 -07:00
|
|
|
"Query": "query",
|
|
|
|
},
|
|
|
|
inputRules: "PromptConverter @ prompt(type(empty, ?term, ?t)) <- input(?term);",
|
2024-09-07 21:43:02 -07:00
|
|
|
input: "type(empty, app(abs(x, number, var(x)), lit(1)), ?tau)",
|
2024-09-07 21:06:57 -07:00
|
|
|
renderRules: renderRules, rules: rules
|
|
|
|
}
|
|
|
|
});
|
2024-09-07 21:43:02 -07:00
|
|
|
|
2024-09-07 22:23:04 -07:00
|
|
|
objectLang.ports.parsedString.subscribe(({ string, term }) => {
|
|
|
|
if (term !== null) {
|
|
|
|
const query = `type(empty, ${term}, ?tau)`;
|
2024-09-15 10:21:38 -07:00
|
|
|
app.ports.receiveConverted.send({ input: string, result: { query } });
|
2024-09-07 22:29:32 -07:00
|
|
|
} else {
|
2024-09-15 10:21:38 -07:00
|
|
|
app.ports.receiveConverted.send({ input: string, result: { error: "Unable to parse object language term" } });
|
2024-09-07 22:23:04 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-09-07 21:43:02 -07:00
|
|
|
app.ports.convertInput.subscribe(({ mode, input }) => {
|
2024-09-07 22:23:04 -07:00
|
|
|
objectLang.ports.parseString.send(input);
|
2024-09-07 21:43:02 -07:00
|
|
|
});
|
2024-09-07 21:06:57 -07:00
|
|
|
})();
|
2023-11-26 15:54:17 -08:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|