|
| 1 | +# AstroParse — Code to Cosmic JSON 🚀 |
| 2 | + |
| 3 | +[](https://opensource.org/licenses/MIT) |
| 4 | + |
| 5 | +**Turn C++ code into LLM-digestible JSON – because AI deserves X-ray vision for code!** |
| 6 | +Powered by Clang AST dissection, Bazel/Docker industrial pipelines, and JSON that pleases both machines and humans. |
| 7 | + |
| 8 | +------ |
| 9 | + |
| 10 | +## 🔥 Features |
| 11 | + |
| 12 | +- **C++ AST → JSON**: Surgical precision with Clang's parsing scalpel |
| 13 | +- **Bazel Builds**: Industrial-grade compilation with dependency isolation |
| 14 | +- **Docker in One Shot**: No dependency hell – just warp-speed deployment |
| 15 | +- **Pre-built Binaries**: For rebels who hate compiling from source |
| 16 | + |
| 17 | +------ |
| 18 | + |
| 19 | +## 🛠 Installation |
| 20 | + |
| 21 | +### Prerequisites |
| 22 | + |
| 23 | +- Docker (recommended) |
| 24 | +- Linux (Windows warriors: WSL2 required) |
| 25 | + |
| 26 | +### Pre-built Release (For Binary Cowboys) |
| 27 | + |
| 28 | +``` bash |
| 29 | +./astroparse-linux-amd64 -i your_code.cpp -o output.json |
| 30 | +``` |
| 31 | + |
| 32 | +### Build from source |
| 33 | + |
| 34 | +Init docker container for build |
| 35 | +``` bash |
| 36 | +./docker.sh init |
| 37 | +``` |
| 38 | + |
| 39 | +Enter the build env |
| 40 | +``` bash |
| 41 | +./docker.sh |
| 42 | +``` |
| 43 | + |
| 44 | +Build the code |
| 45 | +``` bash |
| 46 | +./build.sh |
| 47 | +``` |
| 48 | + |
| 49 | +------ |
| 50 | + |
| 51 | +## 🚀 Demo |
| 52 | + |
| 53 | +### Input: `demo.cpp` |
| 54 | + |
| 55 | +``` cpp |
| 56 | +#include <iostream> |
| 57 | +class SpaceShip { |
| 58 | +public: |
| 59 | + void launch() { std::cout << "3...2...1...Ignition!\n"; } |
| 60 | +}; |
| 61 | +``` |
| 62 | +
|
| 63 | +### Output: `ast.json` (snippet) |
| 64 | +
|
| 65 | +``` json |
| 66 | +{ |
| 67 | + "AST": { |
| 68 | + "type": "TranslationUnitDecl", |
| 69 | + "children": [ |
| 70 | + { |
| 71 | + "type": "ClassDecl", |
| 72 | + "name": "SpaceShip", |
| 73 | + "methods": [ |
| 74 | + { |
| 75 | + "type": "CXXMethodDecl", |
| 76 | + "name": "launch", |
| 77 | + "body": "CompoundStmt" |
| 78 | + } |
| 79 | + ] |
| 80 | + } |
| 81 | + ] |
| 82 | + } |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +------ |
| 87 | + |
| 88 | +## 📡 Architecture |
| 89 | + |
| 90 | +``` |
| 91 | +[Your C++ Code] → Clang Frontend → AST → Custom Traverser → JSON Serializer → [Feed to LLMs/Tools] |
| 92 | +``` |
| 93 | + |
| 94 | +------ |
| 95 | + |
| 96 | +## 🤖 Contributing |
| 97 | + |
| 98 | +1. **Fork This Repo**: Clone your personal universe branch |
| 99 | +2. **Code Style**: Follow `.clang-format` – follow Google style |
| 100 | +3. **Tests**: All PRs must survive `bazel test //...` |
| 101 | + |
| 102 | +------ |
| 103 | + |
| 104 | +## ⚖️ License |
| 105 | + |
| 106 | +**MIT License** – Details at [LICENSE](https://github.com/SilvesterHsu/AstroParse/blob/main/LICENSE) |
| 107 | + |
| 108 | +------ |
| 109 | + |
| 110 | +**Crafted with ❤️ and Clang by Seel.Xu** |
| 111 | +*“Any sufficiently advanced code parser is indistinguishable from magic.”* – Arthur C. Clarke (remixed) |
0 commit comments