$ show BosqueLanguage/BosqueCore
BosqueCore is a compiler and toolchain for the Bosque programming language, a research-oriented language emphasizing mechanized reasoning, deterministic execution, and safe-by-design programming. The repository implements a full compilation pipeline in TypeScript: a recursive-descent parser and lexer, a semantic type checker with advanced features (invariants, pre/post conditions, validated strings, numeric range types), an IR with monomorphization, and a C++ backend that generates garbage-collected, allocation-aware code. The CLI (`src/cmd/bosque.ts`) compiles `.bsq` files to C++ and produces executables via a Makefile build system. Extensive tests cover parser, typechecker, C++ emission, and runtime execution of sample programs (raytracer, nbody, binary tree). The architecture is cleanly split between frontend (AST, parsing, checking) and backend (IR, monomorphization, C++ emission), with a hand-written recursion-descent parser and a highly detailed type system. However, the codebase is a work in progress: many language features are explicitly unimplemented (tasks, switch, dispatch, multi-return, resource/env handling) with `assert(false, "Not implemented")` stubs, and large monolithic files (e.g., `parser.ts`, `checker.ts`, `flatten.ts`) concentrate complexity. The repository also includes a C++ runtime with a custom GC and allocators, plus a lexer/serializer for the BAPI IR format. As a research project transitioning toward practical use, it offers a unique, safety-focused language design but is not yet production-ready.
The LLM identified 2 files worth highlighting for reuse:
A generic lexer for the BAPI IR text format, providing tokenization, token classification, and helper functions like `parseListOf`. It is isolated from the rest of the compiler and could be extracted as a standalone tokenizer for a lightweight structured text format.
A name manager that transforms Bosque identifiers into valid C++ names while avoiding collisions and C++ keywords (e.g., replacing `::` with Unicode characters). This pattern is portable and reusable for any code generator that needs to produce C++-safe identifiers from arbitrary symbol names.