Giter Site home page Giter Site logo

pplusplus's Introduction

P++

P++ is a language based on PL/0 but borrows heavily from C, Haskell and other languages.

I wrote the compiler and interpreter for P++ at University back in 2000 as part of my second year programming languages paper. It was only supposed to be a 200 line assignment but I enjoyed learning about compilers so much that I added many advanced (advanced compared to PL/0) features such as:

* Strings
* Reference counted GC
* Lambda Expressions
* Integrated large integer & float support
* Inline assembly/bytecode
* A modest library of core functions

As much as possible, most of the features and functions are written in the language itself. Big Integer support, math functions such as cos, sin, random and sorting functions were mostly an excercise in learning to implement the functions that almost always come for free with a language. There was a lot of reward in being able to implement complex libraries in a language I wrote myself.

Whilst going through very old disks, I discovered the code and have uploaded it here for posterity and in the hopes that it helps students and teachers learn and teach compiler construction.

Sample P++ source/programs are in the examples directory. Refer to the P++ User Manual for a detailed language spec.

/* Hello World */
using "stream.p++";

function main() : integer
{
	println("Hello World");
};
/* Large integer factorial */
using "lang.p++";
using "string.p++";
using "bignumbers.p++";

function big_factorial(x : bignumber) : bignumber
{	
	return (x > 1) ? x * big_factorial(x - 1) : 1#;
};
Compiler/Interpreter usage:

> p++ helloworld.p++
Hello World!

pplusplus's People

Contributors

tumtumtum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.