Description:
Pallyc is a simplified C compiler that supports nested-function definition.This is an open-source project. Under the agreement of the license, any one can download the binary executive file as well as its source code.
The whole project is written in pure C++ code with the support of STL, which makes Pallyc compiling and running compatible on almost every platform, particularly Windows and Linux.
Goal:
Currently, those prevailing C compilers, such as GNU gcc, MS cl, etc, have no nested-function definition support.Sometimes, programmer would find that nested-function definition(as in Pascal) can be very useful in making the code concise and hierarchical.
The ultimate goal of this Pallyc Project is to help those compilers become compatible with nested-function definition, by generalizing recognizable assembly code for each of those C compilers as input, respectively.
At that time, the role of Pallyc can be thought of as a mid-ware which builds a bridge between those popular, well-developed compilers and the concise, convenient, nested, hierarchical coding style.
Latest Features:
Now Pallyc source code could be compiled online. Use the this form or go to this URL have new experience of nested function style!
Here is the top-level organization for Pallyc: It takes 3 input files: the source code input, key words table input and grammar specification input. And there are 5 distinctive stages:
- In initiating stage, Pallyc calculates and constructs SLR(1) parsing table;
- In lexer stage, source code input is converted into a token file, in which symbols are represented by tokens(integers), according to the key word table input;
- In parsing stage, token file from lexer stage is parsed and semantic action sequence is generated;
- In semantic process stage, a semantic handler process each semantic action in term of the sequence that parsing stage generates.
- Finally, intermediate code of 4-element expression is output and converted to assembly code (assembly conversion is in progress).
See the following figure.
Here is the C language feature coverage status:
| array | supported |
| multidemensional array | supported |
| function | supported |
| nested-function | supported |
| arithmetic operation | supported |
| boolean expression | supported |
| if...else... | supported |
| while | supported |
| break/continue | supported |
| string | not supported |
| negative integer | not supported |
| struct | not supported |
| float type | not supported |
| pointer type | not supported |
| bit operation | not supported |
| Error ID | Error Description | Error Type |
|---|---|---|
| 0001 | parsing table record null | syntax error |
| 0002 | undefined keyword | lexeme error |
| 2040 | identifier redefinition | semantic error |
| 2043 | illegal break | semantic error |
| 2044 | illegal continue | semantic error |
| 2064 | illegal function call | semantic error |
| 2065 | undeclared identifier | semantic error |
| 2065 | illegal array reference | semantic error |
| 2118 | negative subscript for array | semantic error |
| 2440 | type conversion error | semantic error |
| 2440 | array reference doesn’t match array definition | semantic error |
| 2441 | illegal reference to array | semantic error |
| 2466 | cannot allocate an array of constant size 0 | semantic error |
| 2660 | function argument number doesn’t match | semantic error |
Conundrum for Pallyc:
"p" stands for PASCAL's nested function definition, while "c" for C's grammar base frame; the word "ally" represents the combination of those features. And luckily the last 3 letters “lyc᾿happen to be the abbreviation of my name.Contact the author:
If you have any questions about Pallyc or just interested in compiler implementation, please feel free to send me information. Email:

