Commit graph

6 commits

Author SHA1 Message Date
Graeme Geldenhuys 4fbfdfdbba Add semantic analyser with type inference and checking
TSemanticAnalyser walks the AST, resolves all identifiers via the symbol
table, annotates every expression node with ResolvedType, and type-checks
assignments and procedure calls. Raises ESemanticError with source position
on undeclared identifiers, type mismatches, duplicate declarations, and
unknown types. TProgram now owns the TSymbolTable after analysis so
ResolvedType pointers remain valid for the lifetime of the AST.

Also adds the 'div' keyword for integer division throughout the pipeline
(lexer, parser, semantic). 26 new FPCUnit tests, 126 total, all passing.
2026-04-20 17:58:27 +01:00
Graeme Geldenhuys a561525ebd Add symbol table with scope nesting and built-in types
TSymbolTable manages a scope stack with case-insensitive lookup. Each
TScope holds a sorted TStringList (names → TSymbol) and chains to its
parent for identifier resolution. Built-in primitives (Integer, Int64,
UInt32, Byte, Boolean, string) and I/O procedures (Write, WriteLn) are
pre-registered in the global scope. 29 FPCUnit tests, all passing.
2026-04-20 17:52:09 +01:00
Graeme Geldenhuys 95e1ea58af Add FPC-compatible CLI mode to Blaise compiler
Blaise can now act as a drop-in FPC replacement for PasBuild when
invoked via `pasbuild compile --fpc /path/to/blaise`.

- Detects FPC-style invocation (single-dash flags vs. native double-dash)
- Handles -iV / -iTP / -iTO probe queries PasBuild uses before compiling
- Maps -FE<dir>, -o<name> to output path; silently ignores -Fu, -FU,
  -Mobjfpc, -O<n>, -g, -gl, -CX and unknown single-dash flags
- Native --source / --output / --emit-ir mode is fully preserved
2026-04-20 17:37:14 +01:00
Graeme Geldenhuys 25de8be212 Fix compilation errors; vendor QBE 1.2; end-to-end Hello World works
Fix TProgram.Uses reserved-word clash (renamed to UsedUnits), nested
brace-comment in uParser.pas, and missing uAST in Blaise.pas uses clause.

Vendor QBE 1.2 source in vendor/qbe/ (built locally with make; binary
excluded via .gitignore). End-to-end pipeline confirmed: Blaise compiles
Hello World and Calc (6*7=42) to native x86_64 Linux binaries.

71/71 FPCUnit tests passing.
2026-04-20 16:38:57 +01:00
Graeme Geldenhuys 3fce5f86de Phase 1 bootstrap: Blaise compiler skeleton
Renames the project from 'Clean Pascal' to Blaise (after Blaise Pascal).
Adds the Phase 1 compiler pipeline with TDD test suite:

- uPasTokeniser: general Pascal tokeniser (ported from fpGUI IDE)
- uLexer: compiler-specific adapter — filters whitespace/comments,
  maps to TTokenKind, unescapes string literals
- uAST: typed AST node hierarchy (TProgram, TBlock, TBinaryExpr, etc.)
- uParser: recursive-descent parser for the Phase 1 BNF grammar
- uCodeGenQBE: QBE IR emitter — WriteLn/Write built-ins, integer
  variables, arithmetic, string literals
- Blaise.pas: compiler driver — parses flags, shells to qbe+cc
- FPCUnit test suites for lexer, parser, and code generator
2026-04-20 15:35:50 +01:00
Graeme Geldenhuys fd79a7db98 Initial project scaffold
PasBuild multi-module layout with three modules: compiler (application),
rtl (library), and tools/migration-analyser (application). Includes root
aggregator project.xml, debug/release build profiles, BSD 3-Clause licence,
README, .gitignore, and design document. QBE vendored as the Phase 1
backend. Bootstrap requires FPC 3.2.2.
2026-04-20 14:22:10 +01:00