TSL — Small Language for JavaScript
TSL (Time Script Language) is a small, simple programming language that compiles to JavaScript.
Designed for learning, game prototyping, and writing clean, readable code with minimal syntax.
Version: 1.0.0 | Status: Stable | Backend: JavaScript | Website: tsl.timeandtime.online
Simple syntax — colon (:) and indentation for blocks, no braces or keywords
Full compiler pipeline — Lexer → Parser → AST → Validator → Generator
JavaScript backend — generates clean, readable, valid JavaScript
Deterministic output — same source always produces the same JavaScript
Rich type support — numbers, strings, booleans, null, arrays, objects
Control flow — if/else, for, while, break, continue
Functions — declarations, parameters, return, recursion, closures
Error reporting — clear errors with filename, line, column, and source context
CLI tool — build, check, and run from the command line
100+ examples — algorithms, data structures, and game patterns
git clone https://github.com/TimeAndTimeStudio/TSL.git
cd TSL
No dependencies required. TSL runs on Node.js.
node src/cli.js hello.tsl
# Output to stdout
node src/cli.js build hello.tsl
# Write to file
node src/cli.js build hello.tsl -o hello.js
Run the generated JavaScript
node src/cli.js < file.tsl> # Compile and show generated JS
node src/cli.js build < file.tsl> # Build to stdout
node src/cli.js build < file.tsl> -o < output.js> # Build to file
node src/cli.js check < file.tsl> # Validate only
node src/cli.js --version # Show version
# Fibonacci
function fib(n):
if n <= 1:
return n
return fib(n - 1) + fib(n - 2)
for i in range(10):
print(fib(i))
Compiles to:
function fib ( n ) {
if ( n <= 1 ) {
return n ;
}
return fib ( n - 1 ) + fib ( n - 2 ) ;
}
for ( let i of range ( 10 ) ) {
console . log ( fib ( i ) ) ;
}
TSL Source
↓
Lexer → Tokens
↓
Parser → AST
↓
Validator → Valid AST
↓
Generator → JavaScript
↓
JavaScript → Runtime
Example
Description
dfs.tsl
Depth-first search
bfs.tsl
Breadth-first search
# Run all unit tests
npm test
# Run release test suite
cd release-test && node run-all-tests.js
Test results:
Suite
Status
AST
✓ Pass
Lexer
✓ Pass
Parser (expressions + statements)
✓ Pass
Validator
✓ Pass
Generator
✓ Pass
Variable Semantics
✓ Pass
Integration
✓ Pass
CLI
✓ Pass
tsl/
├── src/
│ ├── cli.js # Command-line interface
│ ├── compiler.js # Main compiler orchestrator
│ ├── lexer.js # Tokenizer
│ ├── parser.js # Expression & statement parser
│ ├── ast.js # AST node definitions
│ ├── validator.js # Semantic validation
│ ├── generator.js # JavaScript code generation
│ └── errors.js # Error types
├── examples/ # 100+ TSL examples
├── tests/ # Unit & integration tests
│ ├── ast/
│ ├── cli/
│ ├── generator/
│ ├── integration/
│ ├── lexer/
│ ├── parser/
│ └── validator/
├── docs/ # Documentation
├── release-test/ # Standalone release verification
└── README.md # This file
GPL-3.0