• Stars
    star
    88
  • Rank 363,195 (Top 8 %)
  • Language Pascal
  • Created over 11 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

MiniPascal implemented in Racket

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 ranges

Compilers

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:

raco pkg install --deps search-ask minipascal

or, by evaluating the following in DrRacket:

#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

More Repositories

1

urlang

Urlang is JavaScript with a sane syntax
Racket
296
star
2

sketching

A Racket library for creative drawings and animations. Inspired by Processing.
Racket
108
star
3

racket-cas

Simple computer algebra system
Racket
61
star
4

metapict

A graphics library for producing Racket picts in a MetaPost/TikZ style.
Racket
61
star
5

remacs

Emacs style editor written in Racket
Racket
60
star
6

web-tutorial

How to write web applications with Racket
Racket
50
star
7

racket-stories

Racket Stories is a "submit and vote" web site. This repo serves as an example of a small "in production" web-site written in Racket.
Racket
38
star
8

pyffi

Use Python from Racket
Racket
26
star
9

racket-poppler

Racket bindings for Poppler (library for reading and generating pdfs)
HTML
23
star
10

meta

Exploration of the inner workings of Racket
Racket
19
star
11

flappy-bird

A clone of the game Flappy Bird.
Racket
19
star
12

sci

Racket libraries for scientific computing
Racket
17
star
13

bracket

A computer algebra system (CAS) for high school students
Racket
13
star
14

super

Adds syntax to racket languages
Racket
11
star
15

6502

An emulator/assembler/disassmbler for 6502
Racket
9
star
16

bind

Bind: Let with binding clause transformers
HTML
8
star
17

little-helper

Search engine for full text searches in the Racket documentation
Scheme
8
star
18

control

Control Structures
Racket
8
star
19

breakout

A small breakout game in Racket
Racket
7
star
20

cairo

Racket bindings for Cairo (a 2d graphics library implemented in C)
Racket
6
star
21

space-invaders

Space Invaders
Racket
6
star
22

indiana

Ports of "Indiana" Scheme libraries
Racket
5
star
23

flmatrix

Matrices over floating points. Bindings for CBLAS and LAPACK
Racket
5
star
24

racket-highlight-for-github

Github syntax highlighting for Racket
Racket
5
star
25

mathbook

Scribble support for writing math books - MathJax and more
Racket
4
star
26

infix

Infix expression for Racket
Racket
4
star
27

nanopass

A Racket implementation of the nanopass framework for compiler writing
Racket
4
star
28

Racket-Maxima

Use Maxima from Racket
4
star
29

this-and-that

Roff
4
star
30

require-github

Experiments with require
Racket
4
star
31

racket-osx-libs

Source files and build instructions for the dynamic libraries used by Racket on OS X
C
4
star
32

dualshock4

Dualshock 4 interface for Racket on OS X
Racket
3
star
33

tutorials

Bits and pieces that will end up in tutorials
Racket
2
star
34

srfi-array

Implementation of SRFI 179 - Nonempty Intervals and Generalized Arrays
Racket
2
star
35

poppler-libs

Binaries for poppler built to work with the draw-<platform>-3 libraries
Racket
1
star
36

racketfest-2023-talk-sketching

The RacketFest 2023 talk on Sketching
Racket
1
star
37

triangle-solver

Triangle solver written in Whalesong (Racket)
1
star
38

rackos

Racket Cartridge for Redhat's OpenShift
Shell
1
star
39

disksort

Sort large files
Racket
1
star