Giter VIP home page Giter VIP logo

minipascal's Introduction

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

minipascal's People

Contributors

cmpitg avatar dyoo avatar samth avatar soegaard avatar spdegabrielle avatar stamourv avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.