Metadata-Version: 2.4
Name: cdex
Version: 0.1.0
Summary: Export seven CS3501 compiler design lab experiments as C, Lex and Yacc source files.
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# CS3501 Compiler Design Lab

Install with `python -m pip install cdex` after publication. To install from the extracted project before publication, run `python -m pip install .`.

```python
import cdex

print(cdex.ex2())                  # creates ex2/lexer.l and ex2/input.c
print(cdex.ex3("my_calculator"))   # writes calc.l and calc.y to my_calculator/
```

Each function writes the bundled text files and returns a list of paths. Use a fresh destination when a filename already exists. Python 3.9 or later is required. To compile the exported sources on Ubuntu, install GCC, Flex and Bison. Run each command from the corresponding exported directory.

| Function | Experiment | Ubuntu command |
| --- | --- | --- |
| `ex1()` | C lexical analyzer | `gcc tokens.c -o tokens && ./tokens` |
| `ex2()` | Lex lexical analyzer | `flex lexer.l && gcc lex.yy.c -o lexer && ./lexer < input.c` |
| `ex3()` | Lex/Yacc calculator (3d) | `yacc -d calc.y && flex calc.l && gcc y.tab.c lex.yy.c -o calc && ./calc` |
| `ex4()` | Three-address code | `yacc -d tac.y && flex tac.l && gcc y.tab.c lex.yy.c -o tac && ./tac` |
| `ex5()` | Type checking | `yacc -d type.y && flex type.l && gcc y.tab.c lex.yy.c -o type && ./type` |
| `ex6()` | Code optimization | `gcc optimize.c -o optimize && ./optimize` |
| `ex7()` | 8086 code generator | `gcc backend.c -o backend && ./backend` |

## Publish directly to PyPI

From the extracted folder containing pyproject.toml, run:

```powershell
python -m pip install --upgrade twine
python -m twine check dist/*
python -m twine upload --repository-url https://upload.pypi.org/legacy/ --username __token__ dist/*
```

Enter your PyPI API token at the hidden password prompt. The included distributions are already built. If you edit the source, rebuild in a clean dist directory with `python -m pip install build` and `python -m build` before uploading.
