Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,3 @@ jobs:
project: "hcweb"
entrypoint: "main.ts"
root: "."


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,4 @@ dist
.yarn/install-state.gz
.pnp.*
/cov
/_fresh
7 changes: 2 additions & 5 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,16 @@
],
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.7.3/",
"@swanfactory/hclang": "jsr:@swanfactory/hclang@^0.6.7",
"@swanfactory/hclang": "jsr:@swanfactory/hclang@^0.6.9",
"preact": "https://esm.sh/preact@10.22.0",
"preact/": "https://esm.sh/preact@10.22.0/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1",
"tailwindcss": "npm:tailwindcss@3.4.17",
"tailwindcss/": "npm:/tailwindcss@3.4.17/",
"tailwindcss/plugin": "npm:/tailwindcss@3.4.17/plugin.js",
"$std/": "https://deno.land/std@0.216.0/"
},
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"nodeModulesDir": "auto"
"nodeModulesDir": "none"
}
5 changes: 1 addition & 4 deletions fresh.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { defineConfig } from "$fresh/server.ts";
import tailwind from "$fresh/plugins/tailwind.ts";

export default defineConfig({
plugins: [
tailwind(),
],
plugins: [],
});
43 changes: 23 additions & 20 deletions islands/Interpreter.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { useState } from "preact/hooks";
// import { execute } from "@swanfactory/hclang";

function evaluateCode(code: string): string {
console.log(`Evaluating code: ${code}`);
// console.log(execute);
try {
const result = code.toLocaleUpperCase();
const result = code.toUpperCase();
console.log(`Result: ${result}`);
return result.toString();
} catch (error: unknown) {
console.error(error);
Expand Down Expand Up @@ -30,28 +34,27 @@ export default function Interpreter() {
};

return (
<div className="flex flex-col gap-4">
<input
type="text"
<div>
<textarea
value={text}
onChange={(e) => {
setText((e.target as HTMLInputElement).value);
handleEvaluation((e.target as HTMLInputElement).value);
}}
className="px-4 py-2 border rounded"
onChange={(e) => setText((e.target as HTMLTextAreaElement).value)}
placeholder="Enter code to evaluate"
rows={10}
cols={50}
/>
{isLoading && <div>Evaluating...</div>}
{error && (
<div className="p-4 bg-red-100 text-red-700 rounded">
{error}
</div>
)}
{result && !error && (
<div className="p-4 bg-gray-100 rounded">
<pre className="font-mono">{result}</pre>
</div>
)}
<br />
<button onClick={() => handleEvaluation(text)} disabled={isLoading}>
Evaluate
</button>
<div>
{isLoading && <div>Evaluating...</div>}
{error && <div style={{ color: "red" }}>{error}</div>}
{result && !error && (
<div>
<pre>{result}</pre>
</div>
)}
</div>
</div>
);
}
21 changes: 17 additions & 4 deletions routes/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import type { PageProps } from "$fresh/server.ts";
export default function App({ Component }: PageProps) {
return (
<html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/styles.css" />
<title>HCLang Playground</title>
<link
rel="stylesheet"
href="https://www.w3.org/StyleSheets/Core/Steely"
/>
<style>
{`
button {
padding: 10px 20px;
border-radius: 10px;
font-size: 1.2em;
}
`}
</style>
</head>
<body>
<main>
<Component />
</main>
<footer className="site-footer text-sm text-gray-500">
<footer style={{ color: "gray", fontSize: "0.8em" }}>
<p>&copy; 2025 The Swan Factory</p>
</footer>
</body>
Expand Down
31 changes: 10 additions & 21 deletions routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,21 @@ import Interpreter from "../islands/Interpreter.tsx";
export default function Home() {
return (
<div>
<head>
<title>HCLang Playground</title>
</head>
<div className="max-w-4xl mx-auto p-4">
<h1 className="text-4xl font-bold mb-4">
Welcome to Homoiconic C!
</h1>

<p className="text-lg mb-4">
Homoiconic C ("HC") is a universal data format for computation.
</p>
<header>
<h1>Welcome to Homoiconic C!</h1>
<p>Homoiconic C ("HC") is a universal data format for computation.</p>
<a
className="text-blue-500 hover:underline mb-4 block text-2xl"
className="cheat-sheet"
href="https://ihack.us/2024/09/19/tsm-5-homoiconic-c-hc-syntax-cheat-sheet/"
target="_blank"
>
HC Cheat Sheet.
HC Cheat Sheet
</a>
<div className="mt-8 p-4 border rounded">
<h3 className="text-2xl font-bold mb-4">HCLang Interpreter</h3>
<Interpreter />
</div>
<p className="text-lg text-gray-750 mt-4">
Coming soon: subscribe to our mailing list.
</p>
</div>
</header>
<main className="interpreter-wrapper">
<h3>HCLang Interpreter</h3>
<Interpreter />
</main>
</div>
);
}
3 changes: 0 additions & 3 deletions static/styles.css

This file was deleted.

7 changes: 0 additions & 7 deletions tailwind.config.ts

This file was deleted.

14 changes: 7 additions & 7 deletions tests/hclang.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { execute } from '@swanfactory/hclang';
import { execute } from "@swanfactory/hclang";
import { describe, it } from "jsr:@std/testing/bdd";
import { expect } from "jsr:@std/expect";

// Example test case
describe('evaluate', () => {
it('should evaluate a simple expression', () => {
const result = execute('2 + 2');
expect(result).toBe(4);
});
});
describe("execute", () => {
it("should execute a simple expression", () => {
const result = execute("2 + 2");
expect(result).toBe("4");
});
});