Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/soegaard/minipascal
MiniPascal implemented in Racket
https://github.com/soegaard/minipascal
compiler pascal racket
Last synced: 21 days ago
JSON representation
MiniPascal implemented in Racket
- Host: GitHub
- URL: https://github.com/soegaard/minipascal
- Owner: soegaard
- Created: 2013-01-29T09:28:24.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2021-09-26T12:46:52.000Z (over 3 years ago)
- Last Synced: 2024-11-11T14:55:45.570Z (3 months ago)
- Topics: compiler, pascal, racket
- Language: Pascal
- Homepage:
- Size: 196 KB
- Stars: 88
- Watchers: 5
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-racket - minipascal - MiniPascal as a Racket language. (Compilers)
README
MiniPascal
==========MiniPascal as a Racket language
-------------------------------This is the `minipascal` package. It provides MiniPascal
as a new #lang language.After installation (see later) the following program will run
as is in DrRacket.#lang minipascal
program fact;
type
int=integer;
function fact(n:int):int;
begin
if n=0 then
fact:=1
else
fact:=n*fact(n-1)
end;
begin
writeln(fact(10));
end.See `mini-pascal-grammar.rkt` for a complete grammar.
Features
--------The following features are supported:
- constant definitions
- type definitions
- function and procedure declarations
- nested functions and procedures
- base types: integer, boolean, char,
- arrays
- strings
- integer and char can be used as index rangesCompilers
---------
MiniPascal comes with two compilers. The simple one
in "semantics-simple.rkt" translates directly from
Pascal to Racket without any (compile time) type
checking. This compiler is written in the same
spirit as the example in the Ragg tutorial. In
other words it "compiles by macro expansion".The other compiler in "semantics.rkt" demonstrates
how scoping and type checking can by implemented.
The compiler more traditional, it expands the whole
Pascal program in one go.To switch from the full compiler to the simple one,
add `simple` to the `#lang` line. That is, the lines:#lang minipascal
#lang minipascal simple
use the full and simple compiler respectively.Exercises
---------
- Add mod as an operator
- Add repeat
- Add case
- Add enumerated types
- Add real numbers
- Add records
- Add files
Installation
------------Install this package from the command line with:
```sh
raco pkg install --deps search-ask minipascal
```or, by evaluating the following in DrRacket:
```racket
#lang racket(require pkg)
(install "minipascal" #:deps 'search-ask)
```Use the Racket package manager to install:
```
raco pkg install minipascal
```References
----------
Pascal ISO 7185 from 1990:
http://pascal-central.com/docs/iso7185.pdf