Skip to content

Tidying up shit. - #4

Merged
LowLevelLore merged 2 commits into
mainfrom
dev
Jun 22, 2025
Merged

Tidying up shit.#4
LowLevelLore merged 2 commits into
mainfrom
dev

Conversation

@LowLevelLore

@LowLevelLore LowLevelLore commented Jun 22, 2025

Copy link
Copy Markdown
Owner

Summary by Sourcery

Refactor project structure, improve build system, extend code generation targets, and enhance documentation and tests

New Features:

  • Add code generation support for Windows (x86_64-windows) and LLVM IR targets
  • Introduce a test runner script and categorized test suite under tests/

Enhancements:

  • Reorganize project layout with modular include/ and src/ subdirectories (common, support, ast, lexer, parser, typechecker, codegen)
  • Replace Makefile with CMakeLists.txt for cross-platform builds

Documentation:

  • Overhaul README with updated prerequisites, build instructions, and usage examples for Linux (x86_64 and LLVM IR) and Windows
  • Update example program to a factorial implementation in zlang

Tests:

  • Add tests/ directory with structured test cases and test_runner.py script

Chores:

  • Add LICENSE file and remove .vscode settings

@sourcery-ai

sourcery-ai Bot commented Jun 22, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR restructures the project into modular include/src hierarchies, adds cross-platform codegen backends, replaces the Makefile with a CMake-based build and test harness, and enriches the README with detailed multi-target usage and a new example.

Class diagram for modularized include/src structure

classDiagram
    class Logging {
      <<utility>>
      +logInfo()
      +logError()
    }
    class StringUtils {
      <<utility>>
      +split()
      +join()
    }
    class CommandLine {
      +parseArgs()
    }
    class File {
      +read()
      +write()
    }
    class ASTNode {
      +type
      +children
    }
    class Lexer {
      +tokenize()
    }
    class Parser {
      +parse()
    }
    class ScopeContext {
      +symbols
    }
    class TypeChecker {
      +check()
    }
    class CodeGen {
      +generate()
    }
    class CodeGenLinux {
      +generateLinuxAsm()
    }
    class CodeGenWindows {
      +generateWindowsAsm()
    }
    class CodeGenLLVM {
      +generateLLVMIR()
    }
    class RegisterAllocator {
      +allocate()
    }
    Logging <|-- StringUtils
    Parser --> ASTNode
    Parser --> ScopeContext
    TypeChecker --> ASTNode
    CodeGen <|-- CodeGenLinux
    CodeGen <|-- CodeGenWindows
    CodeGen <|-- CodeGenLLVM
    CodeGen --> RegisterAllocator
Loading

File-Level Changes

Change Details Files
Reorganized headers into modular include subdirectories
  • Created common and support directories under include
  • Moved AST, lexer, parser, typechecker, and codegen headers into respective folders
  • Added shared utilities (Colors, Errors, Logging, StringUtils)
include/common/Colors.hpp
include/common/Errors.hpp
include/common/Logging.hpp
include/common/StringUtils.hpp
include/support/CommandLine.hpp
include/support/File.hpp
include/ast/ASTNode.hpp
include/lexer/Lexer.hpp
include/parser/Parser.hpp
include/parser/ScopeContext.hpp
include/typechecker/TypeChecker.hpp
include/codegen/CodeGen.hpp
include/codegen/Canaries.hpp
include/codegen/RegisterAllocator.hpp
Mirrored modular structure in source files
  • Created source modules for common and support
  • Moved implementations for AST, lexer, parser, and typechecker
  • Added codegen backends for Windows, Linux and LLVM
src/common/Logging.cpp
src/common/StringUtils.cpp
src/support/CommandLine.cpp
src/support/File.cpp
src/ast/ASTNode.cpp
src/lexer/Lexer.cpp
src/parser/ScopeContext.cpp
src/parser/Parser.cpp
src/typechecker/TypeChecker.cpp
src/codegen/CodeGenWindows.cpp
src/codegen/CodeGenLinux.cpp
src/codegen/CodeGenLLVM.cpp
src/codegen/RegisterAllocator.cpp
Overhauled build and test infrastructure
  • Removed the old Makefile
  • Introduced CMakeLists.txt for cross-platform builds
  • Added test_runner.py for automated testing
Makefile
CMakeLists.txt
test_runner.py
Expanded README with multi-target usage and example
  • Updated prerequisites to include GNU, ml64, llc & clang
  • Documented compile/link/run steps for x86_64-linux, llvm-ir, and x86_64-windows
  • Replaced the sample program with a factorial example
README.md
Added tests and example directories
  • Added categorized tests under tests/zz
  • Added an examples folder for current work
tests/zz/
examples/
Cleaned up legacy editor config
  • Removed outdated VSCode settings
  • Pruned legacy example placeholders
.vscode/settings.json
examples/functions.zz

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @LowLevelLore - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@LowLevelLore
LowLevelLore merged commit 038aab0 into main Jun 22, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant