Skip to main content
# 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:
```c
$ nano return0.lna
$ less return0.lna

main : int
main =
=> 0

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

## Implementation

### Lexer
The LnaC lexer is primarily implemented in [`lexer.py`](lnac/lexer.py). Additionally, [`tokens.py`](lnac/tokens.py) 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/parser.py`](lnac/parser/) and creates an abstract syntax tree of nodes defined in [`tree/nodes.py`](lnac/tree/nodes.py).

### 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 - https://norasandler.com/2017/11/29/Write-a-Compiler.html
- ShivyC - https://github.com/ShivamSarodia/ShivyC

Release files for lnac 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lnac 0.0.9
File Size Uploaded
lnac-0.0.9.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lnac 0.0.9
File Interpreter ABI Platform
lnac-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 10.5 kB

Release files / lnac-0.0.9.tar.gz

Download URL lnac-0.0.9.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d25b0f92de62e3ba10f8667dbf23c2d5a7792a9c08619c34bb347274921282a2
BLAKE2b-256 checksum
How to use checksums
8cb5d82f998303d43cdce986f033bbb1cf644dbd3e51a177419c4068b28fbdd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / lnac-0.0.9-py3-none-any.whl

Download URL lnac-0.0.9-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
768de2b040bf5817ff5748fcc799d8c7abf0c7d3c23347dc691525a9014aedc5
BLAKE2b-256 checksum
How to use checksums
4b6851a3c72687d4f9cc0ba8857ff12b081fc1d61d7cf2856bffc4dc6a6b0ccd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page