# pcl **Repository Path**: labsite/pcl ## Basic Information - **Project Name**: pcl - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-06-11 - **Last Updated**: 2021-06-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PCL [![Build Status](https://travis-ci.com/papachristoumarios/pcl.svg?token=DxqFuX4UzFjiGRipqjph&branch=master)](https://travis-ci.com/papachristoumarios/pcl) Compiler for the PCL Language written in [Python](http://www.python.org/). This is part of the semester assignment for [_Compilers_](https://courses.softlab.ntua.gr/compilers/2019a/) course taught in ECE NTUA (Spring 2018-2019). ## :busts_in_silhouette: Authors This compiler would have never been born without the orderly contributions of its authors * Marios Papachristou ([papachristoumarios](https://github.com/papachristoumarios)) * Ioannis Daras ([giannisdaras](https://github.com/giannisdaras)) --- ## :tomato: What is PCL? PCL is a imperative programming language based on a proper subset of ISO PASCAL, among with some changes. The basic characteristics of PCL include: 1. Syntax similar to PASCAL 2. Structured functions similar to PASCAL 3. Basic data types for integers and real numbers, booleans and characters 4. Arrays of fixed or variable size 5. Built-in function library The complete PCL specification is available under `docs/pcl2019.pdf` (in Greek). ## :nut_and_bolt: Setup The compiler comes with a `Makefile` for installation. Install it via ```bash make depend make compiler ``` Please note that PCL compiler requires Python **>=3.6** to work since it has metaprogramming features (due to SLY) to specify lexers and parsers. Older versions **won't** work. ## :hammer: Usage After you have set up PCL you can use the `pclc.py` executable of the PCL compiler. You can display the usage of `pclc.py` via ```bash pclc.py --help ``` The `pcl` executable allows the use of its constituent parts independently. Such parts include 1. The lexer 2. The parser 3. The semantic analyzer 4. The codegen module #### Compile PCL programs For instance assume that you have the following PCL program under `example.pcl` ```pascal program dummmy; var x: integer; begin x := 0; while x < 10 do begin writeInteger(x); writeChar('\n'); x := x + 1; end; end. ``` which prints the numbers 0 to 9. Running ```bash pclc.py example.pcl ``` will produce IR code at `example.imm` , the object file at `example.o` and the final (linked) executable at `example.out`. If you specify the flag `-i` then the program should be read from `stdin` and the IR will be emitted to `stdout` . So the PCL compiler should be called as ```bash pclc.py -i example.imm ``` If one wants to create an object file, he could use UNIX pipes ```bash pclc.py -i example.o ``` Compiling and linking the final can be separately done with the use of `gcc`. If one wants static linking with the `pcl/builtins.h` library then one should use ```bash gcc -Wall -Werror -fpic -lm example.o /path/to/builtins.c/builtins.c -o example.out ``` Note that builtins depend on `stdio.h` and `math.h` so the flag `-lm` is used to do dynamic linking with the math library. If one wants to perform dynamic linking with `pcl/libbuiltins.so` one should use ```bash gcc -Wall -Werror -fpic -lm -L/path/to/libbuiltins.so -lbuiltins example.o -o example.out ``` Again, if one wants to use pipes, it is possible via the `-x` option as ```bash pclc.py -i