How h1ghbre4k3r/pesca-lang works
Project type and purpose
• This is a compiler-style project written in Rust, implementing an experimental programming language called “Pesca”.
• It provides:
• A core library (why_lib) that performs lexing, parsing, and type checking
• A derive macro crate (lex_derive) to generate lexers at compile time
• Two CLI front-ends:
– yc (the compiler driver)
– yls (the language-server for editor integration)
• Documentation (in docs/) and example programs under examples/.
File structure
• Top-level Cargo workspace with Cargo.toml and two binaries in src/bin/: yc.rs and yls.rs.
• crates/lex_derive: a Rust proc-macro crate that generates lexing code based on token definitions.
• crates/why_lib: the core library, subdivided into modules:
• lexer/ – definitions for tokens, lexmap, and the generated lexer
• parser/ – parser combinators, ParseState, and AST definitions (ast/)
• typechecker/ – context, error handling, scope management, and the construction of a typed AST
• docs/: mdBook sources describing language features and usage.
• examples/: sample .why programs used to test the language front end.
Readme insights
• Emphasizes that “everything is an expression” and outlines language syntax (expressions, control flow, functions).
• Mentions that the executable is rudimentary but that the project is a playground for restarting a programming language.
Main components and relationships
a. Components
• Source code files (.why)
• Compiler binary (yc)
• Language server binary (yls)
• Core library (why_lib):
– Lexer (proc-macro generated via lex_derive)
– Parser (parser combinators → AST)
– Typechecker (untyped AST → typed AST)
• Derive macro crate (lex_derive)
• Documentation (mdBook)
• Examples
b. Interactions / Data flow
1. yc / yls loads a .why source file
2. why_lib::lexer (with code generated by lex_derive) tokenizes input → stream of tokens
3. why_lib::parser consumes tokens → constructs an untyped AST
4. why_lib::typechecker consumes untyped AST → produces a typed AST or errors
5. Depending on CLI:
– yc might proceed to code generation or IR (not yet implemented)
– yls uses AST and typed AST to provide editor services
c. Architectural patterns / design principles
• Pipeline architecture (lexer → parser → typechecker → [future] codegen)
• Separation of concerns: proc-macro crate (lex_derive) separated from core logic
• Library + CLI front-ends pattern – reusing why_lib for multiple executables
d. Key technologies and frameworks
• Rust Cargo workspace and crates
• Rust proc-macros (lex_derive)
• Parser combinators in Rust
• mdBook for documentation
Elements
• Source files (.why)
• yc binary
• yls binary
• lex_derive proc-macro crate
• Documentation and examples as side artifacts
• Another for binaries
Detail
• That both yc and yls share the same pipeline
• A “future” codegen stage to capture the full intended architecture