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.3

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

Release files / lnac-0.0.3.tar.gz

Download URL lnac-0.0.3.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
65c9012fe8859df11bbc5aa8e3e69e68c80195b06b997fa3781948e26d4d9b80
BLAKE2b-256 checksum
How to use checksums
2f2d92d7673797edf4bd7f71e37ad598fd771cd2bc51f4ead0cfa8323fbe35a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for lnac 0.0.3

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