Skip to main content

A toy functional language compiler written in Python

Project description

# LnaC

### A toy functional language compiler written in Python.


LnaC is a toy functional language compiler written in Python 3 that supports limited program generation.

For some sample programs, see the [demos directory](demos).

## Quickstart

To install LnaC:
pip3 install lnac

To create, compile, and run an example program:
$ nano return0.lna
$ less return0.lna

main : int
main =
=> 0

$ lnac return0.lna
$ ./return0 && $?

## Implementation

### Lexer
The LnaC lexer is primarily implemented in [``](lnac/ Additionally, [``](lnac/ contains definitions of the token classes used in the lexer and instances of recognized keyword and symbol tokens.

### Parser
The LnaC parser is implemented in [`parser/`](lnac/parser/) and creates an abstract syntax tree of nodes defined in [`tree/`](lnac/tree/

### Assembly
LnaC writes out an intermediary assembly file that gcc then generates an executable from. This assembly file is written following the AT&T assembly syntax and is deleted following a successful compilation.

## References
- Writing a C Compiler -
- ShivyC -

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for lnac, version 0.0.9
Filename, size File type Python version Upload date Hashes
Filename, size lnac-0.0.9.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View
Filename, size lnac-0.0.9-py3-none-any.whl (5.7 kB) File type Wheel Python version 3.6 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page