|
| 1 | +# Contributing to NashmiC |
| 2 | + |
| 3 | +Ahlan wa sahlan! Thanks for wanting to contribute to NashmiC. |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- C11 compiler (`gcc` or `clang`) |
| 10 | +- `make` |
| 11 | +- `git` |
| 12 | +- Linux or macOS |
| 13 | + |
| 14 | +### Build from source |
| 15 | + |
| 16 | +```bash |
| 17 | +git clone https://github.com/Ziadstr/nashmic.git |
| 18 | +cd nashmic |
| 19 | +make |
| 20 | +``` |
| 21 | + |
| 22 | +### Run examples |
| 23 | + |
| 24 | +```bash |
| 25 | +make run-all # All examples |
| 26 | +NASHMIC_ROOT=. ./build/mansaf run examples/marhaba.nsh # Single example |
| 27 | +``` |
| 28 | + |
| 29 | +### Run tests |
| 30 | + |
| 31 | +```bash |
| 32 | +make test |
| 33 | +``` |
| 34 | + |
| 35 | +## Project Structure |
| 36 | + |
| 37 | +``` |
| 38 | +compiler/src/ # mansaf compiler (C11) |
| 39 | + main.c # CLI entry point |
| 40 | + lexer.c/h # UTF-8 tokenizer |
| 41 | + keywords.c/h # Franco-Arab keyword table |
| 42 | + parser.c/h # Recursive descent + Pratt parser |
| 43 | + ast.c/h # AST node types |
| 44 | + codegen_c.c/h # C transpiler backend |
| 45 | + diagnostics.c/h # Errors with Jordanian proverbs |
| 46 | +runtime/ # Runtime library |
| 47 | + nsh_runtime.c/h # I/O, easter eggs |
| 48 | +examples/ # Working example programs (.nsh) |
| 49 | +docs/ # Documentation site |
| 50 | +tests/ # Test suite |
| 51 | +``` |
| 52 | + |
| 53 | +## Compilation Pipeline |
| 54 | + |
| 55 | +``` |
| 56 | +.nsh source -> Lexer -> Parser -> AST -> C Codegen -> .c file -> cc -> binary |
| 57 | +``` |
| 58 | + |
| 59 | +## How to Contribute |
| 60 | + |
| 61 | +### Adding a keyword |
| 62 | + |
| 63 | +1. Add the token type in `compiler/src/lexer.h` |
| 64 | +2. Register it in `compiler/src/keywords.c` |
| 65 | +3. Handle parsing in `compiler/src/parser.c` |
| 66 | +4. Add AST node (if needed) in `compiler/src/ast.h` and `compiler/src/ast.c` |
| 67 | +5. Generate C code in `compiler/src/codegen_c.c` |
| 68 | +6. Add an example in `examples/` |
| 69 | +7. Add a Makefile target to run it |
| 70 | + |
| 71 | +### Fixing a bug |
| 72 | + |
| 73 | +1. Write a minimal `.nsh` file that reproduces the issue |
| 74 | +2. Fix the bug with minimal changes |
| 75 | +3. Verify `make run-all` still passes |
| 76 | +4. Add a test case if applicable |
| 77 | + |
| 78 | +### Documentation |
| 79 | + |
| 80 | +Docs live in `docs/site/index.html` (the live site) and `docs/src/` (mdBook source). Update both if changing user-facing features. |
| 81 | + |
| 82 | +## Code Style |
| 83 | + |
| 84 | +- C11 standard |
| 85 | +- 4-space indentation |
| 86 | +- `snake_case` for functions and variables |
| 87 | +- `PascalCase` for types and enum values |
| 88 | +- `UPPER_SNAKE_CASE` for constants and macros |
| 89 | +- Keep functions under 40 lines where possible |
| 90 | +- Comments for non-obvious logic only |
| 91 | + |
| 92 | +## Commit Style |
| 93 | + |
| 94 | +Conventional commits, one line, concise: |
| 95 | + |
| 96 | +``` |
| 97 | +feat: add saff<T> array type |
| 98 | +fix: correct range codegen for negative steps |
| 99 | +docs: update pattern matching examples |
| 100 | +chore: clean up unused AST nodes |
| 101 | +``` |
| 102 | + |
| 103 | +## Submitting a PR |
| 104 | + |
| 105 | +1. Fork the repo |
| 106 | +2. Create a branch from `main`: `git checkout -b feat/my-feature main` |
| 107 | +3. Make your changes |
| 108 | +4. Verify: `make clean && make && make run-all` |
| 109 | +5. Push and open a PR against `main` |
| 110 | + |
| 111 | +## Franco-Arab Naming Guidelines |
| 112 | + |
| 113 | +NashmiC keywords use Franco-Arab (Arabizi) — the way Arabs text. When naming new keywords: |
| 114 | + |
| 115 | +- Use Jordanian/Levantine dialect, not Modern Standard Arabic |
| 116 | +- Spell it how you'd text it to a friend |
| 117 | +- Numbers replace Arabic letters: `3` = ع, `2` = ء/ق, `7` = ح, `5` = خ |
| 118 | +- Keep it short and natural |
| 119 | +- Test it: would a Jordanian CS student actually say this word? |
| 120 | + |
| 121 | +Examples: `khalli` (let), `dalle` (function), `rajje3` (return), `ba3dain` (later/defer) |
| 122 | + |
| 123 | +## Questions? |
| 124 | + |
| 125 | +Open an issue or start a discussion. We don't bite — unless you use `npm`. |
0 commit comments