Skip to content

ITCraftDevelopmentTeam/SakuraE

Repository files navigation

🌸SakuraE🌸

简体中文

Based on LLVM, A Compilable Programming Language

TODO List

For now version dev 0.0:

  • Basic Variable Declaration
  • Variable Assignment
  • Array Declaration
  • Function Declaration and Calling
  • More Type Checker
  • Complete Runtime Support
  • Complete String Implement
  • Language Flexibility
  • Structure Declaration and Using
  • Module System

Project Structure (Main)

Warning

This part was generated by AI

SakuraE/
├── CMakeLists.txt                  # CMake build configuration file
├── main.cpp                        # Main entry point of the compiler
├── atrI/                           # Interactive CLI and configuration management
│   ├── atrI.hpp                    # Main header for atrI
│   ├── commands.hpp                # CLI command definitions
│   ├── README.md                   # atrI documentation
│   ├── utils.hpp                   # Utility functions for CLI
│   └── config/                     # Configuration management
│       └── config.hpp              # Configuration definitions
├── Compiler/                       # Core compiler components
│   ├── Error/                      # Error handling utilities
│   │   └── error.hpp               # Error definitions and handling
│   ├── Frontend/                   # Frontend components (lexer, parser, AST)
│   │   ├── AST.hpp                 # Abstract Syntax Tree definitions
│   │   ├── grammar.txt             # Grammar rules for parsing
│   │   ├── lexer.cpp               # Lexical analyzer implementation
│   │   ├── lexer.h                 # Lexer header
│   │   ├── parser_base.hpp         # Base parser utilities and parser combinators
│   │   ├── parser.cpp              # Parser implementation
│   │   └── parser.hpp              # Parser header
│   ├── IR/                         # Intermediate Representation (IR) module
│   │   ├── docs/                   # IR documentation and specifications
│   │   ├── generator.cpp           # IR generator implementation (AST visitor)
│   │   ├── generator.hpp           # IR generation utilities
│   │   ├── IR.hpp                  # Core IR definitions
│   │   ├── README-zh_cn.md         # IR documentation (Chinese)
│   │   ├── README.md               # IR documentation (English)
│   │   ├── struct/                 # IR structural components
│   │   │   ├── block.hpp           # Basic block representation
│   │   │   ├── function.hpp        # Function representation with scope management
│   │   │   ├── instruction.hpp     # Instruction definitions and OpKind enum
│   │   │   ├── module.hpp          # Module representation
│   │   │   ├── program.hpp         # Program-level IR
│   │   │   └── scope.hpp           # Scope management for symbols
│   │   ├── type/                   # Type system
│   │   │   ├── type.cpp            # IRType implementation
│   │   │   ├── type.hpp            # IRType definitions (int, float, array, pointer, etc.)
│   │   │   ├── type_info.cpp       # TypeInfo implementation
│   │   │   └── type_info.hpp       # TypeInfo for frontend type representation
│   │   └── value/                  # Value and constant systems
│   │       ├── constant.cpp        # Constant value implementation
│   │       ├── constant.hpp        # Constant value definitions
│   │       └── value.hpp           # Value representations
│   ├── LLVMCodegen/                # LLVM Backend Codegen module
│   │   ├── LLVMCodegenerator.cpp   # Implementation of sakIR to LLVM IR conversion
│   │   └── LLVMCodegenerator.hpp   # LLVM Codegen definitions and state management
│   └── Utils/                      # Utility functions
│       └── Logger.hpp              # Logging utilities
├── Runtime/                        # Runtime Library
│   ├── alloc.cpp                   # Memory allocator implementation
│   ├── alloc.h                     # Allocator header
│   ├── print.cpp                   # Basic I/O implementation
│   ├── raw_string.cpp              # String manipulation implementation
│   ├── README-zh_cn.md             # Runtime documentation (Chinese)
│   └── README.md                   # Runtime documentation (English)
├── includes/                       # External dependencies
│   ├── magic_enum.hpp              # Enum reflection library
│   └── String.hpp                  # Custom string utilities
├── sakurae/                        # VSCode Extension
│   ├── language-configuration.json # Language configuration
│   ├── package.json                # Extension manifest
│   ├── README.md                   # Extension documentation
│   └── syntaxes/                   # Syntax highlighting
│       └── sak.tmLanguage.json     # TextMate grammar for SakuraE
└── README.md                       # This file

Build

Prerequisites

  • C++ Compiler: GCC 13+ or Clang 16+ supporting C++23 (as specified in CMakeLists.txt).
  • CMake: Version 3.24 or higher.
  • LLVM: Version 16+ installed and configured (required for the project, as it uses LLVM libraries).
  • Ninja: Version 1.13.2

Build Steps

  1. Clone the repository:

    git clone https://github.com/powerangelxd/SakuraE.git
    cd SakuraE
  2. Create build directory:

    mkdir build
    cd build
  3. Configure with CMake:

    cmake -G Ninja ..

    This will detect LLVM and set up the build with C++23 standard and necessary flags using Ninja.

  4. Build the project:

    ninja
  5. Create a .sak file in folder build

    touch test.sak

    Then write this program for test:

    func fib(n: int) -> int {
       if (n <= 1) {
          return n;
       }
       return fib(n - 1) + fib(n - 2);
    }
    
    func main() -> int {
       __println("Hello world, check fib(21):");
       return fib(21);
    }
    echo "func fib(n: int) -> int {
     if (n <= 1) {
         return n;
     }
     return fib(n - 1) + fib(n - 2);
    }
    
    func main() -> int {
        __println(\"Hello world, check fib(21):\");
        return fib(21);
    }" >> test.sak
  6. Run the compiler (optional test):

    ./SakuraE

If you encounter issues, ensure LLVM development libraries are installed (e.g., llvm-dev package) and llvm-config is available in PATH.

IR Developing

For more detailed development specifications regarding the IR, please click the link below.

IR README

Runtime Library

If you want to know something about SakuraE Runtime Library, Click the link:

SakuraE Runtime Library

Contributor

Sponsor

  • SendsTeam : Provide LLM Service during developing

About

SakuraE is a simple, compiled language based on LLVM.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages