SimpleScript is a tiny experimental language inspired by JavaScript, designed to be easier to read and write. It comes with:
- A browser interpreter (
simpleScript.js
) so you can run.ss
files in an HTML page. - A VS Code extension (
SimpleScript-Extension/
) that adds syntax highlighting, snippets and hover tooltips for.ss
files.
# Temporary memory (like `let` in JS)
temporary.memory;username = "mattialobrano" end
# Permanent memory (like `const` in JS)
permanent.memory;username = "mattiabanano" end
# Shortcuts
temp.mem;count = 42 end
perm.mem;pi = 3.14 end
# Popup (alert in the browser)
popup "Hello from SimpleScript!" end
# If statements
if count > 10 then
popup "Big number!" end
end
# Loops
repeat 3 times
show "Hello!" end
end
Equivalent JavaScript for some constructs:
let username = "mattialobrano";
const username = "mattiabanano";
let count = 42;
const pi = 3.14;
alert("Hello from SimpleScript!");
if (count > 10) {
alert("Big number!");
}
for (let i = 0; i < 3; i++) {
console.log("Hello!");
}
Folder layout
SimpleScript/
├─ index.html
├─ simpleScript.js ← the interpreter (must define runSimpleScript)
└─ program.ss ← your SimpleScript program
Important: Browsers don’t execute
.ss
files natively.simpleScript.js
must read and execute them. The examples below show two correct ways.
Create index.html
:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>SimpleScript Test</title>
<script src="simpleScript.js"></script>
</head>
<body>
<h1>SimpleScript demo</h1>
<div id="output"></div>
<script>
// fetch the external .ss file and run it through the interpreter
fetch('program.ss')
.then(res => res.text())
.then(code => runSimpleScript(code, document.getElementById('output')))
.catch(err => console.error('Failed to load SimpleScript file:', err));
</script>
</body>
</html>
Run: serve the folder over HTTP (Live Server in VS Code, python -m http.server
, or http-server
) and open index.html
. The interpreter will fetch program.ss
and execute it.
Option B — embed SimpleScript inside HTML (inline) or use a <script type="text/simplescript" src="...">
loader
You can embed code inside an HTML page or use a <script type="text/simplescript">
tag and a small loader which supports both inline content and an external src
. This pattern lets you write SimpleScript directly in HTML while still using the interpreter.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Inline SimpleScript</title>
<script src="simpleScript.js"></script>
</head>
<body>
<script type="text/simplescript" id="inlineScript">
temp.mem;score = 5 end
show score
popup "Hello inline!"
</script>
<!-- Or reference an external file as src (loader will fetch it) -->
<script type="text/simplescript" src="program.ss"></script>
<script>
// Loader: finds script[type="text/simplescript"], supports inline or external src
document.querySelectorAll('script[type="text/simplescript"]').forEach(async (el) => {
const output = document.createElement('div');
document.body.appendChild(output);
const src = el.getAttribute('src');
if (src) {
// fetch external .ss file (must be served over HTTP)
const res = await fetch(src);
const code = await res.text();
runSimpleScript(code, output);
} else {
// inline content
runSimpleScript(el.textContent, output);
}
});
</script>
</body>
</html>
Note: If you use external src="program.ss"
, you must serve the files over HTTP (Live Server or similar). file://
pages often block fetch()
.
Save this as program.ss
:
temp.mem;playerName = "Mattia" end
temp.mem;score = 5 end
temp.mem;bonus = 10 end
temp.mem;total = score + bonus end
show playerName
show "Total Score: "
show total
if total > 10 then
popup "You won the game!" end
end
repeat 3 times
popup "Repeating popup" end
end
The SimpleScript-Extension/
folder contains the VS Code editor support: grammar, snippets and hover tooltips.
- Syntax highlighting for
.ss
files - Snippets for
temp.mem;
,perm.mem;
,if
,repeat
,popup
,show
- Hover tooltips for keywords
-
Install
vsce
if you haven't:npm install -g vsce
-
From inside
SimpleScript-Extension/
run:vsce package
This will produce a
.vsix
file (e.g.simplescript-0.1.0.vsix
). -
In VS Code: Extensions →
...
menu → Install from VSIX... → choose the.vsix
file. -
Reload VS Code. Open a
.ss
file — the language should show as SimpleScript in the status bar.
Troubleshooting: Make sure package.json
contains:
"activationEvents": ["onLanguage:simplescript"],
"main": "./hover.js"
and that the languages
and grammars
configure .ss
and point to syntaxes/simplescript.tmLanguage.json
.
simpleScript.js
should export/definerunSimpleScript(code, outputEl)
— the README examples rely on that function name.- When testing locally, use Live Server (VS Code extension) or
python -m http.server
to avoidfetch()
blocking issues. - The extension only helps editing (.ss grammar/snippets/hover). It does not execute
.ss
itself; execution is done withsimpleScript.js
in the browser (or a Node runner you create).
- Functions
- Better expression parsing (avoid
eval
where possible) -
while
andfor
- Publish VS Code extension to Marketplace
- Unit tests for the interpreter
MIT — feel free to use, modify and share. Add a LICENSE
file if you want.
- Put
index.html
,simpleScript.js
andprogram.ss
in the same folder. - Start a simple HTTP server (Live Server or
python -m http.server
). - Open
index.html
in the browser. - Edit
program.ss
, refresh the page — your SimpleScript runs.