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

Metadata

Release files for lnac 0.0.4

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.4
File Size Uploaded Provenance Actions
lnac-0.0.4.tar.gz 3.5 kB Without provenance Details for lnac-0.0.4.tar.gz

Release files / lnac-0.0.4.tar.gz

Download URL lnac-0.0.4.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5801a84654354f19b11f9ea311b80ef45cc70c910eb90c513821b857d0f22049
BLAKE2b-256 checksum
How to use checksums
d83197c082793d7ed3f9a2f4a6ad5c19cc0d5e13815b86d56690c6f9b5d11e32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for lnac 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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