tylerlaberge / Rascal
Licence: mit
A simple Pascal interpreter written in rust.
Stars: ✭ 38
Labels
Projects that are alternatives of or similar to Rascal
Umka Lang
Umka: a statically typed embeddable scripting language
Stars: ✭ 308 (+710.53%)
Mutual labels: compiler, interpreter
Enso
Hybrid visual and textual functional programming.
Stars: ✭ 5,238 (+13684.21%)
Mutual labels: compiler, interpreter
Craftinginterpreters
Repository for the book "Crafting Interpreters"
Stars: ✭ 4,298 (+11210.53%)
Mutual labels: compiler, interpreter
Rascal
The implementation of the Rascal meta-programming language (including interpreter, type checker, parser generator, compiler and JVM based run-time system)
Stars: ✭ 284 (+647.37%)
Mutual labels: compiler, interpreter
Lbforth
Self-hosting metacompiled Forth, bootstrapping from a few lines of C; targets Linux, Windows, ARM, RISC-V, 68000, PDP-11, asm.js.
Stars: ✭ 293 (+671.05%)
Mutual labels: compiler, interpreter
Passerine
A small extensible programming language designed for concise expression with little code.
Stars: ✭ 341 (+797.37%)
Mutual labels: compiler, interpreter
Swift Lispkit
Interpreter framework for Lisp-based extension and scripting languages on macOS and iOS. LispKit is based on the R7RS standard for Scheme. Its compiler generates bytecode for a virtual machine. LispKit is fully implemented in Swift 5.
Stars: ✭ 228 (+500%)
Mutual labels: compiler, interpreter
Red
Red is a next-generation programming language strongly inspired by Rebol, but with a broader field of usage thanks to its native-code compiler, from system programming to high-level scripting and cross-platform reactive GUI, while providing modern support for concurrency, all in a zero-install, zero-config, single 1MB file!
Stars: ✭ 4,725 (+12334.21%)
Mutual labels: compiler, interpreter
Renjin
JVM-based interpreter for the R language for the statistical analysis.
Stars: ✭ 466 (+1126.32%)
Mutual labels: compiler, interpreter
Openj9
Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Stars: ✭ 2,802 (+7273.68%)
Mutual labels: compiler, interpreter
Enso Archive
Looking for Enso, the visual programming language? ➡️ https://github.com/enso-org/enso
Stars: ✭ 305 (+702.63%)
Mutual labels: compiler, interpreter
Gwion
🎵 strongly-timed musical programming language
Stars: ✭ 235 (+518.42%)
Mutual labels: compiler, interpreter
V8
The official mirror of the V8 Git repository
Stars: ✭ 18,808 (+49394.74%)
Mutual labels: compiler, interpreter
Go.vm
A simple virtual machine - compiler & interpreter - written in golang
Stars: ✭ 178 (+368.42%)
Mutual labels: compiler, interpreter
Ph7
An Embedded Implementation of PHP (C Library)
Stars: ✭ 422 (+1010.53%)
Mutual labels: compiler, interpreter
Tiny Compiler
A tiny evaluator and compiler of arithmetic expressions.
Stars: ✭ 680 (+1689.47%)
Mutual labels: compiler, interpreter
rascal
A simple Pascal interpreter written in rust.
Usage
Download the latest rascal executable from the release page.
Run the executable.
rascal.exe <name-of-pascal-file>.pas
Features
Types and Variable Declarations
program exampleVariables;
var
intOne, intTwo: integer;
realOne, realTwo, realThree: real;
stringOne, stringTwo: string;
boolOne: boolean;
begin
intOne := 5;
realOne := 5.5;
stringOne := 'foobar';
boolOne := true;
end.
Functions and Procedures
program exampleProcedure;
procedure printSum(a, b: integer);
var
sum: integer;
begin
sum := a + b;
writeln(IntToString(a) + ' + ' + IntToString(b) + ' = ' + IntToString(sum));
end
begin
printSum(5, 10);
end.
program exampleFunction;
var
mySum: integer;
function sum(a, b: integer): integer;
var
sum: integer;
begin
sum := a + b;
end
begin
mySum := sum(5, 10);
end.
Control Flow
program exampleControlFlow;
begin
if 20 = 5 then
begin
writeln('unreachable');
end
else if 5 + 7 < 30 then
begin
writeln('this will print');
end
else if not true then
begin
writeln('this will not print');
end
else if 20 <> 5 then
begin
writeln('<> means not equal');
end
else
begin
writeln('this will not print');
end
end.
Expressions
program exampleExpressions;
var
foo: integer;
bar: real;
baz: boolean;
begin
foo := 5 * ( 7 - -2) div 5;
bar := 5.5 * (7.0 - -2.5) / 10.0;
baz := true and (true or false) and (10 < foo or 9 = foo);
end.
BuiltIn Functions
program exampleBuiltIns;
var
my_int: integer;
my_real: real;
my_string: string;
begin
my_int := 5;
my_string := IntToString(my_int);
my_real := 5.5;
my_string := RealToString(my_real);
my_string := '5';
my_int := StringToInt(my_string);
my_string := '5.5';
my_real := StringToReal(my_string);
write('print without a newline');
writeln('print with a newline');
my_string := readln();
end.
Example Programs
hello world
program helloworld;
begin
writeln('hello world!');
end.
fibonacci
note: This program is not very efficient. You should probably stick to integers less than 20.
program fibonacci;
var
input: integer;
function fib(n:integer): integer;
var
val: integer;
return: integer;
begin
if (n <= 2) then
begin
val := 1;
end
else
begin
val := fib(n-1) + fib(n-2);
end
return := val;
end
begin
writeln('Welcome to fibonacci!');
write('Please enter an integer: ');
input := StringToInt(readln());
writeln('fib of ' + IntToString(input) + ' is ' + IntToString(fib(input)));
end.
Resources
Pascal basic syntax can be read about here.
Bear in mind that this interpreter does not implement every feature of pascal.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].