Go to file
lyc d01963b9e8 update: readme 2024-12-17 21:02:24 +08:00
antlr style 2024-12-02 22:32:57 +08:00
assest update 2024-12-06 00:37:07 +08:00
grammar have est 2024-12-02 22:24:15 +08:00
include update: readme 2024-12-17 21:02:24 +08:00
src update: readme 2024-12-17 21:02:24 +08:00
test init3 2024-12-02 23:35:48 +08:00
.gitignore init 2024-12-02 21:52:40 +08:00
CMakeLists.txt init4 2024-12-03 00:06:45 +08:00
README.md update: readme 2024-12-17 21:02:24 +08:00
main.cpp update: readme 2024-12-17 21:02:24 +08:00
test_all.sh init3 2024-12-02 23:35:48 +08:00

README.md

环境

  • x86 Debian GNU/Linux 12
  • Python 3.11.2
  • gcc version 12.2.2
  • openJDK version "17.0.12"
  • NASM version 2.16.01
  • antlr complete & runtime Version: 4.9.3
  • glog
  • 请使用C++17以上标准

构建

mkdir build && cd build
cmake ..
make -j4

批量执行

bash test_all.sh

详细说明

  • 可执行文件 LiteGoCompiler
  • 用法
./LiteGoCompiler /path/to/gofile
  • 所需库 print.o 负责向标准输出打印结果
  • 源文件同级文件夹下生成中间产物
    • out.asm 三地址中间代码
    • out.o 二进制编译产物
  • 目标可执行文件 out.bin

文件结构

.
├── antlr -------------------------- 存放 antlr jar 包和 runtime
│   └── antlr4-runtime
│       
├── grammar ------------------------ 存放 Go 语言语法文件和 antlr 针对 Cpp 的解析结果
│   └── cpp
├── include ------------------------ 代码头文件
│   ├── ICG
│   ├── Public
│   └── TCG
├── src ----------------------------- 源代码
│   ├── ICG ------------------------- 中间代码生成相关,对接 antlr
│   ├── Public ---------------------- 定义了一些公共宏,三地址操作,符号解析和管理
│   └── TCG ------------------------- 目标代码生成相关
│
└── test ---------------------------- 测试文件

代码架构

code