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
7 changes: 7 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-25.11

- name: Run interpreter tests
run: |
nix develop --command bash -c "
cd interpreter
npm run test
"

- name: Build site
env:
STEPCODE_ENV: production
Expand Down
10 changes: 9 additions & 1 deletion interpreter/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@

import fs from 'fs';
import readline from 'readline';
import { parse, step } from '../static/js/index.js';
import { Lexer } from './static/lexer.js';
import { Parser } from './static/parser.js';
import { step } from './static/interpreter.js';

function parse(input) {
const lexer = new Lexer(input);
const parser = new Parser(lexer.tokenize());
return parser.parse();
}

const file = process.argv[2];

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 9 additions & 1 deletion interpreter/tests/interpreter.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { test } from 'node:test';
import * as assert from 'node:assert';
import { step, parse } from '../../static/js/index.js';
import { Lexer } from '../static/lexer.js';
import { Parser } from '../static/parser.js';
import { step } from '../static/interpreter.js';

function parse(input) {
const lexer = new Lexer(input);
const parser = new Parser(lexer.tokenize());
return parser.parse();
}

test('Interpreter: basic assignment and arithmetic', () => {
const ast = parse(`
Expand Down
4 changes: 2 additions & 2 deletions interpreter/tests/parser.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test } from 'node:test';
import * as assert from 'node:assert';
import { Lexer } from '../../static/js/lexer.js';
import { Parser } from '../../static/js/parser.js';
import { Lexer } from '../static/lexer.js';
import { Parser } from '../static/parser.js';

test('Lexer: basic tokenization', () => {
const input = `n := 4
Expand Down
25 changes: 22 additions & 3 deletions src/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
</head>
<body>
<nav>
<a href="{index_path}"><h2>Index</h2></a>
<h3>Table of Contents</h3>
{nav_tree}
</nav>
Expand Down Expand Up @@ -226,7 +227,8 @@ def process_node(node, output_root, site_root, flat_tree, current_path=''):
os.makedirs(os.path.dirname(output_file), exist_ok=True)

css_relative_path = get_asset_path(node.path, 'static/base.css')
js_relative_path = get_asset_path(node.path, 'static/js/index.js')
js_relative_path = get_asset_path(node.path, 'static/index.js')
index_relative_path = get_asset_path(node.path, 'index.html')

nav_html = render_nav_tree(site_root, node.path)

Expand Down Expand Up @@ -262,6 +264,7 @@ def process_node(node, output_root, site_root, flat_tree, current_path=''):
content=node.page.render(),
css_path=css_relative_path,
js_path=js_relative_path,
index_path=index_relative_path,
nav_tree=nav_html,
navigation=navigation_html,
FOOTER=FOOTER,
Expand All @@ -281,8 +284,24 @@ def write_output(root_node: DirNode, output_path: str) -> None:
flat_tree = flatten_tree(root_node)
process_node(root_node, output_path, root_node, flat_tree)

static_dest = os.path.join(output_path, 'static')
os.makedirs(static_dest, exist_ok=True)

if os.path.exists('static'):
shutil.copytree('static', os.path.join(output_path, 'static'))
print('copied static directory')
for filename in ['base.css', 'index.js']:
src = os.path.join('static', filename)
if os.path.exists(src):
shutil.copy2(src, os.path.join(static_dest, filename))
print('copied base.css and index.js from static directory')
else:
print('Warning: static directory not found in root directory')

interpreter_static = os.path.join('interpreter', 'static')
if os.path.exists(interpreter_static):
for filename in os.listdir(interpreter_static):
src = os.path.join(interpreter_static, filename)
if os.path.isfile(src):
shutil.copy2(src, os.path.join(static_dest, filename))
print('copied interpreter files from interpreter/static')
else:
print('Warning: interpreter/static directory not found')
File renamed without changes.