Pascal parser in js. The goal is to be able to run simple Turbo Pascal demos made in the 90s that depend on asm, but otherwise very simple pascal.
The generated js output is very sensible and lean. For example the following pascal program:
program HelloWorld;
var
x: String;
begin
x := 'y';
WriteLn('x is ', x);
end.
Is compiled to just
// Genrated by pascaljs. https://github.com/vidstige/pascaljs
function WriteLn() { var args = Array.prototype.slice.call(arguments); console.log(args.join('')); }
var x = null; // integer
x = 'y';
WriteLn('x is ', x);
https://vidstige.github.io/pascaljs/
- Programs
- Units
- Comments
- Invoke Procedures
-
var
parameters - Compound
-
for
-
if
- assignment
-
while
-
repeat
-
with
-
case
- Recursive calls
- Integer literals
- String literals
- Variables
- Parenthesis
- Boolean operators
- Arithmetic operators
- Comparisions
- Function calls
- Pointers
- Procedures
- Functions
- Variabes
- Constants
- Type aliases
- Records
- Arrays
- Mix declaration order
- Real
- Type checking
- Nested arrays/records
- Export types from units
- Parse keywords
- Construct structured JavaScript flow control (
if-then-else
,do-while
) from assembler - Adress variables and pointers
- Basic instruction set
- Low/High/Full 16-bit register semantics (
ah
,al
,ax
, etc) -
int
for graphics, sleeps, and more - Full instruction set
- `WriteLn´
- Arithmetic
- File I/O
- Strings
- In separate file
- Separate _system.js for web
- VGA emulation
- Palette
Samuel Carlsson [email protected]