{"id":32674099,"url":"https://github.com/vitorpy/cobolana","last_synced_at":"2025-11-01T06:01:39.106Z","repository":{"id":321168463,"uuid":"1082580324","full_name":"vitorpy/cobolana","owner":"vitorpy","description":"🔥 COBOL on Solana - Because 1959 deserves to run on the blockchain. The world's most absurd compiler: Enterprise COBOL → Solana BPF. It actually works.","archived":false,"fork":false,"pushed_at":"2025-10-24T13:05:18.000Z","size":504,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-28T07:43:53.800Z","etag":null,"topics":["blockchain","bpf","cobol","compiler","cursed","ebpf","meme","solana","solana-program"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vitorpy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-24T13:03:10.000Z","updated_at":"2025-10-27T21:26:56.000Z","dependencies_parsed_at":"2025-10-28T07:43:58.341Z","dependency_job_id":"96c76c46-e882-42d8-bb3b-b4543ac4df51","html_url":"https://github.com/vitorpy/cobolana","commit_stats":null,"previous_names":["vitorpy/cobolana"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/vitorpy/cobolana","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorpy%2Fcobolana","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorpy%2Fcobolana/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorpy%2Fcobolana/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorpy%2Fcobolana/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitorpy","download_url":"https://codeload.github.com/vitorpy/cobolana/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorpy%2Fcobolana/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":282101881,"owners_count":26614352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-01T02:00:06.759Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","bpf","cobol","compiler","cursed","ebpf","meme","solana","solana-program"],"created_at":"2025-11-01T06:00:25.729Z","updated_at":"2025-11-01T06:01:39.094Z","avatar_url":"https://github.com/vitorpy.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔥 COBOLANA - COBOL on Solana\n\n\u003e **Because 1959 deserves to run on the blockchain.**\n\nThe world's most absurd compiler: Enterprise COBOL → Solana BPF bytecode.\n\n**It actually works.** ✅\n\n```cobol\nIDENTIFICATION DIVISION.\nPROGRAM-ID. COBOLANA.\n\nDATA DIVISION.\nWORKING-STORAGE SECTION.\n01 HELLO-MSG PIC X(14) VALUE \"Hello Cobolana\".\n\nPROCEDURE DIVISION.\n    CALL \"sol_log_\" USING\n        BY REFERENCE HELLO-MSG\n        BY VALUE 14.\n    STOP RUN.\n```\n\n```bash\n$ npm test\n\nProgram log: Hello Cobolana\nProgram 9yR685XRwdjQXy4Nz7TcYP4LuP4SjxWWpmcABig5RcYT success\n✅ consumed 104 compute units\n\nPASS test/cobolana.test.ts\n  ✓ should execute and log \"Hello Cobolana\"\n  ✓ should succeed with no errors\n\nTests: 2 passed, 2 total\n```\n\n## What is this?\n\nA complete COBOL-to-Solana compiler that:\n- Takes COBOL source code from 1959\n- Compiles it to Solana BPF bytecode\n- Deploys it on-chain\n- Executes successfully with minimal compute units\n\nThis is not a joke. This is not a wrapper. This is a **real compiler** using GnuCOBOL's full parser infrastructure (20,000+ line bison grammar) with a custom Solana BPF backend.\n\n## Why does this exist?\n\n1. **Because we can** - The ultimate test of \"everything is a compiler target\"\n2. **For the memes** - COBOL on blockchain is peak absurdist programming\n3. **Historical irony** - Grace Hopper's 1959 language running on 2020s distributed ledgers\n4. **It's actually interesting** - Bridging 65+ years of computer science\n\n## Architecture\n\n```\nCOBOL Source (.cob)\n       ↓\n┌──────────────────────────────────────────┐\n│   cobolana-cc (GnuCOBOL-based compiler)  │\n│   - Full COBOL parser (parser.y)         │\n│   - Custom sBPF backend (codegen.c)      │\n└──────────────────────────────────────────┘\n       ↓\nsBPF Assembly (.s)\n       ↓\n┌──────────────────────────────────────────┐\n│   sbpf build tool                        │\n│   - Assembles to ELF object              │\n│   - Links syscalls                       │\n└──────────────────────────────────────────┘\n       ↓\nSolana BPF Program (.so)\n       ↓\nsolana-test-validator / Mainnet\n```\n\n## Quick Start\n\n### Prerequisites\n\n```bash\n# Install Solana CLI tools\nsh -c \"$(curl -sSfL https://release.solana.com/stable/install)\"\n\n# Install Node.js dependencies\nnpm install\n\n# Build GnuCOBOL-based compiler (one-time setup)\ncd cobolana-cc\nmake\ncd ..\n```\n\n### Build \u0026 Test\n\n```bash\n# Build COBOL → Solana BPF\n./build.sh\n\n# Run end-to-end tests (deploys to local validator)\nnpm test\n```\n\n## Project Structure\n\n```\ncobolana/\n├── src/\n│   ├── cobolana.cob          # COBOL source code\n│   └── cobolana/             # Generated sBPF assembly (build artifact)\n├── cobolana-cc/              # The compiler\n│   ├── codegen.c             # Custom Solana BPF backend\n│   ├── parser.y              # COBOL grammar (from GnuCOBOL)\n│   ├── scanner.l             # COBOL lexer\n│   └── ...                   # Full GnuCOBOL infrastructure\n├── test/\n│   └── cobolana.test.ts      # Jest tests (deploy \u0026 verify on-chain)\n├── build.sh                  # Build script\n└── README.md                 # You are here\n```\n\n## How It Works\n\n### 1. COBOL Parsing\nUses GnuCOBOL's industrial-strength COBOL parser:\n- 20,000+ line bison grammar\n- Full COBOL-85 compatibility\n- Builds an AST of the program\n\n### 2. Code Generation (codegen.c)\nCustom backend that walks the AST and emits sBPF assembly:\n\n```c\n// From codegen.c - Generating a sol_log_ syscall\nfprintf(out, \"  lddw r1, msg_%s\\n\", field-\u003ename);  // Load string address\nfprintf(out, \"  lddw r2, %d\\n\", field-\u003esize);      // Load string length\nfprintf(out, \"  call sol_log_\\n\");                 // Syscall\n```\n\nOutputs valid sBPF assembly:\n```assembly\n.section .rodata\nmsg_HELLO_MSG:\n  .ascii \"Hello Cobolana\"\n\n.text\n.globl entrypoint\n\nentrypoint:\n  lddw r1, msg_HELLO_MSG\n  lddw r2, 14\n  call sol_log_\n  exit\n```\n\n### 3. Assembly \u0026 Linking\nUses the `sbpf` toolchain to:\n- Assemble `.s` → `.o` (ELF object)\n- Link syscalls (sol_log_ → 0x207559bd)\n- Generate final `.so` binary\n\n### 4. Deployment \u0026 Execution\nJest tests deploy to `solana-test-validator` and verify on-chain execution.\n\n## Features\n\n- ✅ **Full COBOL parser** - Not a toy, uses production compiler infrastructure\n- ✅ **Real syscalls** - Calls Solana's `sol_log_` to write on-chain logs\n- ✅ **Minimal compute** - Only 104 CUs for Hello World\n- ✅ **End-to-end tests** - Automated deploy \u0026 verification\n- ✅ **Proper toolchain** - Integrates with sbpf assembler/linker\n\n## Limitations\n\nThis is a **proof of concept**. Current limitations:\n\n- ❌ Only supports `CALL \"sol_log_\"` syscall\n- ❌ No arithmetic operations yet\n- ❌ No branching/conditionals\n- ❌ No account handling\n- ❌ String literals only (no dynamic data)\n\n**But it WORKS.** And that's beautiful.\n\n## Future Ideas\n\n- [ ] Support more Solana syscalls (sol_log_64_, sol_create_program_address, etc.)\n- [ ] Implement COBOL COMPUTE for on-chain arithmetic\n- [ ] Map COBOL file I/O to Solana accounts\n- [ ] IF/ELSE → BPF conditional jumps\n- [ ] PERFORM → BPF subroutines\n- [ ] Deploy a COBOL program to mainnet (for the culture)\n\n## The Story\n\nThis started as a joke: \"What's the most absurd language to compile to Solana?\"\n\nCOBOL won because:\n1. **Maximum age gap** - 1959 vs 2020\n2. **Cultural contrast** - Enterprise banking vs DeFi\n3. **Technical challenge** - Complex grammar, different paradigms\n4. **Meme potential** - Infinite\n\nAfter 83,000+ lines of compiler code and many debugger sessions, **it works.**\n\n```\nProgram log: Hello Cobolana\n```\n\n*Chef's kiss.* 👨‍🍳\n\n## Credits\n\n- **GnuCOBOL** - For the industrial-grade COBOL parser\n- **sbpf toolchain** - For making sBPF assembly viable\n- **Solana** - For being a compiler target that accepts anything\n- **Grace Hopper** - For COBOL (sorry Grace, we did this to your baby)\n\n## License\n\nMIT - Do whatever you want with this madness\n\n## Contributing\n\nPRs welcome! Especially if you want to:\n- Add more syscalls\n- Implement COBOL arithmetic/branching\n- Write more on-chain COBOL programs\n- Make the error messages less terrifying\n\n## Star This Repo\n\nIf this made you smile, give it a ⭐\n\nIf this made you cry, also give it a ⭐\n\nIf you worked in COBOL in the 80s and this triggered your PTSD, definitely give it a ⭐\n\n---\n\nBuilt with ❤️ and questionable life choices.\n\n**COBOL on Solana. Because someone had to.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitorpy%2Fcobolana","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitorpy%2Fcobolana","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitorpy%2Fcobolana/lists"}