This commit is contained in:
abbie 507131 2025-01-05 02:45:56 +00:00
parent 0cf29a0fd7
commit 95ff6a5e4a
Signed by: threeoh6000
GPG key ID: 801FE4AD456E922C
4 changed files with 20 additions and 13 deletions

View file

@ -6,7 +6,7 @@ enum Token {
Number(num:Int); Number(num:Int);
} }
class Parser { class Hexat {
static public function main() { static public function main() {
var button = document.querySelector(".runButton"); var button = document.querySelector(".runButton");
button.onclick = (event) -> runButton(); button.onclick = (event) -> runButton();

7
README.md Normal file
View file

@ -0,0 +1,7 @@
# Hexat
Haxe calculator/language
## Build instructions
```
haxe --main Hexat --js script.js
```

View file

@ -1,13 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en-GB"> <html lang="en-GB">
<head> <head>
<title>HTML Boilerplate</title> <title>Hexat</title>
<link rel="stylesheet" type="text/css" href="style.css" /> <link rel="stylesheet" type="text/css" href="style.css" />
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
</head> </head>
<body> <body>
<h1>hxcalc</h1> <h1>Hexat</h1>
<textarea class="source"></textarea> <textarea class="source"></textarea>
<button class="runButton">Run</button><br/><br/> <button class="runButton">Run</button><br/><br/>
<div class="output">Output: </div> <div class="output">Output: </div>

View file

@ -1,27 +1,26 @@
// Generated by Haxe 4.3.6 // Generated by Haxe 4.3.6
(function ($global) { "use strict"; (function ($global) { "use strict";
var $estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_; var $estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_;
Math.__name__ = true;
var Token = $hxEnums["Token"] = { __ename__:true,__constructs__:null var Token = $hxEnums["Token"] = { __ename__:true,__constructs__:null
,Operation: ($_=function(op) { return {_hx_index:0,op:op,__enum__:"Token",toString:$estr}; },$_._hx_name="Operation",$_.__params__ = ["op"],$_) ,Operation: ($_=function(op) { return {_hx_index:0,op:op,__enum__:"Token",toString:$estr}; },$_._hx_name="Operation",$_.__params__ = ["op"],$_)
,Number: ($_=function(num) { return {_hx_index:1,num:num,__enum__:"Token",toString:$estr}; },$_._hx_name="Number",$_.__params__ = ["num"],$_) ,Number: ($_=function(num) { return {_hx_index:1,num:num,__enum__:"Token",toString:$estr}; },$_._hx_name="Number",$_.__params__ = ["num"],$_)
}; };
Token.__constructs__ = [Token.Operation,Token.Number]; Token.__constructs__ = [Token.Operation,Token.Number];
var Parser = function() { }; var Hexat = function() { };
Parser.__name__ = true; Hexat.__name__ = true;
Parser.main = function() { Hexat.main = function() {
var button = window.document.querySelector(".runButton"); var button = window.document.querySelector(".runButton");
button.onclick = function(event) { button.onclick = function(event) {
Parser.runButton(); Hexat.runButton();
}; };
}; };
Parser.runButton = function() { Hexat.runButton = function() {
var inputArea = window.document.querySelector(".source"); var inputArea = window.document.querySelector(".source");
var res = Parser.run(Parser.parse(inputArea.value)); var res = Hexat.run(Hexat.parse(inputArea.value));
var outputDisplay = window.document.querySelector(".output"); var outputDisplay = window.document.querySelector(".output");
outputDisplay.innerHTML = "Output: <pre>" + res.join(", ") + "</pre>"; outputDisplay.innerHTML = "Output: <pre>" + res.join(", ") + "</pre>";
}; };
Parser.parse = function(input) { Hexat.parse = function(input) {
var array = []; var array = [];
var i = 0; var i = 0;
var splits = input.split(" "); var splits = input.split(" ");
@ -39,7 +38,7 @@ Parser.parse = function(input) {
} }
return array; return array;
}; };
Parser.run = function(array) { Hexat.run = function(array) {
var stack = []; var stack = [];
var i = 0; var i = 0;
while(i < array.length) { while(i < array.length) {
@ -88,6 +87,7 @@ Parser.run = function(array) {
} }
return stack; return stack;
}; };
Math.__name__ = true;
var Std = function() { }; var Std = function() { };
Std.__name__ = true; Std.__name__ = true;
Std.parseInt = function(x) { Std.parseInt = function(x) {
@ -225,5 +225,5 @@ js_Boot.__string_rec = function(o,s) {
String.__name__ = true; String.__name__ = true;
Array.__name__ = true; Array.__name__ = true;
js_Boot.__toStr = ({ }).toString; js_Boot.__toStr = ({ }).toString;
Parser.main(); Hexat.main();
})({}); })({});