forked from NUDT-compiler/nudt-compiler-cpp
Compare commits
No commits in common. 'master' and 'master' have entirely different histories.
@ -1,201 +1,17 @@
|
|||||||
#ifndef SYMBOL_TABLE_H
|
// 极简符号表:记录局部变量定义点。
|
||||||
#define SYMBOL_TABLE_H
|
#pragma once
|
||||||
|
|
||||||
#include <any>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <stack>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
// 核心类型枚举
|
#include "SysYParser.h"
|
||||||
enum class SymbolType {
|
|
||||||
TYPE_UNKNOWN, // 未知类型
|
|
||||||
TYPE_INT, // 整型
|
|
||||||
TYPE_FLOAT, // 浮点型
|
|
||||||
TYPE_VOID, // 空类型
|
|
||||||
TYPE_ARRAY, // 数组类型
|
|
||||||
TYPE_FUNCTION // 函数类型
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取类型名称字符串
|
|
||||||
inline const char* SymbolTypeToString(SymbolType type) {
|
|
||||||
switch (type) {
|
|
||||||
case SymbolType::TYPE_INT: return "int";
|
|
||||||
case SymbolType::TYPE_FLOAT: return "float";
|
|
||||||
case SymbolType::TYPE_VOID: return "void";
|
|
||||||
case SymbolType::TYPE_ARRAY: return "array";
|
|
||||||
case SymbolType::TYPE_FUNCTION: return "function";
|
|
||||||
default: return "unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 变量信息结构体
|
|
||||||
struct VarInfo {
|
|
||||||
SymbolType type = SymbolType::TYPE_UNKNOWN;
|
|
||||||
bool is_const = false;
|
|
||||||
std::any const_val;
|
|
||||||
std::vector<int> array_dims; // 数组维度,空表示非数组
|
|
||||||
void* decl_ctx = nullptr; // 关联的语法节点
|
|
||||||
|
|
||||||
// 检查是否为数组类型
|
|
||||||
bool IsArray() const { return !array_dims.empty(); }
|
|
||||||
|
|
||||||
// 获取数组元素总数
|
|
||||||
int GetArrayElementCount() const {
|
|
||||||
int count = 1;
|
|
||||||
for (int dim : array_dims) {
|
|
||||||
count *= dim;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 函数信息结构体
|
|
||||||
struct FuncInfo {
|
|
||||||
SymbolType ret_type = SymbolType::TYPE_UNKNOWN;
|
|
||||||
std::string name;
|
|
||||||
std::vector<SymbolType> param_types; // 参数类型列表
|
|
||||||
void* decl_ctx = nullptr; // 关联的语法节点
|
|
||||||
|
|
||||||
// 检查参数匹配
|
|
||||||
bool CheckParams(const std::vector<SymbolType>& actual_params) const {
|
|
||||||
if (actual_params.size() != param_types.size()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < param_types.size(); ++i) {
|
|
||||||
if (param_types[i] != actual_params[i] &&
|
|
||||||
param_types[i] != SymbolType::TYPE_UNKNOWN &&
|
|
||||||
actual_params[i] != SymbolType::TYPE_UNKNOWN) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 作用域条目结构体
|
|
||||||
struct ScopeEntry {
|
|
||||||
// 变量符号表:符号名 -> (符号信息, 声明节点)
|
|
||||||
std::unordered_map<std::string, std::pair<VarInfo, void*>> var_symbols;
|
|
||||||
|
|
||||||
// 函数符号表:符号名 -> (函数信息, 声明节点)
|
|
||||||
std::unordered_map<std::string, std::pair<FuncInfo, void*>> func_symbols;
|
|
||||||
|
|
||||||
// 清空作用域
|
|
||||||
void Clear() {
|
|
||||||
var_symbols.clear();
|
|
||||||
func_symbols.clear();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 符号表核心类
|
|
||||||
class SymbolTable {
|
class SymbolTable {
|
||||||
public:
|
public:
|
||||||
// ========== 作用域管理 ==========
|
void Add(const std::string& name, SysYParser::VarDefContext* decl);
|
||||||
|
bool Contains(const std::string& name) const;
|
||||||
// 进入新作用域
|
SysYParser::VarDefContext* Lookup(const std::string& name) const;
|
||||||
void EnterScope();
|
|
||||||
|
|
||||||
// 离开当前作用域
|
|
||||||
void LeaveScope();
|
|
||||||
|
|
||||||
// 获取当前作用域深度
|
|
||||||
size_t GetScopeDepth() const { return scopes_.size(); }
|
|
||||||
|
|
||||||
// 检查作用域栈是否为空
|
|
||||||
bool IsEmpty() const { return scopes_.empty(); }
|
|
||||||
|
|
||||||
// ========== 变量符号管理 ==========
|
|
||||||
|
|
||||||
// 检查当前作用域是否包含指定变量
|
|
||||||
bool CurrentScopeHasVar(const std::string& name) const;
|
|
||||||
|
|
||||||
// 绑定变量到当前作用域
|
|
||||||
void BindVar(const std::string& name, const VarInfo& info, void* decl_ctx);
|
|
||||||
|
|
||||||
// 查找变量(从当前作用域向上遍历)
|
|
||||||
bool LookupVar(const std::string& name, VarInfo& out_info, void*& out_decl_ctx) const;
|
|
||||||
|
|
||||||
// 快速查找变量(不获取详细信息)
|
private:
|
||||||
bool HasVar(const std::string& name) const {
|
std::unordered_map<std::string, SysYParser::VarDefContext*> table_;
|
||||||
VarInfo info;
|
|
||||||
void* ctx;
|
|
||||||
return LookupVar(name, info, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 函数符号管理 ==========
|
|
||||||
|
|
||||||
// 检查当前作用域是否包含指定函数
|
|
||||||
bool CurrentScopeHasFunc(const std::string& name) const;
|
|
||||||
|
|
||||||
// 绑定函数到当前作用域
|
|
||||||
void BindFunc(const std::string& name, const FuncInfo& info, void* decl_ctx);
|
|
||||||
|
|
||||||
// 查找函数(从当前作用域向上遍历)
|
|
||||||
bool LookupFunc(const std::string& name, FuncInfo& out_info, void*& out_decl_ctx) const;
|
|
||||||
|
|
||||||
// 快速查找函数(不获取详细信息)
|
|
||||||
bool HasFunc(const std::string& name) const {
|
|
||||||
FuncInfo info;
|
|
||||||
void* ctx;
|
|
||||||
return LookupFunc(name, info, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 循环状态管理 ==========
|
|
||||||
|
|
||||||
// 进入循环
|
|
||||||
void EnterLoop();
|
|
||||||
|
|
||||||
// 离开循环
|
|
||||||
void ExitLoop();
|
|
||||||
|
|
||||||
// 检查是否在循环内
|
|
||||||
bool InLoop() const;
|
|
||||||
|
|
||||||
// 获取循环嵌套深度
|
|
||||||
int GetLoopDepth() const { return loop_depth_; }
|
|
||||||
|
|
||||||
// ========== 辅助功能 ==========
|
|
||||||
|
|
||||||
// 清空所有作用域和状态
|
|
||||||
void Clear();
|
|
||||||
|
|
||||||
// 获取当前作用域中所有变量名
|
|
||||||
std::vector<std::string> GetCurrentScopeVarNames() const;
|
|
||||||
|
|
||||||
// 获取当前作用域中所有函数名
|
|
||||||
std::vector<std::string> GetCurrentScopeFuncNames() const;
|
|
||||||
|
|
||||||
// 调试:打印符号表内容
|
|
||||||
void Dump() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// 作用域栈
|
|
||||||
std::stack<ScopeEntry> scopes_;
|
|
||||||
|
|
||||||
// 循环嵌套深度
|
|
||||||
int loop_depth_ = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 类型兼容性检查函数
|
|
||||||
inline bool IsTypeCompatible(SymbolType expected, SymbolType actual) {
|
|
||||||
if (expected == SymbolType::TYPE_UNKNOWN || actual == SymbolType::TYPE_UNKNOWN) {
|
|
||||||
return true; // 未知类型视为兼容
|
|
||||||
}
|
|
||||||
|
|
||||||
// 基本类型兼容规则
|
|
||||||
if (expected == actual) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// int 可以隐式转换为 float
|
|
||||||
if (expected == SymbolType::TYPE_FLOAT && actual == SymbolType::TYPE_INT) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // SYMBOL_TABLE_H
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "nudt-compiler-cpp",
|
|
||||||
"lockfileVersion": 2,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {}
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
@ -1,3 +0,0 @@
|
|||||||
This project is dual-licensed under the Unlicense and MIT licenses.
|
|
||||||
|
|
||||||
You may use this code under the terms of either license.
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,46 +0,0 @@
|
|||||||
# `@img/sharp-libvips-linux-x64`
|
|
||||||
|
|
||||||
Prebuilt libvips and dependencies for use with sharp on Linux (glibc) x64.
|
|
||||||
|
|
||||||
## Licensing
|
|
||||||
|
|
||||||
This software contains third-party libraries
|
|
||||||
used under the terms of the following licences:
|
|
||||||
|
|
||||||
| Library | Used under the terms of |
|
|
||||||
|---------------|-----------------------------------------------------------------------------------------------------------|
|
|
||||||
| aom | BSD 2-Clause + [Alliance for Open Media Patent License 1.0](https://aomedia.org/license/patent-license/) |
|
|
||||||
| cairo | Mozilla Public License 2.0 |
|
|
||||||
| cgif | MIT Licence |
|
|
||||||
| expat | MIT Licence |
|
|
||||||
| fontconfig | [fontconfig Licence](https://gitlab.freedesktop.org/fontconfig/fontconfig/blob/main/COPYING) (BSD-like) |
|
|
||||||
| freetype | [freetype Licence](https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT) (BSD-like) |
|
|
||||||
| fribidi | LGPLv3 |
|
|
||||||
| glib | LGPLv3 |
|
|
||||||
| harfbuzz | MIT Licence |
|
|
||||||
| highway | Apache-2.0 License, BSD 3-Clause |
|
|
||||||
| lcms | MIT Licence |
|
|
||||||
| libarchive | BSD 2-Clause |
|
|
||||||
| libexif | LGPLv3 |
|
|
||||||
| libffi | MIT Licence |
|
|
||||||
| libheif | LGPLv3 |
|
|
||||||
| libimagequant | [BSD 2-Clause](https://github.com/lovell/libimagequant/blob/main/COPYRIGHT) |
|
|
||||||
| libnsgif | MIT Licence |
|
|
||||||
| libpng | [libpng License](https://github.com/pnggroup/libpng/blob/master/LICENSE) |
|
|
||||||
| librsvg | LGPLv3 |
|
|
||||||
| libspng | [BSD 2-Clause, libpng License](https://github.com/randy408/libspng/blob/master/LICENSE) |
|
|
||||||
| libtiff | [libtiff License](https://gitlab.com/libtiff/libtiff/blob/master/LICENSE.md) (BSD-like) |
|
|
||||||
| libvips | LGPLv3 |
|
|
||||||
| libwebp | New BSD License |
|
|
||||||
| libxml2 | MIT Licence |
|
|
||||||
| mozjpeg | [zlib License, IJG License, BSD-3-Clause](https://github.com/mozilla/mozjpeg/blob/master/LICENSE.md) |
|
|
||||||
| pango | LGPLv3 |
|
|
||||||
| pixman | MIT Licence |
|
|
||||||
| proxy-libintl | LGPLv3 |
|
|
||||||
| zlib-ng | [zlib Licence](https://github.com/zlib-ng/zlib-ng/blob/develop/LICENSE.md) |
|
|
||||||
|
|
||||||
Use of libraries under the terms of the LGPLv3 is via the
|
|
||||||
"any later version" clause of the LGPLv2 or LGPLv2.1.
|
|
||||||
|
|
||||||
Please report any errors or omissions via
|
|
||||||
https://github.com/lovell/sharp-libvips/issues/new
|
|
||||||
@ -1,221 +0,0 @@
|
|||||||
/* glibconfig.h
|
|
||||||
*
|
|
||||||
* This is a generated file. Please modify 'glibconfig.h.in'
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GLIBCONFIG_H__
|
|
||||||
#define __GLIBCONFIG_H__
|
|
||||||
|
|
||||||
#include <glib/gmacros.h>
|
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
#include <float.h>
|
|
||||||
#define GLIB_HAVE_ALLOCA_H
|
|
||||||
|
|
||||||
#define GLIB_STATIC_COMPILATION 1
|
|
||||||
#define GOBJECT_STATIC_COMPILATION 1
|
|
||||||
#define GIO_STATIC_COMPILATION 1
|
|
||||||
#define GMODULE_STATIC_COMPILATION 1
|
|
||||||
#define GI_STATIC_COMPILATION 1
|
|
||||||
#define G_INTL_STATIC_COMPILATION 1
|
|
||||||
#define FFI_STATIC_BUILD 1
|
|
||||||
|
|
||||||
/* Specifies that GLib's g_print*() functions wrap the
|
|
||||||
* system printf functions. This is useful to know, for example,
|
|
||||||
* when using glibc's register_printf_function().
|
|
||||||
*/
|
|
||||||
#define GLIB_USING_SYSTEM_PRINTF
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define G_MINFLOAT FLT_MIN
|
|
||||||
#define G_MAXFLOAT FLT_MAX
|
|
||||||
#define G_MINDOUBLE DBL_MIN
|
|
||||||
#define G_MAXDOUBLE DBL_MAX
|
|
||||||
#define G_MINSHORT SHRT_MIN
|
|
||||||
#define G_MAXSHORT SHRT_MAX
|
|
||||||
#define G_MAXUSHORT USHRT_MAX
|
|
||||||
#define G_MININT INT_MIN
|
|
||||||
#define G_MAXINT INT_MAX
|
|
||||||
#define G_MAXUINT UINT_MAX
|
|
||||||
#define G_MINLONG LONG_MIN
|
|
||||||
#define G_MAXLONG LONG_MAX
|
|
||||||
#define G_MAXULONG ULONG_MAX
|
|
||||||
|
|
||||||
typedef signed char gint8;
|
|
||||||
typedef unsigned char guint8;
|
|
||||||
|
|
||||||
typedef signed short gint16;
|
|
||||||
typedef unsigned short guint16;
|
|
||||||
|
|
||||||
#define G_GINT16_MODIFIER "h"
|
|
||||||
#define G_GINT16_FORMAT "hi"
|
|
||||||
#define G_GUINT16_FORMAT "hu"
|
|
||||||
|
|
||||||
|
|
||||||
typedef signed int gint32;
|
|
||||||
typedef unsigned int guint32;
|
|
||||||
|
|
||||||
#define G_GINT32_MODIFIER ""
|
|
||||||
#define G_GINT32_FORMAT "i"
|
|
||||||
#define G_GUINT32_FORMAT "u"
|
|
||||||
|
|
||||||
|
|
||||||
#define G_HAVE_GINT64 1 /* deprecated, always true */
|
|
||||||
|
|
||||||
typedef signed long gint64;
|
|
||||||
typedef unsigned long guint64;
|
|
||||||
|
|
||||||
#define G_GINT64_CONSTANT(val) (val##L)
|
|
||||||
#define G_GUINT64_CONSTANT(val) (val##UL)
|
|
||||||
|
|
||||||
#define G_GINT64_MODIFIER "l"
|
|
||||||
#define G_GINT64_FORMAT "li"
|
|
||||||
#define G_GUINT64_FORMAT "lu"
|
|
||||||
|
|
||||||
|
|
||||||
#define GLIB_SIZEOF_VOID_P 8
|
|
||||||
#define GLIB_SIZEOF_LONG 8
|
|
||||||
#define GLIB_SIZEOF_SIZE_T 8
|
|
||||||
#define GLIB_SIZEOF_SSIZE_T 8
|
|
||||||
|
|
||||||
typedef signed long gssize;
|
|
||||||
typedef unsigned long gsize;
|
|
||||||
#define G_GSIZE_MODIFIER "l"
|
|
||||||
#define G_GSSIZE_MODIFIER "l"
|
|
||||||
#define G_GSIZE_FORMAT "lu"
|
|
||||||
#define G_GSSIZE_FORMAT "li"
|
|
||||||
|
|
||||||
#define G_MAXSIZE G_MAXULONG
|
|
||||||
#define G_MINSSIZE G_MINLONG
|
|
||||||
#define G_MAXSSIZE G_MAXLONG
|
|
||||||
|
|
||||||
typedef gint64 goffset;
|
|
||||||
#define G_MINOFFSET G_MININT64
|
|
||||||
#define G_MAXOFFSET G_MAXINT64
|
|
||||||
|
|
||||||
#define G_GOFFSET_MODIFIER G_GINT64_MODIFIER
|
|
||||||
#define G_GOFFSET_FORMAT G_GINT64_FORMAT
|
|
||||||
#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
|
|
||||||
|
|
||||||
#define G_POLLFD_FORMAT "%d"
|
|
||||||
|
|
||||||
#define GPOINTER_TO_INT(p) ((gint) (glong) (p))
|
|
||||||
#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p))
|
|
||||||
|
|
||||||
#define GINT_TO_POINTER(i) ((gpointer) (glong) (i))
|
|
||||||
#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u))
|
|
||||||
|
|
||||||
typedef signed long gintptr;
|
|
||||||
typedef unsigned long guintptr;
|
|
||||||
|
|
||||||
#define G_GINTPTR_MODIFIER "l"
|
|
||||||
#define G_GINTPTR_FORMAT "li"
|
|
||||||
#define G_GUINTPTR_FORMAT "lu"
|
|
||||||
|
|
||||||
#define GLIB_MAJOR_VERSION 2
|
|
||||||
#define GLIB_MINOR_VERSION 86
|
|
||||||
#define GLIB_MICRO_VERSION 1
|
|
||||||
|
|
||||||
#define G_OS_UNIX
|
|
||||||
|
|
||||||
#define G_VA_COPY va_copy
|
|
||||||
|
|
||||||
#define G_VA_COPY_AS_ARRAY 1
|
|
||||||
|
|
||||||
#define G_HAVE_ISO_VARARGS 1
|
|
||||||
|
|
||||||
/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
|
|
||||||
* is passed ISO vararg support is turned off, and there is no work
|
|
||||||
* around to turn it on, so we unconditionally turn it off.
|
|
||||||
*/
|
|
||||||
#if __GNUC__ == 2 && __GNUC_MINOR__ == 95
|
|
||||||
# undef G_HAVE_ISO_VARARGS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define G_HAVE_GROWING_STACK 0
|
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
# define G_HAVE_GNUC_VARARGS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
|
|
||||||
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
|
|
||||||
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
|
|
||||||
#define G_GNUC_INTERNAL __hidden
|
|
||||||
#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY)
|
|
||||||
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
|
|
||||||
#else
|
|
||||||
#define G_GNUC_INTERNAL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define G_THREADS_ENABLED
|
|
||||||
#define G_THREADS_IMPL_POSIX
|
|
||||||
|
|
||||||
#define G_ATOMIC_LOCK_FREE
|
|
||||||
|
|
||||||
#define GINT16_TO_LE(val) ((gint16) (val))
|
|
||||||
#define GUINT16_TO_LE(val) ((guint16) (val))
|
|
||||||
#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
|
|
||||||
#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
|
|
||||||
|
|
||||||
#define GINT32_TO_LE(val) ((gint32) (val))
|
|
||||||
#define GUINT32_TO_LE(val) ((guint32) (val))
|
|
||||||
#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
|
|
||||||
#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val))
|
|
||||||
|
|
||||||
#define GINT64_TO_LE(val) ((gint64) (val))
|
|
||||||
#define GUINT64_TO_LE(val) ((guint64) (val))
|
|
||||||
#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
|
|
||||||
#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val))
|
|
||||||
|
|
||||||
#define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val))
|
|
||||||
#define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val))
|
|
||||||
#define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val))
|
|
||||||
#define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val))
|
|
||||||
#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val))
|
|
||||||
#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val))
|
|
||||||
#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val))
|
|
||||||
#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val))
|
|
||||||
#define GSIZE_TO_LE(val) ((gsize) GUINT64_TO_LE (val))
|
|
||||||
#define GSSIZE_TO_LE(val) ((gssize) GINT64_TO_LE (val))
|
|
||||||
#define GSIZE_TO_BE(val) ((gsize) GUINT64_TO_BE (val))
|
|
||||||
#define GSSIZE_TO_BE(val) ((gssize) GINT64_TO_BE (val))
|
|
||||||
#define G_BYTE_ORDER G_LITTLE_ENDIAN
|
|
||||||
|
|
||||||
#define GLIB_SYSDEF_POLLIN =1
|
|
||||||
#define GLIB_SYSDEF_POLLOUT =4
|
|
||||||
#define GLIB_SYSDEF_POLLPRI =2
|
|
||||||
#define GLIB_SYSDEF_POLLHUP =16
|
|
||||||
#define GLIB_SYSDEF_POLLERR =8
|
|
||||||
#define GLIB_SYSDEF_POLLNVAL =32
|
|
||||||
|
|
||||||
/* No way to disable deprecation warnings for macros, so only emit deprecation
|
|
||||||
* warnings on platforms where usage of this macro is broken */
|
|
||||||
#if defined(__APPLE__) || defined(_MSC_VER) || defined(__CYGWIN__)
|
|
||||||
#define G_MODULE_SUFFIX "so" GLIB_DEPRECATED_MACRO_IN_2_76
|
|
||||||
#else
|
|
||||||
#define G_MODULE_SUFFIX "so"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef int GPid;
|
|
||||||
#define G_PID_FORMAT "i"
|
|
||||||
|
|
||||||
#define GLIB_SYSDEF_AF_UNIX 1
|
|
||||||
#define GLIB_SYSDEF_AF_INET 2
|
|
||||||
#define GLIB_SYSDEF_AF_INET6 10
|
|
||||||
|
|
||||||
#define GLIB_SYSDEF_MSG_OOB 1
|
|
||||||
#define GLIB_SYSDEF_MSG_PEEK 2
|
|
||||||
#define GLIB_SYSDEF_MSG_DONTROUTE 4
|
|
||||||
|
|
||||||
#define G_DIR_SEPARATOR '/'
|
|
||||||
#define G_DIR_SEPARATOR_S "/"
|
|
||||||
#define G_SEARCHPATH_SEPARATOR ':'
|
|
||||||
#define G_SEARCHPATH_SEPARATOR_S ":"
|
|
||||||
|
|
||||||
#undef G_HAVE_FREE_SIZED
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __GLIBCONFIG_H__ */
|
|
||||||
@ -1 +0,0 @@
|
|||||||
module.exports = __dirname;
|
|
||||||
Binary file not shown.
@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@img/sharp-libvips-linux-x64",
|
|
||||||
"version": "1.2.4",
|
|
||||||
"description": "Prebuilt libvips and dependencies for use with sharp on Linux (glibc) x64",
|
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/lovell/sharp-libvips.git",
|
|
||||||
"directory": "npm/linux-x64"
|
|
||||||
},
|
|
||||||
"license": "LGPL-3.0-or-later",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://opencollective.com/libvips"
|
|
||||||
},
|
|
||||||
"preferUnplugged": true,
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib",
|
|
||||||
"versions.json"
|
|
||||||
],
|
|
||||||
"type": "commonjs",
|
|
||||||
"exports": {
|
|
||||||
"./lib": "./lib/index.js",
|
|
||||||
"./package": "./package.json",
|
|
||||||
"./versions": "./versions.json"
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"glibc": ">=2.26"
|
|
||||||
},
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
{
|
|
||||||
"aom": "3.13.1",
|
|
||||||
"archive": "3.8.2",
|
|
||||||
"cairo": "1.18.4",
|
|
||||||
"cgif": "0.5.0",
|
|
||||||
"exif": "0.6.25",
|
|
||||||
"expat": "2.7.3",
|
|
||||||
"ffi": "3.5.2",
|
|
||||||
"fontconfig": "2.17.1",
|
|
||||||
"freetype": "2.14.1",
|
|
||||||
"fribidi": "1.0.16",
|
|
||||||
"glib": "2.86.1",
|
|
||||||
"harfbuzz": "12.1.0",
|
|
||||||
"heif": "1.20.2",
|
|
||||||
"highway": "1.3.0",
|
|
||||||
"imagequant": "2.4.1",
|
|
||||||
"lcms": "2.17",
|
|
||||||
"mozjpeg": "0826579",
|
|
||||||
"pango": "1.57.0",
|
|
||||||
"pixman": "0.46.4",
|
|
||||||
"png": "1.6.50",
|
|
||||||
"proxy-libintl": "0.5",
|
|
||||||
"rsvg": "2.61.2",
|
|
||||||
"spng": "0.7.4",
|
|
||||||
"tiff": "4.7.1",
|
|
||||||
"vips": "8.17.3",
|
|
||||||
"webp": "1.6.0",
|
|
||||||
"xml2": "2.15.1",
|
|
||||||
"zlib-ng": "2.2.5"
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
# `@img/sharp-libvips-linuxmusl-x64`
|
|
||||||
|
|
||||||
Prebuilt libvips and dependencies for use with sharp on Linux (musl) x64.
|
|
||||||
|
|
||||||
## Licensing
|
|
||||||
|
|
||||||
This software contains third-party libraries
|
|
||||||
used under the terms of the following licences:
|
|
||||||
|
|
||||||
| Library | Used under the terms of |
|
|
||||||
|---------------|-----------------------------------------------------------------------------------------------------------|
|
|
||||||
| aom | BSD 2-Clause + [Alliance for Open Media Patent License 1.0](https://aomedia.org/license/patent-license/) |
|
|
||||||
| cairo | Mozilla Public License 2.0 |
|
|
||||||
| cgif | MIT Licence |
|
|
||||||
| expat | MIT Licence |
|
|
||||||
| fontconfig | [fontconfig Licence](https://gitlab.freedesktop.org/fontconfig/fontconfig/blob/main/COPYING) (BSD-like) |
|
|
||||||
| freetype | [freetype Licence](https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT) (BSD-like) |
|
|
||||||
| fribidi | LGPLv3 |
|
|
||||||
| glib | LGPLv3 |
|
|
||||||
| harfbuzz | MIT Licence |
|
|
||||||
| highway | Apache-2.0 License, BSD 3-Clause |
|
|
||||||
| lcms | MIT Licence |
|
|
||||||
| libarchive | BSD 2-Clause |
|
|
||||||
| libexif | LGPLv3 |
|
|
||||||
| libffi | MIT Licence |
|
|
||||||
| libheif | LGPLv3 |
|
|
||||||
| libimagequant | [BSD 2-Clause](https://github.com/lovell/libimagequant/blob/main/COPYRIGHT) |
|
|
||||||
| libnsgif | MIT Licence |
|
|
||||||
| libpng | [libpng License](https://github.com/pnggroup/libpng/blob/master/LICENSE) |
|
|
||||||
| librsvg | LGPLv3 |
|
|
||||||
| libspng | [BSD 2-Clause, libpng License](https://github.com/randy408/libspng/blob/master/LICENSE) |
|
|
||||||
| libtiff | [libtiff License](https://gitlab.com/libtiff/libtiff/blob/master/LICENSE.md) (BSD-like) |
|
|
||||||
| libvips | LGPLv3 |
|
|
||||||
| libwebp | New BSD License |
|
|
||||||
| libxml2 | MIT Licence |
|
|
||||||
| mozjpeg | [zlib License, IJG License, BSD-3-Clause](https://github.com/mozilla/mozjpeg/blob/master/LICENSE.md) |
|
|
||||||
| pango | LGPLv3 |
|
|
||||||
| pixman | MIT Licence |
|
|
||||||
| proxy-libintl | LGPLv3 |
|
|
||||||
| zlib-ng | [zlib Licence](https://github.com/zlib-ng/zlib-ng/blob/develop/LICENSE.md) |
|
|
||||||
|
|
||||||
Use of libraries under the terms of the LGPLv3 is via the
|
|
||||||
"any later version" clause of the LGPLv2 or LGPLv2.1.
|
|
||||||
|
|
||||||
Please report any errors or omissions via
|
|
||||||
https://github.com/lovell/sharp-libvips/issues/new
|
|
||||||
221
node_modules/@img/sharp-libvips-linuxmusl-x64/lib/glib-2.0/include/glibconfig.h
generated
vendored
221
node_modules/@img/sharp-libvips-linuxmusl-x64/lib/glib-2.0/include/glibconfig.h
generated
vendored
@ -1,221 +0,0 @@
|
|||||||
/* glibconfig.h
|
|
||||||
*
|
|
||||||
* This is a generated file. Please modify 'glibconfig.h.in'
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GLIBCONFIG_H__
|
|
||||||
#define __GLIBCONFIG_H__
|
|
||||||
|
|
||||||
#include <glib/gmacros.h>
|
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
#include <float.h>
|
|
||||||
#define GLIB_HAVE_ALLOCA_H
|
|
||||||
|
|
||||||
#define GLIB_STATIC_COMPILATION 1
|
|
||||||
#define GOBJECT_STATIC_COMPILATION 1
|
|
||||||
#define GIO_STATIC_COMPILATION 1
|
|
||||||
#define GMODULE_STATIC_COMPILATION 1
|
|
||||||
#define GI_STATIC_COMPILATION 1
|
|
||||||
#define G_INTL_STATIC_COMPILATION 1
|
|
||||||
#define FFI_STATIC_BUILD 1
|
|
||||||
|
|
||||||
/* Specifies that GLib's g_print*() functions wrap the
|
|
||||||
* system printf functions. This is useful to know, for example,
|
|
||||||
* when using glibc's register_printf_function().
|
|
||||||
*/
|
|
||||||
#define GLIB_USING_SYSTEM_PRINTF
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define G_MINFLOAT FLT_MIN
|
|
||||||
#define G_MAXFLOAT FLT_MAX
|
|
||||||
#define G_MINDOUBLE DBL_MIN
|
|
||||||
#define G_MAXDOUBLE DBL_MAX
|
|
||||||
#define G_MINSHORT SHRT_MIN
|
|
||||||
#define G_MAXSHORT SHRT_MAX
|
|
||||||
#define G_MAXUSHORT USHRT_MAX
|
|
||||||
#define G_MININT INT_MIN
|
|
||||||
#define G_MAXINT INT_MAX
|
|
||||||
#define G_MAXUINT UINT_MAX
|
|
||||||
#define G_MINLONG LONG_MIN
|
|
||||||
#define G_MAXLONG LONG_MAX
|
|
||||||
#define G_MAXULONG ULONG_MAX
|
|
||||||
|
|
||||||
typedef signed char gint8;
|
|
||||||
typedef unsigned char guint8;
|
|
||||||
|
|
||||||
typedef signed short gint16;
|
|
||||||
typedef unsigned short guint16;
|
|
||||||
|
|
||||||
#define G_GINT16_MODIFIER "h"
|
|
||||||
#define G_GINT16_FORMAT "hi"
|
|
||||||
#define G_GUINT16_FORMAT "hu"
|
|
||||||
|
|
||||||
|
|
||||||
typedef signed int gint32;
|
|
||||||
typedef unsigned int guint32;
|
|
||||||
|
|
||||||
#define G_GINT32_MODIFIER ""
|
|
||||||
#define G_GINT32_FORMAT "i"
|
|
||||||
#define G_GUINT32_FORMAT "u"
|
|
||||||
|
|
||||||
|
|
||||||
#define G_HAVE_GINT64 1 /* deprecated, always true */
|
|
||||||
|
|
||||||
typedef signed long gint64;
|
|
||||||
typedef unsigned long guint64;
|
|
||||||
|
|
||||||
#define G_GINT64_CONSTANT(val) (val##L)
|
|
||||||
#define G_GUINT64_CONSTANT(val) (val##UL)
|
|
||||||
|
|
||||||
#define G_GINT64_MODIFIER "l"
|
|
||||||
#define G_GINT64_FORMAT "li"
|
|
||||||
#define G_GUINT64_FORMAT "lu"
|
|
||||||
|
|
||||||
|
|
||||||
#define GLIB_SIZEOF_VOID_P 8
|
|
||||||
#define GLIB_SIZEOF_LONG 8
|
|
||||||
#define GLIB_SIZEOF_SIZE_T 8
|
|
||||||
#define GLIB_SIZEOF_SSIZE_T 8
|
|
||||||
|
|
||||||
typedef signed long gssize;
|
|
||||||
typedef unsigned long gsize;
|
|
||||||
#define G_GSIZE_MODIFIER "l"
|
|
||||||
#define G_GSSIZE_MODIFIER "l"
|
|
||||||
#define G_GSIZE_FORMAT "lu"
|
|
||||||
#define G_GSSIZE_FORMAT "li"
|
|
||||||
|
|
||||||
#define G_MAXSIZE G_MAXULONG
|
|
||||||
#define G_MINSSIZE G_MINLONG
|
|
||||||
#define G_MAXSSIZE G_MAXLONG
|
|
||||||
|
|
||||||
typedef gint64 goffset;
|
|
||||||
#define G_MINOFFSET G_MININT64
|
|
||||||
#define G_MAXOFFSET G_MAXINT64
|
|
||||||
|
|
||||||
#define G_GOFFSET_MODIFIER G_GINT64_MODIFIER
|
|
||||||
#define G_GOFFSET_FORMAT G_GINT64_FORMAT
|
|
||||||
#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
|
|
||||||
|
|
||||||
#define G_POLLFD_FORMAT "%d"
|
|
||||||
|
|
||||||
#define GPOINTER_TO_INT(p) ((gint) (glong) (p))
|
|
||||||
#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p))
|
|
||||||
|
|
||||||
#define GINT_TO_POINTER(i) ((gpointer) (glong) (i))
|
|
||||||
#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u))
|
|
||||||
|
|
||||||
typedef signed long gintptr;
|
|
||||||
typedef unsigned long guintptr;
|
|
||||||
|
|
||||||
#define G_GINTPTR_MODIFIER "l"
|
|
||||||
#define G_GINTPTR_FORMAT "li"
|
|
||||||
#define G_GUINTPTR_FORMAT "lu"
|
|
||||||
|
|
||||||
#define GLIB_MAJOR_VERSION 2
|
|
||||||
#define GLIB_MINOR_VERSION 86
|
|
||||||
#define GLIB_MICRO_VERSION 1
|
|
||||||
|
|
||||||
#define G_OS_UNIX
|
|
||||||
|
|
||||||
#define G_VA_COPY va_copy
|
|
||||||
|
|
||||||
#define G_VA_COPY_AS_ARRAY 1
|
|
||||||
|
|
||||||
#define G_HAVE_ISO_VARARGS 1
|
|
||||||
|
|
||||||
/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
|
|
||||||
* is passed ISO vararg support is turned off, and there is no work
|
|
||||||
* around to turn it on, so we unconditionally turn it off.
|
|
||||||
*/
|
|
||||||
#if __GNUC__ == 2 && __GNUC_MINOR__ == 95
|
|
||||||
# undef G_HAVE_ISO_VARARGS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define G_HAVE_GROWING_STACK 0
|
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
# define G_HAVE_GNUC_VARARGS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
|
|
||||||
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
|
|
||||||
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
|
|
||||||
#define G_GNUC_INTERNAL __hidden
|
|
||||||
#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY)
|
|
||||||
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
|
|
||||||
#else
|
|
||||||
#define G_GNUC_INTERNAL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define G_THREADS_ENABLED
|
|
||||||
#define G_THREADS_IMPL_POSIX
|
|
||||||
|
|
||||||
#define G_ATOMIC_LOCK_FREE
|
|
||||||
|
|
||||||
#define GINT16_TO_LE(val) ((gint16) (val))
|
|
||||||
#define GUINT16_TO_LE(val) ((guint16) (val))
|
|
||||||
#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
|
|
||||||
#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
|
|
||||||
|
|
||||||
#define GINT32_TO_LE(val) ((gint32) (val))
|
|
||||||
#define GUINT32_TO_LE(val) ((guint32) (val))
|
|
||||||
#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
|
|
||||||
#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val))
|
|
||||||
|
|
||||||
#define GINT64_TO_LE(val) ((gint64) (val))
|
|
||||||
#define GUINT64_TO_LE(val) ((guint64) (val))
|
|
||||||
#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
|
|
||||||
#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val))
|
|
||||||
|
|
||||||
#define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val))
|
|
||||||
#define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val))
|
|
||||||
#define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val))
|
|
||||||
#define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val))
|
|
||||||
#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val))
|
|
||||||
#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val))
|
|
||||||
#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val))
|
|
||||||
#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val))
|
|
||||||
#define GSIZE_TO_LE(val) ((gsize) GUINT64_TO_LE (val))
|
|
||||||
#define GSSIZE_TO_LE(val) ((gssize) GINT64_TO_LE (val))
|
|
||||||
#define GSIZE_TO_BE(val) ((gsize) GUINT64_TO_BE (val))
|
|
||||||
#define GSSIZE_TO_BE(val) ((gssize) GINT64_TO_BE (val))
|
|
||||||
#define G_BYTE_ORDER G_LITTLE_ENDIAN
|
|
||||||
|
|
||||||
#define GLIB_SYSDEF_POLLIN =1
|
|
||||||
#define GLIB_SYSDEF_POLLOUT =4
|
|
||||||
#define GLIB_SYSDEF_POLLPRI =2
|
|
||||||
#define GLIB_SYSDEF_POLLHUP =16
|
|
||||||
#define GLIB_SYSDEF_POLLERR =8
|
|
||||||
#define GLIB_SYSDEF_POLLNVAL =32
|
|
||||||
|
|
||||||
/* No way to disable deprecation warnings for macros, so only emit deprecation
|
|
||||||
* warnings on platforms where usage of this macro is broken */
|
|
||||||
#if defined(__APPLE__) || defined(_MSC_VER) || defined(__CYGWIN__)
|
|
||||||
#define G_MODULE_SUFFIX "so" GLIB_DEPRECATED_MACRO_IN_2_76
|
|
||||||
#else
|
|
||||||
#define G_MODULE_SUFFIX "so"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef int GPid;
|
|
||||||
#define G_PID_FORMAT "i"
|
|
||||||
|
|
||||||
#define GLIB_SYSDEF_AF_UNIX 1
|
|
||||||
#define GLIB_SYSDEF_AF_INET 2
|
|
||||||
#define GLIB_SYSDEF_AF_INET6 10
|
|
||||||
|
|
||||||
#define GLIB_SYSDEF_MSG_OOB 1
|
|
||||||
#define GLIB_SYSDEF_MSG_PEEK 2
|
|
||||||
#define GLIB_SYSDEF_MSG_DONTROUTE 4
|
|
||||||
|
|
||||||
#define G_DIR_SEPARATOR '/'
|
|
||||||
#define G_DIR_SEPARATOR_S "/"
|
|
||||||
#define G_SEARCHPATH_SEPARATOR ':'
|
|
||||||
#define G_SEARCHPATH_SEPARATOR_S ":"
|
|
||||||
|
|
||||||
#undef G_HAVE_FREE_SIZED
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __GLIBCONFIG_H__ */
|
|
||||||
@ -1 +0,0 @@
|
|||||||
module.exports = __dirname;
|
|
||||||
Binary file not shown.
@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@img/sharp-libvips-linuxmusl-x64",
|
|
||||||
"version": "1.2.4",
|
|
||||||
"description": "Prebuilt libvips and dependencies for use with sharp on Linux (musl) x64",
|
|
||||||
"author": "Lovell Fuller <npm@lovell.info>",
|
|
||||||
"homepage": "https://sharp.pixelplumbing.com",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/lovell/sharp-libvips.git",
|
|
||||||
"directory": "npm/linuxmusl-x64"
|
|
||||||
},
|
|
||||||
"license": "LGPL-3.0-or-later",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://opencollective.com/libvips"
|
|
||||||
},
|
|
||||||
"preferUnplugged": true,
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib",
|
|
||||||
"versions.json"
|
|
||||||
],
|
|
||||||
"type": "commonjs",
|
|
||||||
"exports": {
|
|
||||||
"./lib": "./lib/index.js",
|
|
||||||
"./package": "./package.json",
|
|
||||||
"./versions": "./versions.json"
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"musl": ">=1.2.2"
|
|
||||||
},
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
{
|
|
||||||
"aom": "3.13.1",
|
|
||||||
"archive": "3.8.2",
|
|
||||||
"cairo": "1.18.4",
|
|
||||||
"cgif": "0.5.0",
|
|
||||||
"exif": "0.6.25",
|
|
||||||
"expat": "2.7.3",
|
|
||||||
"ffi": "3.5.2",
|
|
||||||
"fontconfig": "2.17.1",
|
|
||||||
"freetype": "2.14.1",
|
|
||||||
"fribidi": "1.0.16",
|
|
||||||
"glib": "2.86.1",
|
|
||||||
"harfbuzz": "12.1.0",
|
|
||||||
"heif": "1.20.2",
|
|
||||||
"highway": "1.3.0",
|
|
||||||
"imagequant": "2.4.1",
|
|
||||||
"lcms": "2.17",
|
|
||||||
"mozjpeg": "0826579",
|
|
||||||
"pango": "1.57.0",
|
|
||||||
"pixman": "0.46.4",
|
|
||||||
"png": "1.6.50",
|
|
||||||
"proxy-libintl": "0.5",
|
|
||||||
"rsvg": "2.61.2",
|
|
||||||
"spng": "0.7.4",
|
|
||||||
"tiff": "4.7.1",
|
|
||||||
"vips": "8.17.3",
|
|
||||||
"webp": "1.6.0",
|
|
||||||
"xml2": "2.15.1",
|
|
||||||
"zlib-ng": "2.2.5"
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "nudt-compiler-cpp",
|
|
||||||
"lockfileVersion": 2,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {}
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
import os
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
COMPILER = "./build/bin/compiler"
|
|
||||||
TEST_DIR = "./test/test_case/functional"
|
|
||||||
|
|
||||||
pass_cnt = 0
|
|
||||||
fail_cnt = 0
|
|
||||||
|
|
||||||
print("===== SysY Batch Test Start =====")
|
|
||||||
|
|
||||||
for file in os.listdir(TEST_DIR):
|
|
||||||
if not file.endswith(".sy"):
|
|
||||||
continue
|
|
||||||
|
|
||||||
path = os.path.join(TEST_DIR, file)
|
|
||||||
print(f"[TEST] {file} ... ", end="")
|
|
||||||
|
|
||||||
result = subprocess.run(
|
|
||||||
[COMPILER, "--emit-parse-tree", path],
|
|
||||||
stdout=subprocess.DEVNULL,
|
|
||||||
stderr=subprocess.PIPE
|
|
||||||
)
|
|
||||||
|
|
||||||
if result.returncode == 0:
|
|
||||||
print("PASS")
|
|
||||||
pass_cnt += 1
|
|
||||||
else:
|
|
||||||
print("FAIL")
|
|
||||||
fail_cnt += 1
|
|
||||||
print("---- Error ----")
|
|
||||||
print(result.stderr.decode())
|
|
||||||
print("---------------")
|
|
||||||
|
|
||||||
print("===============================")
|
|
||||||
print(f"Total: {pass_cnt + fail_cnt}")
|
|
||||||
print(f"PASS : {pass_cnt}")
|
|
||||||
print(f"FAIL : {fail_cnt}")
|
|
||||||
print("===============================")
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
// Generated from SysY.g4 by ANTLR 4.7.2
|
|
||||||
|
|
||||||
|
|
||||||
#include "SysYBaseVisitor.h"
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,144 +0,0 @@
|
|||||||
|
|
||||||
// Generated from SysY.g4 by ANTLR 4.7.2
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
#include "antlr4-runtime.h"
|
|
||||||
#include "SysYVisitor.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class provides an empty implementation of SysYVisitor, which can be
|
|
||||||
* extended to create a visitor which only needs to handle a subset of the available methods.
|
|
||||||
*/
|
|
||||||
class SysYBaseVisitor : public SysYVisitor {
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitCompUnit(SysYParser::CompUnitContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitDecl(SysYParser::DeclContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitConstDecl(SysYParser::ConstDeclContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitBType(SysYParser::BTypeContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitConstDef(SysYParser::ConstDefContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitConstInitVal(SysYParser::ConstInitValContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitVarDecl(SysYParser::VarDeclContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitVarDef(SysYParser::VarDefContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitInitVal(SysYParser::InitValContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitFuncDef(SysYParser::FuncDefContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitFuncType(SysYParser::FuncTypeContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitFuncFParams(SysYParser::FuncFParamsContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitFuncFParam(SysYParser::FuncFParamContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitBlock(SysYParser::BlockContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitBlockItem(SysYParser::BlockItemContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitStmt(SysYParser::StmtContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitExp(SysYParser::ExpContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitCond(SysYParser::CondContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitLVal(SysYParser::LValContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitPrimaryExp(SysYParser::PrimaryExpContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitNumber(SysYParser::NumberContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitUnaryExp(SysYParser::UnaryExpContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitUnaryOp(SysYParser::UnaryOpContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitFuncRParams(SysYParser::FuncRParamsContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitMulExp(SysYParser::MulExpContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitAddExp(SysYParser::AddExpContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitRelExp(SysYParser::RelExpContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitEqExp(SysYParser::EqExpContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitLAndExp(SysYParser::LAndExpContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitLOrExp(SysYParser::LOrExpContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitConstExp(SysYParser::ConstExpContext *ctx) override {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
@ -1,377 +0,0 @@
|
|||||||
|
|
||||||
// Generated from SysY.g4 by ANTLR 4.7.2
|
|
||||||
|
|
||||||
|
|
||||||
#include "SysYLexer.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace antlr4;
|
|
||||||
|
|
||||||
|
|
||||||
SysYLexer::SysYLexer(CharStream *input) : Lexer(input) {
|
|
||||||
_interpreter = new atn::LexerATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
SysYLexer::~SysYLexer() {
|
|
||||||
delete _interpreter;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string SysYLexer::getGrammarFileName() const {
|
|
||||||
return "SysY.g4";
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<std::string>& SysYLexer::getRuleNames() const {
|
|
||||||
return _ruleNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<std::string>& SysYLexer::getChannelNames() const {
|
|
||||||
return _channelNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<std::string>& SysYLexer::getModeNames() const {
|
|
||||||
return _modeNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<std::string>& SysYLexer::getTokenNames() const {
|
|
||||||
return _tokenNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
dfa::Vocabulary& SysYLexer::getVocabulary() const {
|
|
||||||
return _vocabulary;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<uint16_t> SysYLexer::getSerializedATN() const {
|
|
||||||
return _serializedATN;
|
|
||||||
}
|
|
||||||
|
|
||||||
const atn::ATN& SysYLexer::getATN() const {
|
|
||||||
return _atn;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Static vars and initialization.
|
|
||||||
std::vector<dfa::DFA> SysYLexer::_decisionToDFA;
|
|
||||||
atn::PredictionContextCache SysYLexer::_sharedContextCache;
|
|
||||||
|
|
||||||
// We own the ATN which in turn owns the ATN states.
|
|
||||||
atn::ATN SysYLexer::_atn;
|
|
||||||
std::vector<uint16_t> SysYLexer::_serializedATN;
|
|
||||||
|
|
||||||
std::vector<std::string> SysYLexer::_ruleNames = {
|
|
||||||
u8"T__0", u8"T__1", u8"T__2", u8"T__3", u8"T__4", u8"T__5", u8"T__6",
|
|
||||||
u8"T__7", u8"T__8", u8"T__9", u8"T__10", u8"T__11", u8"T__12", u8"T__13",
|
|
||||||
u8"T__14", u8"T__15", u8"T__16", u8"T__17", u8"T__18", u8"T__19", u8"T__20",
|
|
||||||
u8"T__21", u8"T__22", u8"T__23", u8"T__24", u8"T__25", u8"T__26", u8"T__27",
|
|
||||||
u8"T__28", u8"T__29", u8"T__30", u8"T__31", u8"T__32", u8"DIGIT", u8"HEXDIGIT",
|
|
||||||
u8"EXP", u8"PEXP", u8"FloatConst", u8"IntConst", u8"Ident", u8"WS", u8"LINE_COMMENT",
|
|
||||||
u8"BLOCK_COMMENT"
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<std::string> SysYLexer::_channelNames = {
|
|
||||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<std::string> SysYLexer::_modeNames = {
|
|
||||||
u8"DEFAULT_MODE"
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<std::string> SysYLexer::_literalNames = {
|
|
||||||
"", u8"'const'", u8"','", u8"';'", u8"'int'", u8"'float'", u8"'['", u8"']'",
|
|
||||||
u8"'='", u8"'{'", u8"'}'", u8"'('", u8"')'", u8"'void'", u8"'if'", u8"'else'",
|
|
||||||
u8"'while'", u8"'break'", u8"'continue'", u8"'return'", u8"'+'", u8"'-'",
|
|
||||||
u8"'!'", u8"'*'", u8"'/'", u8"'%'", u8"'<'", u8"'>'", u8"'<='", u8"'>='",
|
|
||||||
u8"'=='", u8"'!='", u8"'&&'", u8"'||'"
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<std::string> SysYLexer::_symbolicNames = {
|
|
||||||
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
|
|
||||||
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", u8"FloatConst",
|
|
||||||
u8"IntConst", u8"Ident", u8"WS", u8"LINE_COMMENT", u8"BLOCK_COMMENT"
|
|
||||||
};
|
|
||||||
|
|
||||||
dfa::Vocabulary SysYLexer::_vocabulary(_literalNames, _symbolicNames);
|
|
||||||
|
|
||||||
std::vector<std::string> SysYLexer::_tokenNames;
|
|
||||||
|
|
||||||
SysYLexer::Initializer::Initializer() {
|
|
||||||
// This code could be in a static initializer lambda, but VS doesn't allow access to private class members from there.
|
|
||||||
for (size_t i = 0; i < _symbolicNames.size(); ++i) {
|
|
||||||
std::string name = _vocabulary.getLiteralName(i);
|
|
||||||
if (name.empty()) {
|
|
||||||
name = _vocabulary.getSymbolicName(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name.empty()) {
|
|
||||||
_tokenNames.push_back("<INVALID>");
|
|
||||||
} else {
|
|
||||||
_tokenNames.push_back(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_serializedATN = {
|
|
||||||
0x3, 0x608b, 0xa72a, 0x8133, 0xb9ed, 0x417c, 0x3be7, 0x7786, 0x5964,
|
|
||||||
0x2, 0x29, 0x160, 0x8, 0x1, 0x4, 0x2, 0x9, 0x2, 0x4, 0x3, 0x9, 0x3,
|
|
||||||
0x4, 0x4, 0x9, 0x4, 0x4, 0x5, 0x9, 0x5, 0x4, 0x6, 0x9, 0x6, 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
|
|
||||||
0x3, 0x21, 0x3, 0x21, 0x3, 0x22, 0x3, 0x22, 0x3, 0x22, 0x3, 0x23, 0x3,
|
|
||||||
0x23, 0x3, 0x24, 0x3, 0x24, 0x3, 0x25, 0x3, 0x25, 0x5, 0x25, 0xcd, 0xa,
|
|
||||||
0x25, 0x3, 0x25, 0x6, 0x25, 0xd0, 0xa, 0x25, 0xd, 0x25, 0xe, 0x25, 0xd1,
|
|
||||||
0x3, 0x26, 0x3, 0x26, 0x5, 0x26, 0xd6, 0xa, 0x26, 0x3, 0x26, 0x6, 0x26,
|
|
||||||
0xd9, 0xa, 0x26, 0xd, 0x26, 0xe, 0x26, 0xda, 0x3, 0x27, 0x3, 0x27, 0x3,
|
|
||||||
0x27, 0x3, 0x27, 0x5, 0x27, 0xe1, 0xa, 0x27, 0x3, 0x27, 0x6, 0x27, 0xe4,
|
|
||||||
0xa, 0x27, 0xd, 0x27, 0xe, 0x27, 0xe5, 0x3, 0x27, 0x3, 0x27, 0x7, 0x27,
|
|
||||||
0xea, 0xa, 0x27, 0xc, 0x27, 0xe, 0x27, 0xed, 0xb, 0x27, 0x3, 0x27, 0x3,
|
|
||||||
0x27, 0x6, 0x27, 0xf1, 0xa, 0x27, 0xd, 0x27, 0xe, 0x27, 0xf2, 0x3, 0x27,
|
|
||||||
0x6, 0x27, 0xf6, 0xa, 0x27, 0xd, 0x27, 0xe, 0x27, 0xf7, 0x5, 0x27, 0xfa,
|
|
||||||
0xa, 0x27, 0x3, 0x27, 0x3, 0x27, 0x3, 0x27, 0x3, 0x27, 0x6, 0x27, 0x100,
|
|
||||||
0xa, 0x27, 0xd, 0x27, 0xe, 0x27, 0x101, 0x3, 0x27, 0x5, 0x27, 0x105,
|
|
||||||
0xa, 0x27, 0x3, 0x27, 0x6, 0x27, 0x108, 0xa, 0x27, 0xd, 0x27, 0xe, 0x27,
|
|
||||||
0x109, 0x3, 0x27, 0x3, 0x27, 0x7, 0x27, 0x10e, 0xa, 0x27, 0xc, 0x27,
|
|
||||||
0xe, 0x27, 0x111, 0xb, 0x27, 0x3, 0x27, 0x5, 0x27, 0x114, 0xa, 0x27,
|
|
||||||
0x3, 0x27, 0x6, 0x27, 0x117, 0xa, 0x27, 0xd, 0x27, 0xe, 0x27, 0x118,
|
|
||||||
0x3, 0x27, 0x3, 0x27, 0x5, 0x27, 0x11d, 0xa, 0x27, 0x3, 0x28, 0x3, 0x28,
|
|
||||||
0x3, 0x28, 0x7, 0x28, 0x122, 0xa, 0x28, 0xc, 0x28, 0xe, 0x28, 0x125,
|
|
||||||
0xb, 0x28, 0x3, 0x28, 0x3, 0x28, 0x6, 0x28, 0x129, 0xa, 0x28, 0xd, 0x28,
|
|
||||||
0xe, 0x28, 0x12a, 0x3, 0x28, 0x3, 0x28, 0x3, 0x28, 0x3, 0x28, 0x5, 0x28,
|
|
||||||
0x131, 0xa, 0x28, 0x3, 0x28, 0x6, 0x28, 0x134, 0xa, 0x28, 0xd, 0x28,
|
|
||||||
0xe, 0x28, 0x135, 0x5, 0x28, 0x138, 0xa, 0x28, 0x3, 0x29, 0x3, 0x29,
|
|
||||||
0x7, 0x29, 0x13c, 0xa, 0x29, 0xc, 0x29, 0xe, 0x29, 0x13f, 0xb, 0x29,
|
|
||||||
0x3, 0x2a, 0x6, 0x2a, 0x142, 0xa, 0x2a, 0xd, 0x2a, 0xe, 0x2a, 0x143,
|
|
||||||
0x3, 0x2a, 0x3, 0x2a, 0x3, 0x2b, 0x3, 0x2b, 0x3, 0x2b, 0x3, 0x2b, 0x7,
|
|
||||||
0x2b, 0x14c, 0xa, 0x2b, 0xc, 0x2b, 0xe, 0x2b, 0x14f, 0xb, 0x2b, 0x3,
|
|
||||||
0x2b, 0x3, 0x2b, 0x3, 0x2c, 0x3, 0x2c, 0x3, 0x2c, 0x3, 0x2c, 0x7, 0x2c,
|
|
||||||
0x157, 0xa, 0x2c, 0xc, 0x2c, 0xe, 0x2c, 0x15a, 0xb, 0x2c, 0x3, 0x2c,
|
|
||||||
0x3, 0x2c, 0x3, 0x2c, 0x3, 0x2c, 0x3, 0x2c, 0x3, 0x158, 0x2, 0x2d, 0x3,
|
|
||||||
0x3, 0x5, 0x4, 0x7, 0x5, 0x9, 0x6, 0xb, 0x7, 0xd, 0x8, 0xf, 0x9, 0x11,
|
|
||||||
0xa, 0x13, 0xb, 0x15, 0xc, 0x17, 0xd, 0x19, 0xe, 0x1b, 0xf, 0x1d, 0x10,
|
|
||||||
0x1f, 0x11, 0x21, 0x12, 0x23, 0x13, 0x25, 0x14, 0x27, 0x15, 0x29, 0x16,
|
|
||||||
0x2b, 0x17, 0x2d, 0x18, 0x2f, 0x19, 0x31, 0x1a, 0x33, 0x1b, 0x35, 0x1c,
|
|
||||||
0x37, 0x1d, 0x39, 0x1e, 0x3b, 0x1f, 0x3d, 0x20, 0x3f, 0x21, 0x41, 0x22,
|
|
||||||
0x43, 0x23, 0x45, 0x2, 0x47, 0x2, 0x49, 0x2, 0x4b, 0x2, 0x4d, 0x24,
|
|
||||||
0x4f, 0x25, 0x51, 0x26, 0x53, 0x27, 0x55, 0x28, 0x57, 0x29, 0x3, 0x2,
|
|
||||||
0xd, 0x3, 0x2, 0x32, 0x3b, 0x5, 0x2, 0x32, 0x3b, 0x43, 0x48, 0x63, 0x68,
|
|
||||||
0x4, 0x2, 0x47, 0x47, 0x67, 0x67, 0x4, 0x2, 0x2d, 0x2d, 0x2f, 0x2f,
|
|
||||||
0x4, 0x2, 0x52, 0x52, 0x72, 0x72, 0x3, 0x2, 0x33, 0x3b, 0x3, 0x2, 0x32,
|
|
||||||
0x39, 0x5, 0x2, 0x43, 0x5c, 0x61, 0x61, 0x63, 0x7c, 0x6, 0x2, 0x32,
|
|
||||||
0x3b, 0x43, 0x5c, 0x61, 0x61, 0x63, 0x7c, 0x5, 0x2, 0xb, 0xc, 0xf, 0xf,
|
|
||||||
0x22, 0x22, 0x4, 0x2, 0xc, 0xc, 0xf, 0xf, 0x2, 0x17a, 0x2, 0x3, 0x3,
|
|
||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103,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x104, 0x105, 0x3, 0x2, 0x2, 0x2, 0x105, 0x11d,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x106, 0x108, 0x5, 0x45, 0x23, 0x2, 0x107, 0x106,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x108, 0x109, 0x3, 0x2, 0x2, 0x2, 0x109, 0x107,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x109, 0x10a, 0x3, 0x2, 0x2, 0x2, 0x10a, 0x10b,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x10b, 0x10f, 0x7, 0x30, 0x2, 0x2, 0x10c, 0x10e,
|
|
||||||
0x5, 0x45, 0x23, 0x2, 0x10d, 0x10c, 0x3, 0x2, 0x2, 0x2, 0x10e, 0x111,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x10f, 0x10d, 0x3, 0x2, 0x2, 0x2, 0x10f, 0x110,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x110, 0x113, 0x3, 0x2, 0x2, 0x2, 0x111, 0x10f,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x112, 0x114, 0x5, 0x49, 0x25, 0x2, 0x113, 0x112,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x113, 0x114, 0x3, 0x2, 0x2, 0x2, 0x114, 0x11d,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x115, 0x117, 0x5, 0x45, 0x23, 0x2, 0x116, 0x115,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x117, 0x118, 0x3, 0x2, 0x2, 0x2, 0x118, 0x116,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x118, 0x119, 0x3, 0x2, 0x2, 0x2, 0x119, 0x11a,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x11a, 0x11b, 0x5, 0x49, 0x25, 0x2, 0x11b, 0x11d,
|
|
||||||
0x3, 0x2, 0x2, 0x2, 0x11c, 0xe0, 0x3, 0x2, 0x2, 0x2, 0x11c, 0xfd, 0x3,
|
|
||||||
0x2, 0x2, 0x2, 0x11c, 0x107, 0x3, 0x2, 0x2, 0x2, 0x11c, 0x116, 0x3,
|
|
||||||
0x2, 0x2, 0x2, 0x11d, 0x4e, 0x3, 0x2, 0x2, 0x2, 0x11e, 0x138, 0x7, 0x32,
|
|
||||||
0x2, 0x2, 0x11f, 0x123, 0x9, 0x7, 0x2, 0x2, 0x120, 0x122, 0x9, 0x2,
|
|
||||||
0x2, 0x2, 0x121, 0x120, 0x3, 0x2, 0x2, 0x2, 0x122, 0x125, 0x3, 0x2,
|
|
||||||
0x2, 0x2, 0x123, 0x121, 0x3, 0x2, 0x2, 0x2, 0x123, 0x124, 0x3, 0x2,
|
|
||||||
0x2, 0x2, 0x124, 0x138, 0x3, 0x2, 0x2, 0x2, 0x125, 0x123, 0x3, 0x2,
|
|
||||||
0x2, 0x2, 0x126, 0x128, 0x7, 0x32, 0x2, 0x2, 0x127, 0x129, 0x9, 0x8,
|
|
||||||
0x2, 0x2, 0x128, 0x127, 0x3, 0x2, 0x2, 0x2, 0x129, 0x12a, 0x3, 0x2,
|
|
||||||
0x2, 0x2, 0x12a, 0x128, 0x3, 0x2, 0x2, 0x2, 0x12a, 0x12b, 0x3, 0x2,
|
|
||||||
0x2, 0x2, 0x12b, 0x138, 0x3, 0x2, 0x2, 0x2, 0x12c, 0x12d, 0x7, 0x32,
|
|
||||||
0x2, 0x2, 0x12d, 0x131, 0x7, 0x7a, 0x2, 0x2, 0x12e, 0x12f, 0x7, 0x32,
|
|
||||||
0x2, 0x2, 0x12f, 0x131, 0x7, 0x5a, 0x2, 0x2, 0x130, 0x12c, 0x3, 0x2,
|
|
||||||
0x2, 0x2, 0x130, 0x12e, 0x3, 0x2, 0x2, 0x2, 0x131, 0x133, 0x3, 0x2,
|
|
||||||
0x2, 0x2, 0x132, 0x134, 0x9, 0x3, 0x2, 0x2, 0x133, 0x132, 0x3, 0x2,
|
|
||||||
0x2, 0x2, 0x134, 0x135, 0x3, 0x2, 0x2, 0x2, 0x135, 0x133, 0x3, 0x2,
|
|
||||||
0x2, 0x2, 0x135, 0x136, 0x3, 0x2, 0x2, 0x2, 0x136, 0x138, 0x3, 0x2,
|
|
||||||
0x2, 0x2, 0x137, 0x11e, 0x3, 0x2, 0x2, 0x2, 0x137, 0x11f, 0x3, 0x2,
|
|
||||||
0x2, 0x2, 0x137, 0x126, 0x3, 0x2, 0x2, 0x2, 0x137, 0x130, 0x3, 0x2,
|
|
||||||
0x2, 0x2, 0x138, 0x50, 0x3, 0x2, 0x2, 0x2, 0x139, 0x13d, 0x9, 0x9, 0x2,
|
|
||||||
0x2, 0x13a, 0x13c, 0x9, 0xa, 0x2, 0x2, 0x13b, 0x13a, 0x3, 0x2, 0x2,
|
|
||||||
0x2, 0x13c, 0x13f, 0x3, 0x2, 0x2, 0x2, 0x13d, 0x13b, 0x3, 0x2, 0x2,
|
|
||||||
0x2, 0x13d, 0x13e, 0x3, 0x2, 0x2, 0x2, 0x13e, 0x52, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x13f, 0x13d, 0x3, 0x2, 0x2, 0x2, 0x140, 0x142, 0x9, 0xb, 0x2, 0x2,
|
|
||||||
0x141, 0x140, 0x3, 0x2, 0x2, 0x2, 0x142, 0x143, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x143, 0x141, 0x3, 0x2, 0x2, 0x2, 0x143, 0x144, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x144, 0x145, 0x3, 0x2, 0x2, 0x2, 0x145, 0x146, 0x8, 0x2a, 0x2, 0x2,
|
|
||||||
0x146, 0x54, 0x3, 0x2, 0x2, 0x2, 0x147, 0x148, 0x7, 0x31, 0x2, 0x2,
|
|
||||||
0x148, 0x149, 0x7, 0x31, 0x2, 0x2, 0x149, 0x14d, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x14a, 0x14c, 0xa, 0xc, 0x2, 0x2, 0x14b, 0x14a, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x14c, 0x14f, 0x3, 0x2, 0x2, 0x2, 0x14d, 0x14b, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x14d, 0x14e, 0x3, 0x2, 0x2, 0x2, 0x14e, 0x150, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x14f, 0x14d, 0x3, 0x2, 0x2, 0x2, 0x150, 0x151, 0x8, 0x2b, 0x2, 0x2,
|
|
||||||
0x151, 0x56, 0x3, 0x2, 0x2, 0x2, 0x152, 0x153, 0x7, 0x31, 0x2, 0x2,
|
|
||||||
0x153, 0x154, 0x7, 0x2c, 0x2, 0x2, 0x154, 0x158, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x155, 0x157, 0xb, 0x2, 0x2, 0x2, 0x156, 0x155, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x157, 0x15a, 0x3, 0x2, 0x2, 0x2, 0x158, 0x159, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x158, 0x156, 0x3, 0x2, 0x2, 0x2, 0x159, 0x15b, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x15a, 0x158, 0x3, 0x2, 0x2, 0x2, 0x15b, 0x15c, 0x7, 0x2c, 0x2, 0x2,
|
|
||||||
0x15c, 0x15d, 0x7, 0x31, 0x2, 0x2, 0x15d, 0x15e, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x15e, 0x15f, 0x8, 0x2c, 0x2, 0x2, 0x15f, 0x58, 0x3, 0x2, 0x2, 0x2,
|
|
||||||
0x1d, 0x2, 0xcc, 0xd1, 0xd5, 0xda, 0xe0, 0xe5, 0xeb, 0xf2, 0xf7, 0xf9,
|
|
||||||
0x101, 0x104, 0x109, 0x10f, 0x113, 0x118, 0x11c, 0x123, 0x12a, 0x130,
|
|
||||||
0x135, 0x137, 0x13d, 0x143, 0x14d, 0x158, 0x3, 0x8, 0x2, 0x2,
|
|
||||||
};
|
|
||||||
|
|
||||||
atn::ATNDeserializer deserializer;
|
|
||||||
_atn = deserializer.deserialize(_serializedATN);
|
|
||||||
|
|
||||||
size_t count = _atn.getNumberOfDecisions();
|
|
||||||
_decisionToDFA.reserve(count);
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
|
||||||
_decisionToDFA.emplace_back(_atn.getDecisionState(i), i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SysYLexer::Initializer SysYLexer::_init;
|
|
||||||
@ -1,62 +0,0 @@
|
|||||||
|
|
||||||
// Generated from SysY.g4 by ANTLR 4.7.2
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
#include "antlr4-runtime.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SysYLexer : public antlr4::Lexer {
|
|
||||||
public:
|
|
||||||
enum {
|
|
||||||
T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, T__4 = 5, T__5 = 6, T__6 = 7,
|
|
||||||
T__7 = 8, T__8 = 9, T__9 = 10, T__10 = 11, T__11 = 12, T__12 = 13, T__13 = 14,
|
|
||||||
T__14 = 15, T__15 = 16, T__16 = 17, T__17 = 18, T__18 = 19, T__19 = 20,
|
|
||||||
T__20 = 21, T__21 = 22, T__22 = 23, T__23 = 24, T__24 = 25, T__25 = 26,
|
|
||||||
T__26 = 27, T__27 = 28, T__28 = 29, T__29 = 30, T__30 = 31, T__31 = 32,
|
|
||||||
T__32 = 33, FloatConst = 34, IntConst = 35, Ident = 36, WS = 37, LINE_COMMENT = 38,
|
|
||||||
BLOCK_COMMENT = 39
|
|
||||||
};
|
|
||||||
|
|
||||||
SysYLexer(antlr4::CharStream *input);
|
|
||||||
~SysYLexer();
|
|
||||||
|
|
||||||
virtual std::string getGrammarFileName() const override;
|
|
||||||
virtual const std::vector<std::string>& getRuleNames() const override;
|
|
||||||
|
|
||||||
virtual const std::vector<std::string>& getChannelNames() const override;
|
|
||||||
virtual const std::vector<std::string>& getModeNames() const override;
|
|
||||||
virtual const std::vector<std::string>& getTokenNames() const override; // deprecated, use vocabulary instead
|
|
||||||
virtual antlr4::dfa::Vocabulary& getVocabulary() const override;
|
|
||||||
|
|
||||||
virtual const std::vector<uint16_t> getSerializedATN() const override;
|
|
||||||
virtual const antlr4::atn::ATN& getATN() const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
static std::vector<antlr4::dfa::DFA> _decisionToDFA;
|
|
||||||
static antlr4::atn::PredictionContextCache _sharedContextCache;
|
|
||||||
static std::vector<std::string> _ruleNames;
|
|
||||||
static std::vector<std::string> _tokenNames;
|
|
||||||
static std::vector<std::string> _channelNames;
|
|
||||||
static std::vector<std::string> _modeNames;
|
|
||||||
|
|
||||||
static std::vector<std::string> _literalNames;
|
|
||||||
static std::vector<std::string> _symbolicNames;
|
|
||||||
static antlr4::dfa::Vocabulary _vocabulary;
|
|
||||||
static antlr4::atn::ATN _atn;
|
|
||||||
static std::vector<uint16_t> _serializedATN;
|
|
||||||
|
|
||||||
|
|
||||||
// Individual action functions triggered by action() above.
|
|
||||||
|
|
||||||
// Individual semantic predicate functions triggered by sempred() above.
|
|
||||||
|
|
||||||
struct Initializer {
|
|
||||||
Initializer();
|
|
||||||
};
|
|
||||||
static Initializer _init;
|
|
||||||
};
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,513 +0,0 @@
|
|||||||
|
|
||||||
// Generated from SysY.g4 by ANTLR 4.7.2
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
#include "antlr4-runtime.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SysYParser : public antlr4::Parser {
|
|
||||||
public:
|
|
||||||
enum {
|
|
||||||
T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, T__4 = 5, T__5 = 6, T__6 = 7,
|
|
||||||
T__7 = 8, T__8 = 9, T__9 = 10, T__10 = 11, T__11 = 12, T__12 = 13, T__13 = 14,
|
|
||||||
T__14 = 15, T__15 = 16, T__16 = 17, T__17 = 18, T__18 = 19, T__19 = 20,
|
|
||||||
T__20 = 21, T__21 = 22, T__22 = 23, T__23 = 24, T__24 = 25, T__25 = 26,
|
|
||||||
T__26 = 27, T__27 = 28, T__28 = 29, T__29 = 30, T__30 = 31, T__31 = 32,
|
|
||||||
T__32 = 33, FloatConst = 34, IntConst = 35, Ident = 36, WS = 37, LINE_COMMENT = 38,
|
|
||||||
BLOCK_COMMENT = 39
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
RuleCompUnit = 0, RuleDecl = 1, RuleConstDecl = 2, RuleBType = 3, RuleConstDef = 4,
|
|
||||||
RuleConstInitVal = 5, RuleVarDecl = 6, RuleVarDef = 7, RuleInitVal = 8,
|
|
||||||
RuleFuncDef = 9, RuleFuncType = 10, RuleFuncFParams = 11, RuleFuncFParam = 12,
|
|
||||||
RuleBlock = 13, RuleBlockItem = 14, RuleStmt = 15, RuleExp = 16, RuleCond = 17,
|
|
||||||
RuleLVal = 18, RulePrimaryExp = 19, RuleNumber = 20, RuleUnaryExp = 21,
|
|
||||||
RuleUnaryOp = 22, RuleFuncRParams = 23, RuleMulExp = 24, RuleAddExp = 25,
|
|
||||||
RuleRelExp = 26, RuleEqExp = 27, RuleLAndExp = 28, RuleLOrExp = 29,
|
|
||||||
RuleConstExp = 30
|
|
||||||
};
|
|
||||||
|
|
||||||
SysYParser(antlr4::TokenStream *input);
|
|
||||||
~SysYParser();
|
|
||||||
|
|
||||||
virtual std::string getGrammarFileName() const override;
|
|
||||||
virtual const antlr4::atn::ATN& getATN() const override { return _atn; };
|
|
||||||
virtual const std::vector<std::string>& getTokenNames() const override { return _tokenNames; }; // deprecated: use vocabulary instead.
|
|
||||||
virtual const std::vector<std::string>& getRuleNames() const override;
|
|
||||||
virtual antlr4::dfa::Vocabulary& getVocabulary() const override;
|
|
||||||
|
|
||||||
|
|
||||||
class CompUnitContext;
|
|
||||||
class DeclContext;
|
|
||||||
class ConstDeclContext;
|
|
||||||
class BTypeContext;
|
|
||||||
class ConstDefContext;
|
|
||||||
class ConstInitValContext;
|
|
||||||
class VarDeclContext;
|
|
||||||
class VarDefContext;
|
|
||||||
class InitValContext;
|
|
||||||
class FuncDefContext;
|
|
||||||
class FuncTypeContext;
|
|
||||||
class FuncFParamsContext;
|
|
||||||
class FuncFParamContext;
|
|
||||||
class BlockContext;
|
|
||||||
class BlockItemContext;
|
|
||||||
class StmtContext;
|
|
||||||
class ExpContext;
|
|
||||||
class CondContext;
|
|
||||||
class LValContext;
|
|
||||||
class PrimaryExpContext;
|
|
||||||
class NumberContext;
|
|
||||||
class UnaryExpContext;
|
|
||||||
class UnaryOpContext;
|
|
||||||
class FuncRParamsContext;
|
|
||||||
class MulExpContext;
|
|
||||||
class AddExpContext;
|
|
||||||
class RelExpContext;
|
|
||||||
class EqExpContext;
|
|
||||||
class LAndExpContext;
|
|
||||||
class LOrExpContext;
|
|
||||||
class ConstExpContext;
|
|
||||||
|
|
||||||
class CompUnitContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
CompUnitContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
std::vector<DeclContext *> decl();
|
|
||||||
DeclContext* decl(size_t i);
|
|
||||||
std::vector<FuncDefContext *> funcDef();
|
|
||||||
FuncDefContext* funcDef(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
CompUnitContext* compUnit();
|
|
||||||
|
|
||||||
class DeclContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
DeclContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
ConstDeclContext *constDecl();
|
|
||||||
VarDeclContext *varDecl();
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
DeclContext* decl();
|
|
||||||
|
|
||||||
class ConstDeclContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
ConstDeclContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
BTypeContext *bType();
|
|
||||||
std::vector<ConstDefContext *> constDef();
|
|
||||||
ConstDefContext* constDef(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
ConstDeclContext* constDecl();
|
|
||||||
|
|
||||||
class BTypeContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
BTypeContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
BTypeContext* bType();
|
|
||||||
|
|
||||||
class ConstDefContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
ConstDefContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
antlr4::tree::TerminalNode *Ident();
|
|
||||||
ConstInitValContext *constInitVal();
|
|
||||||
std::vector<ConstExpContext *> constExp();
|
|
||||||
ConstExpContext* constExp(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
ConstDefContext* constDef();
|
|
||||||
|
|
||||||
class ConstInitValContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
ConstInitValContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
ConstExpContext *constExp();
|
|
||||||
std::vector<ConstInitValContext *> constInitVal();
|
|
||||||
ConstInitValContext* constInitVal(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
ConstInitValContext* constInitVal();
|
|
||||||
|
|
||||||
class VarDeclContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
VarDeclContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
BTypeContext *bType();
|
|
||||||
std::vector<VarDefContext *> varDef();
|
|
||||||
VarDefContext* varDef(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
VarDeclContext* varDecl();
|
|
||||||
|
|
||||||
class VarDefContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
VarDefContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
antlr4::tree::TerminalNode *Ident();
|
|
||||||
std::vector<ConstExpContext *> constExp();
|
|
||||||
ConstExpContext* constExp(size_t i);
|
|
||||||
InitValContext *initVal();
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
VarDefContext* varDef();
|
|
||||||
|
|
||||||
class InitValContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
InitValContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
ExpContext *exp();
|
|
||||||
std::vector<InitValContext *> initVal();
|
|
||||||
InitValContext* initVal(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
InitValContext* initVal();
|
|
||||||
|
|
||||||
class FuncDefContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
FuncDefContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
FuncTypeContext *funcType();
|
|
||||||
antlr4::tree::TerminalNode *Ident();
|
|
||||||
BlockContext *block();
|
|
||||||
FuncFParamsContext *funcFParams();
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
FuncDefContext* funcDef();
|
|
||||||
|
|
||||||
class FuncTypeContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
FuncTypeContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
FuncTypeContext* funcType();
|
|
||||||
|
|
||||||
class FuncFParamsContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
FuncFParamsContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
std::vector<FuncFParamContext *> funcFParam();
|
|
||||||
FuncFParamContext* funcFParam(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
FuncFParamsContext* funcFParams();
|
|
||||||
|
|
||||||
class FuncFParamContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
FuncFParamContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
BTypeContext *bType();
|
|
||||||
antlr4::tree::TerminalNode *Ident();
|
|
||||||
std::vector<ExpContext *> exp();
|
|
||||||
ExpContext* exp(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
FuncFParamContext* funcFParam();
|
|
||||||
|
|
||||||
class BlockContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
BlockContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
std::vector<BlockItemContext *> blockItem();
|
|
||||||
BlockItemContext* blockItem(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
BlockContext* block();
|
|
||||||
|
|
||||||
class BlockItemContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
BlockItemContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
DeclContext *decl();
|
|
||||||
StmtContext *stmt();
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
BlockItemContext* blockItem();
|
|
||||||
|
|
||||||
class StmtContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
StmtContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
LValContext *lVal();
|
|
||||||
ExpContext *exp();
|
|
||||||
BlockContext *block();
|
|
||||||
CondContext *cond();
|
|
||||||
std::vector<StmtContext *> stmt();
|
|
||||||
StmtContext* stmt(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
StmtContext* stmt();
|
|
||||||
|
|
||||||
class ExpContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
ExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
AddExpContext *addExp();
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
ExpContext* exp();
|
|
||||||
|
|
||||||
class CondContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
CondContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
LOrExpContext *lOrExp();
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
CondContext* cond();
|
|
||||||
|
|
||||||
class LValContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
LValContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
antlr4::tree::TerminalNode *Ident();
|
|
||||||
std::vector<ExpContext *> exp();
|
|
||||||
ExpContext* exp(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
LValContext* lVal();
|
|
||||||
|
|
||||||
class PrimaryExpContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
PrimaryExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
ExpContext *exp();
|
|
||||||
LValContext *lVal();
|
|
||||||
NumberContext *number();
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
PrimaryExpContext* primaryExp();
|
|
||||||
|
|
||||||
class NumberContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
NumberContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
antlr4::tree::TerminalNode *FloatConst();
|
|
||||||
antlr4::tree::TerminalNode *IntConst();
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
NumberContext* number();
|
|
||||||
|
|
||||||
class UnaryExpContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
UnaryExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
PrimaryExpContext *primaryExp();
|
|
||||||
antlr4::tree::TerminalNode *Ident();
|
|
||||||
FuncRParamsContext *funcRParams();
|
|
||||||
UnaryOpContext *unaryOp();
|
|
||||||
UnaryExpContext *unaryExp();
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
UnaryExpContext* unaryExp();
|
|
||||||
|
|
||||||
class UnaryOpContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
UnaryOpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
UnaryOpContext* unaryOp();
|
|
||||||
|
|
||||||
class FuncRParamsContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
FuncRParamsContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
std::vector<ExpContext *> exp();
|
|
||||||
ExpContext* exp(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
FuncRParamsContext* funcRParams();
|
|
||||||
|
|
||||||
class MulExpContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
MulExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
std::vector<UnaryExpContext *> unaryExp();
|
|
||||||
UnaryExpContext* unaryExp(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
MulExpContext* mulExp();
|
|
||||||
|
|
||||||
class AddExpContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
AddExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
std::vector<MulExpContext *> mulExp();
|
|
||||||
MulExpContext* mulExp(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
AddExpContext* addExp();
|
|
||||||
|
|
||||||
class RelExpContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
RelExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
std::vector<AddExpContext *> addExp();
|
|
||||||
AddExpContext* addExp(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
RelExpContext* relExp();
|
|
||||||
|
|
||||||
class EqExpContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
EqExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
std::vector<RelExpContext *> relExp();
|
|
||||||
RelExpContext* relExp(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
EqExpContext* eqExp();
|
|
||||||
|
|
||||||
class LAndExpContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
LAndExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
std::vector<EqExpContext *> eqExp();
|
|
||||||
EqExpContext* eqExp(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
LAndExpContext* lAndExp();
|
|
||||||
|
|
||||||
class LOrExpContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
LOrExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
std::vector<LAndExpContext *> lAndExp();
|
|
||||||
LAndExpContext* lAndExp(size_t i);
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
LOrExpContext* lOrExp();
|
|
||||||
|
|
||||||
class ConstExpContext : public antlr4::ParserRuleContext {
|
|
||||||
public:
|
|
||||||
ConstExpContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
|
||||||
virtual size_t getRuleIndex() const override;
|
|
||||||
AddExpContext *addExp();
|
|
||||||
|
|
||||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
ConstExpContext* constExp();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
static std::vector<antlr4::dfa::DFA> _decisionToDFA;
|
|
||||||
static antlr4::atn::PredictionContextCache _sharedContextCache;
|
|
||||||
static std::vector<std::string> _ruleNames;
|
|
||||||
static std::vector<std::string> _tokenNames;
|
|
||||||
|
|
||||||
static std::vector<std::string> _literalNames;
|
|
||||||
static std::vector<std::string> _symbolicNames;
|
|
||||||
static antlr4::dfa::Vocabulary _vocabulary;
|
|
||||||
static antlr4::atn::ATN _atn;
|
|
||||||
static std::vector<uint16_t> _serializedATN;
|
|
||||||
|
|
||||||
|
|
||||||
struct Initializer {
|
|
||||||
Initializer();
|
|
||||||
};
|
|
||||||
static Initializer _init;
|
|
||||||
};
|
|
||||||
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
// Generated from SysY.g4 by ANTLR 4.7.2
|
|
||||||
|
|
||||||
|
|
||||||
#include "SysYVisitor.h"
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,86 +0,0 @@
|
|||||||
|
|
||||||
// Generated from SysY.g4 by ANTLR 4.7.2
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
#include "antlr4-runtime.h"
|
|
||||||
#include "SysYParser.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class defines an abstract visitor for a parse tree
|
|
||||||
* produced by SysYParser.
|
|
||||||
*/
|
|
||||||
class SysYVisitor : public antlr4::tree::AbstractParseTreeVisitor {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Visit parse trees produced by SysYParser.
|
|
||||||
*/
|
|
||||||
virtual antlrcpp::Any visitCompUnit(SysYParser::CompUnitContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitDecl(SysYParser::DeclContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitConstDecl(SysYParser::ConstDeclContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitBType(SysYParser::BTypeContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitConstDef(SysYParser::ConstDefContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitConstInitVal(SysYParser::ConstInitValContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitVarDecl(SysYParser::VarDeclContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitVarDef(SysYParser::VarDefContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitInitVal(SysYParser::InitValContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitFuncDef(SysYParser::FuncDefContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitFuncType(SysYParser::FuncTypeContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitFuncFParams(SysYParser::FuncFParamsContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitFuncFParam(SysYParser::FuncFParamContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitBlock(SysYParser::BlockContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitBlockItem(SysYParser::BlockItemContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitStmt(SysYParser::StmtContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitExp(SysYParser::ExpContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitCond(SysYParser::CondContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitLVal(SysYParser::LValContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitPrimaryExp(SysYParser::PrimaryExpContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitNumber(SysYParser::NumberContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitUnaryExp(SysYParser::UnaryExpContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitUnaryOp(SysYParser::UnaryOpContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitFuncRParams(SysYParser::FuncRParamsContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitMulExp(SysYParser::MulExpContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitAddExp(SysYParser::AddExpContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitRelExp(SysYParser::RelExpContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitEqExp(SysYParser::EqExpContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitLAndExp(SysYParser::LAndExpContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitLOrExp(SysYParser::LOrExpContext *context) = 0;
|
|
||||||
|
|
||||||
virtual antlrcpp::Any visitConstExp(SysYParser::ConstExpContext *context) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
@ -1,95 +0,0 @@
|
|||||||
#include "irgen/IRGen.h"
|
|
||||||
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "SysYParser.h"
|
|
||||||
#include "utils/Log.h"
|
|
||||||
|
|
||||||
// 内部辅助:不依赖类成员,只需 ConstEnv。
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
int EvalAddExp(SysYParser::AddExpContext* ctx,
|
|
||||||
const IRGenImpl::ConstEnv& env);
|
|
||||||
int EvalMulExp(SysYParser::MulExpContext* ctx,
|
|
||||||
const IRGenImpl::ConstEnv& env);
|
|
||||||
int EvalUnaryExp(SysYParser::UnaryExpContext* ctx,
|
|
||||||
const IRGenImpl::ConstEnv& env);
|
|
||||||
|
|
||||||
int EvalPrimary(SysYParser::PrimaryExpContext* ctx,
|
|
||||||
const IRGenImpl::ConstEnv& env) {
|
|
||||||
if (!ctx) throw std::runtime_error(FormatError("consteval", "空主表达式"));
|
|
||||||
if (ctx->number()) {
|
|
||||||
if (!ctx->number()->ILITERAL())
|
|
||||||
throw std::runtime_error(
|
|
||||||
FormatError("consteval", "constExp 不支持浮点字面量"));
|
|
||||||
return std::stoi(ctx->number()->getText());
|
|
||||||
}
|
|
||||||
if (ctx->exp()) return EvalAddExp(ctx->exp()->addExp(), env);
|
|
||||||
if (ctx->lValue()) {
|
|
||||||
if (!ctx->lValue()->ID())
|
|
||||||
throw std::runtime_error(FormatError("consteval", "非法 lValue"));
|
|
||||||
const std::string name = ctx->lValue()->ID()->getText();
|
|
||||||
auto it = env.find(name);
|
|
||||||
if (it == env.end())
|
|
||||||
throw std::runtime_error(
|
|
||||||
FormatError("consteval", "constExp 引用非 const 变量: " + name));
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
throw std::runtime_error(FormatError("consteval", "不支持的主表达式形式"));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EvalUnaryExp(SysYParser::UnaryExpContext* ctx,
|
|
||||||
const IRGenImpl::ConstEnv& env) {
|
|
||||||
if (!ctx) throw std::runtime_error(FormatError("consteval", "空一元表达式"));
|
|
||||||
if (ctx->primaryExp()) return EvalPrimary(ctx->primaryExp(), env);
|
|
||||||
if (ctx->unaryOp() && ctx->unaryExp()) {
|
|
||||||
int v = EvalUnaryExp(ctx->unaryExp(), env);
|
|
||||||
if (ctx->unaryOp()->SUB()) return -v;
|
|
||||||
if (ctx->unaryOp()->ADD()) return v;
|
|
||||||
if (ctx->unaryOp()->NOT()) return (v == 0) ? 1 : 0;
|
|
||||||
}
|
|
||||||
throw std::runtime_error(
|
|
||||||
FormatError("consteval", "函数调用不能出现在 constExp 中"));
|
|
||||||
}
|
|
||||||
|
|
||||||
int EvalMulExp(SysYParser::MulExpContext* ctx,
|
|
||||||
const IRGenImpl::ConstEnv& env) {
|
|
||||||
if (!ctx) throw std::runtime_error(FormatError("consteval", "空乘法表达式"));
|
|
||||||
if (ctx->mulExp()) {
|
|
||||||
int lhs = EvalMulExp(ctx->mulExp(), env);
|
|
||||||
int rhs = EvalUnaryExp(ctx->unaryExp(), env);
|
|
||||||
if (ctx->MUL()) return lhs * rhs;
|
|
||||||
if (ctx->DIV()) { if (!rhs) throw std::runtime_error("除以零"); return lhs / rhs; }
|
|
||||||
if (ctx->MOD()) { if (!rhs) throw std::runtime_error("模零"); return lhs % rhs; }
|
|
||||||
throw std::runtime_error(FormatError("consteval", "未知乘法运算符"));
|
|
||||||
}
|
|
||||||
return EvalUnaryExp(ctx->unaryExp(), env);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EvalAddExp(SysYParser::AddExpContext* ctx,
|
|
||||||
const IRGenImpl::ConstEnv& env) {
|
|
||||||
if (!ctx) throw std::runtime_error(FormatError("consteval", "空加法表达式"));
|
|
||||||
if (ctx->addExp()) {
|
|
||||||
int lhs = EvalAddExp(ctx->addExp(), env);
|
|
||||||
int rhs = EvalMulExp(ctx->mulExp(), env);
|
|
||||||
if (ctx->ADD()) return lhs + rhs;
|
|
||||||
if (ctx->SUB()) return lhs - rhs;
|
|
||||||
throw std::runtime_error(FormatError("consteval", "未知加法运算符"));
|
|
||||||
}
|
|
||||||
return EvalMulExp(ctx->mulExp(), env);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
int IRGenImpl::EvalConstExpr(SysYParser::ConstExpContext* ctx) const {
|
|
||||||
if (!ctx || !ctx->addExp())
|
|
||||||
throw std::runtime_error(FormatError("consteval", "空 constExp"));
|
|
||||||
return EvalAddExp(ctx->addExp(), const_env_);
|
|
||||||
}
|
|
||||||
|
|
||||||
int IRGenImpl::EvalExpAsConst(SysYParser::ExpContext* ctx) const {
|
|
||||||
if (!ctx || !ctx->addExp())
|
|
||||||
throw std::runtime_error(FormatError("consteval", "空 exp"));
|
|
||||||
return EvalAddExp(ctx->addExp(), const_env_);
|
|
||||||
}
|
|
||||||
@ -1,490 +1,200 @@
|
|||||||
#include "sem/Sema.h"
|
#include "sem/Sema.h"
|
||||||
|
|
||||||
|
#include <any>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace {
|
#include "SysYBaseVisitor.h"
|
||||||
|
#include "sem/SymbolTable.h"
|
||||||
|
#include "utils/Log.h"
|
||||||
|
|
||||||
SymbolType ParseType(const std::string& text) {
|
namespace {
|
||||||
if (text == "int") {
|
|
||||||
return SymbolType::TYPE_INT;
|
|
||||||
}
|
|
||||||
if (text == "float") {
|
|
||||||
return SymbolType::TYPE_FLOAT;
|
|
||||||
}
|
|
||||||
if (text == "void") {
|
|
||||||
return SymbolType::TYPE_VOID;
|
|
||||||
}
|
|
||||||
return SymbolType::TYPE_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
SymbolType MergeNumericType(SymbolType lhs, SymbolType rhs) {
|
std::string GetLValueName(SysYParser::LValueContext& lvalue) {
|
||||||
if (lhs == SymbolType::TYPE_FLOAT || rhs == SymbolType::TYPE_FLOAT) {
|
if (!lvalue.ID()) {
|
||||||
return SymbolType::TYPE_FLOAT;
|
throw std::runtime_error(FormatError("sema", "非法左值"));
|
||||||
}
|
|
||||||
if (lhs == SymbolType::TYPE_INT && rhs == SymbolType::TYPE_INT) {
|
|
||||||
return SymbolType::TYPE_INT;
|
|
||||||
}
|
|
||||||
if (lhs != SymbolType::TYPE_UNKNOWN) {
|
|
||||||
return lhs;
|
|
||||||
}
|
}
|
||||||
return rhs;
|
return lvalue.ID()->getText();
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void SemaVisitor::RecordNodeError(antlr4::ParserRuleContext* ctx,
|
|
||||||
const std::string& msg) {
|
|
||||||
if (!ctx || !ctx->getStart()) {
|
|
||||||
ir_ctx_.RecordError(ErrorMsg(msg, 0, 0));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ir_ctx_.RecordError(ErrorMsg(msg, ctx->getStart()->getLine(),
|
|
||||||
ctx->getStart()->getCharPositionInLine() + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitCompUnit(SysYParser::CompUnitContext* ctx) {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitDecl(SysYParser::DeclContext* ctx) {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitConstDecl(SysYParser::ConstDeclContext* ctx) {
|
|
||||||
current_decl_is_const_ = true;
|
|
||||||
current_decl_type_ = SymbolType::TYPE_UNKNOWN;
|
|
||||||
if (ctx && ctx->btype()) {
|
|
||||||
current_decl_type_ = ParseType(ctx->btype()->getText());
|
|
||||||
}
|
|
||||||
std::any result = visitChildren(ctx);
|
|
||||||
current_decl_is_const_ = false;
|
|
||||||
current_decl_type_ = SymbolType::TYPE_UNKNOWN;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitBtype(SysYParser::BtypeContext* ctx) {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::any SemaVisitor::visitConstDef(SysYParser::ConstDefContext* ctx) {
|
class SemaVisitor final : public SysYBaseVisitor {
|
||||||
if (!ctx || !ctx->ID()) {
|
public:
|
||||||
return {};
|
std::any visitCompUnit(SysYParser::CompUnitContext* ctx) override {
|
||||||
|
if (!ctx) {
|
||||||
|
throw std::runtime_error(FormatError("sema", "缺少编译单元"));
|
||||||
}
|
}
|
||||||
|
auto* func = ctx->funcDef();
|
||||||
const std::string name = ctx->ID()->getText();
|
if (!func || !func->blockStmt()) {
|
||||||
auto& table = ir_ctx_.GetSymbolTable();
|
throw std::runtime_error(FormatError("sema", "缺少 main 函数定义"));
|
||||||
if (table.CurrentScopeHasVar(name)) {
|
|
||||||
RecordNodeError(ctx, "重复定义变量: " + name);
|
|
||||||
} else {
|
|
||||||
VarInfo info;
|
|
||||||
info.type = current_decl_type_;
|
|
||||||
info.is_const = true;
|
|
||||||
info.decl_ctx = ctx;
|
|
||||||
table.BindVar(name, info, ctx);
|
|
||||||
}
|
}
|
||||||
|
if (!func->ID() || func->ID()->getText() != "main") {
|
||||||
ir_ctx_.SetType(ctx, current_decl_type_);
|
throw std::runtime_error(FormatError("sema", "缺少 main 函数定义"));
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitConstInitValue(SysYParser::ConstInitValueContext* ctx) {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitVarDecl(SysYParser::VarDeclContext* ctx) {
|
|
||||||
current_decl_is_const_ = false;
|
|
||||||
current_decl_type_ = SymbolType::TYPE_UNKNOWN;
|
|
||||||
if (ctx && ctx->btype()) {
|
|
||||||
current_decl_type_ = ParseType(ctx->btype()->getText());
|
|
||||||
}
|
|
||||||
std::any result = visitChildren(ctx);
|
|
||||||
current_decl_type_ = SymbolType::TYPE_UNKNOWN;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitVarDef(SysYParser::VarDefContext* ctx) {
|
|
||||||
if (!ctx || !ctx->ID()) {
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
func->accept(this);
|
||||||
const std::string name = ctx->ID()->getText();
|
if (!seen_return_) {
|
||||||
auto& table = ir_ctx_.GetSymbolTable();
|
throw std::runtime_error(
|
||||||
if (table.CurrentScopeHasVar(name)) {
|
FormatError("sema", "main 函数必须包含 return 语句"));
|
||||||
RecordNodeError(ctx, "重复定义变量: " + name);
|
|
||||||
} else {
|
|
||||||
VarInfo info;
|
|
||||||
info.type = current_decl_type_;
|
|
||||||
info.is_const = current_decl_is_const_;
|
|
||||||
info.decl_ctx = ctx;
|
|
||||||
table.BindVar(name, info, ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ir_ctx_.SetType(ctx, current_decl_type_);
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitInitValue(SysYParser::InitValueContext* ctx) {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitFuncDef(SysYParser::FuncDefContext* ctx) {
|
|
||||||
if (!ctx || !ctx->ID() || !ctx->funcType()) {
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string func_name = ctx->ID()->getText();
|
std::any visitFuncDef(SysYParser::FuncDefContext* ctx) override {
|
||||||
SymbolType ret_type = ParseType(ctx->funcType()->getText());
|
if (!ctx || !ctx->blockStmt()) {
|
||||||
ir_ctx_.SetCurrentFuncReturnType(ret_type);
|
throw std::runtime_error(FormatError("sema", "缺少 main 函数定义"));
|
||||||
|
|
||||||
auto& table = ir_ctx_.GetSymbolTable();
|
|
||||||
if (table.CurrentScopeHasFunc(func_name)) {
|
|
||||||
RecordNodeError(ctx, "重复定义函数: " + func_name);
|
|
||||||
} else {
|
|
||||||
FuncInfo info;
|
|
||||||
info.name = func_name;
|
|
||||||
info.ret_type = ret_type;
|
|
||||||
info.decl_ctx = ctx;
|
|
||||||
if (ctx->funcFParams()) {
|
|
||||||
for (auto* param : ctx->funcFParams()->funcFParam()) {
|
|
||||||
if (!param || !param->btype()) {
|
|
||||||
info.param_types.push_back(SymbolType::TYPE_UNKNOWN);
|
|
||||||
} else {
|
|
||||||
info.param_types.push_back(ParseType(param->btype()->getText()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!ctx->funcType() || !ctx->funcType()->INT()) {
|
||||||
|
throw std::runtime_error(FormatError("sema", "当前仅支持 int main"));
|
||||||
}
|
}
|
||||||
table.BindFunc(func_name, info, ctx);
|
const auto& items = ctx->blockStmt()->blockItem();
|
||||||
}
|
if (items.empty()) {
|
||||||
|
throw std::runtime_error(
|
||||||
ir_ctx_.EnterScope();
|
FormatError("sema", "main 函数不能为空,且必须以 return 结束"));
|
||||||
if (ctx->funcFParams()) {
|
|
||||||
ctx->funcFParams()->accept(this);
|
|
||||||
}
|
}
|
||||||
if (ctx->blockStmt()) {
|
|
||||||
ctx->blockStmt()->accept(this);
|
ctx->blockStmt()->accept(this);
|
||||||
}
|
|
||||||
ir_ctx_.LeaveScope();
|
|
||||||
|
|
||||||
ir_ctx_.SetCurrentFuncReturnType(SymbolType::TYPE_UNKNOWN);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitFuncType(SysYParser::FuncTypeContext* ctx) {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitFuncFParams(SysYParser::FuncFParamsContext* ctx) {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitFuncFParam(SysYParser::FuncFParamContext* ctx) {
|
|
||||||
if (!ctx || !ctx->ID() || !ctx->btype()) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
const std::string name = ctx->ID()->getText();
|
|
||||||
auto& table = ir_ctx_.GetSymbolTable();
|
|
||||||
if (table.CurrentScopeHasVar(name)) {
|
|
||||||
RecordNodeError(ctx, "重复定义形参: " + name);
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
VarInfo info;
|
std::any visitBlockStmt(SysYParser::BlockStmtContext* ctx) override {
|
||||||
info.type = ParseType(ctx->btype()->getText());
|
|
||||||
info.is_const = false;
|
|
||||||
info.decl_ctx = ctx;
|
|
||||||
table.BindVar(name, info, ctx);
|
|
||||||
ir_ctx_.SetType(ctx, info.type);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitBlockStmt(SysYParser::BlockStmtContext* ctx) {
|
|
||||||
ir_ctx_.EnterScope();
|
|
||||||
std::any result = visitChildren(ctx);
|
|
||||||
ir_ctx_.LeaveScope();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitBlockItem(SysYParser::BlockItemContext* ctx) {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitStmt(SysYParser::StmtContext* ctx) {
|
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
return {};
|
throw std::runtime_error(FormatError("sema", "缺少语句块"));
|
||||||
}
|
}
|
||||||
|
const auto& items = ctx->blockItem();
|
||||||
if (ctx->WHILE()) {
|
for (size_t i = 0; i < items.size(); ++i) {
|
||||||
ir_ctx_.EnterLoop();
|
auto* item = items[i];
|
||||||
std::any result = visitChildren(ctx);
|
if (!item) {
|
||||||
ir_ctx_.ExitLoop();
|
continue;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
if (seen_return_) {
|
||||||
if (ctx->BREAK() && !ir_ctx_.InLoop()) {
|
throw std::runtime_error(
|
||||||
RecordNodeError(ctx, "break 只能出现在循环语句中");
|
FormatError("sema", "return 必须是 main 函数中的最后一条语句"));
|
||||||
}
|
}
|
||||||
|
current_item_index_ = i;
|
||||||
if (ctx->CONTINUE() && !ir_ctx_.InLoop()) {
|
total_items_ = items.size();
|
||||||
RecordNodeError(ctx, "continue 只能出现在循环语句中");
|
item->accept(this);
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->lValue() && ctx->exp()) {
|
|
||||||
ctx->lValue()->accept(this);
|
|
||||||
ctx->exp()->accept(this);
|
|
||||||
SymbolType lhs = ir_ctx_.GetType(ctx->lValue());
|
|
||||||
SymbolType rhs = ir_ctx_.GetType(ctx->exp());
|
|
||||||
if (!IsTypeCompatible(lhs, rhs)) {
|
|
||||||
RecordNodeError(ctx, "赋值两侧类型不兼容");
|
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return visitChildren(ctx);
|
std::any visitBlockItem(SysYParser::BlockItemContext* ctx) override {
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitReturnStmt(SysYParser::ReturnStmtContext* ctx) {
|
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
return {};
|
throw std::runtime_error(FormatError("sema", "暂不支持的语句或声明"));
|
||||||
}
|
|
||||||
|
|
||||||
SymbolType ret_type = ir_ctx_.GetCurrentFuncReturnType();
|
|
||||||
if (ctx->exp()) {
|
|
||||||
ctx->exp()->accept(this);
|
|
||||||
SymbolType expr_type = ir_ctx_.GetType(ctx->exp());
|
|
||||||
if (ret_type == SymbolType::TYPE_VOID) {
|
|
||||||
RecordNodeError(ctx, "void 函数不应返回表达式");
|
|
||||||
} else if (!IsTypeCompatible(ret_type, expr_type)) {
|
|
||||||
RecordNodeError(ctx, "return 表达式类型与函数返回类型不匹配");
|
|
||||||
}
|
|
||||||
} else if (ret_type != SymbolType::TYPE_VOID &&
|
|
||||||
ret_type != SymbolType::TYPE_UNKNOWN) {
|
|
||||||
RecordNodeError(ctx, "非 void 函数 return 必须带表达式");
|
|
||||||
}
|
}
|
||||||
|
if (ctx->decl()) {
|
||||||
return {};
|
ctx->decl()->accept(this);
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitExp(SysYParser::ExpContext* ctx) {
|
|
||||||
if (!ctx || !ctx->addExp()) {
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
ctx->addExp()->accept(this);
|
if (ctx->stmt()) {
|
||||||
ir_ctx_.SetType(ctx, ir_ctx_.GetType(ctx->addExp()));
|
ctx->stmt()->accept(this);
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitCond(SysYParser::CondContext* ctx) {
|
|
||||||
if (!ctx || !ctx->lOrExp()) {
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
ctx->lOrExp()->accept(this);
|
throw std::runtime_error(FormatError("sema", "暂不支持的语句或声明"));
|
||||||
ir_ctx_.SetType(ctx, SymbolType::TYPE_INT);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitLValue(SysYParser::LValueContext* ctx) {
|
|
||||||
if (!ctx || !ctx->ID()) {
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VarInfo var;
|
std::any visitDecl(SysYParser::DeclContext* ctx) override {
|
||||||
void* decl_ctx = nullptr;
|
if (!ctx) {
|
||||||
auto& table = ir_ctx_.GetSymbolTable();
|
throw std::runtime_error(FormatError("sema", "非法变量声明"));
|
||||||
const std::string name = ctx->ID()->getText();
|
|
||||||
if (!table.LookupVar(name, var, decl_ctx)) {
|
|
||||||
RecordNodeError(ctx, "未定义变量: " + name);
|
|
||||||
ir_ctx_.SetType(ctx, SymbolType::TYPE_UNKNOWN);
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
if (!ctx->btype() || !ctx->btype()->INT()) {
|
||||||
ir_ctx_.SetType(ctx, var.type);
|
throw std::runtime_error(FormatError("sema", "当前仅支持局部 int 变量声明"));
|
||||||
|
|
||||||
if (sema_ctx_ && decl_ctx) {
|
|
||||||
auto* rule = static_cast<antlr4::ParserRuleContext*>(decl_ctx);
|
|
||||||
if (auto* var_def = dynamic_cast<SysYParser::VarDefContext*>(rule)) {
|
|
||||||
sema_ctx_->BindVarUse(ctx, var_def);
|
|
||||||
}
|
}
|
||||||
|
auto* var_def = ctx->varDef();
|
||||||
|
if (!var_def || !var_def->lValue()) {
|
||||||
|
throw std::runtime_error(FormatError("sema", "非法变量声明"));
|
||||||
}
|
}
|
||||||
|
const std::string name = GetLValueName(*var_def->lValue());
|
||||||
return {};
|
if (table_.Contains(name)) {
|
||||||
}
|
throw std::runtime_error(FormatError("sema", "重复定义变量: " + name));
|
||||||
|
|
||||||
std::any SemaVisitor::visitPrimaryExp(SysYParser::PrimaryExpContext* ctx) {
|
|
||||||
if (!ctx) {
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
if (auto* init = var_def->initValue()) {
|
||||||
if (ctx->exp()) {
|
if (!init->exp()) {
|
||||||
ctx->exp()->accept(this);
|
throw std::runtime_error(FormatError("sema", "当前不支持聚合初始化"));
|
||||||
ir_ctx_.SetType(ctx, ir_ctx_.GetType(ctx->exp()));
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
init->exp()->accept(this);
|
||||||
if (ctx->lValue()) {
|
}
|
||||||
ctx->lValue()->accept(this);
|
table_.Add(name, var_def);
|
||||||
ir_ctx_.SetType(ctx, ir_ctx_.GetType(ctx->lValue()));
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->number()) {
|
std::any visitStmt(SysYParser::StmtContext* ctx) override {
|
||||||
ctx->number()->accept(this);
|
if (!ctx || !ctx->returnStmt()) {
|
||||||
ir_ctx_.SetType(ctx, ir_ctx_.GetType(ctx->number()));
|
throw std::runtime_error(FormatError("sema", "暂不支持的语句或声明"));
|
||||||
}
|
}
|
||||||
|
ctx->returnStmt()->accept(this);
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitNumber(SysYParser::NumberContext* ctx) {
|
|
||||||
if (!ctx) {
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->ILITERAL()) {
|
std::any visitReturnStmt(SysYParser::ReturnStmtContext* ctx) override {
|
||||||
ir_ctx_.SetType(ctx, SymbolType::TYPE_INT);
|
if (!ctx || !ctx->exp()) {
|
||||||
ir_ctx_.SetConstVal(ctx, std::any(0L));
|
throw std::runtime_error(FormatError("sema", "return 缺少表达式"));
|
||||||
} else if (ctx->FLITERAL()) {
|
|
||||||
ir_ctx_.SetType(ctx, SymbolType::TYPE_FLOAT);
|
|
||||||
ir_ctx_.SetConstVal(ctx, std::any(0.0));
|
|
||||||
}
|
}
|
||||||
|
ctx->exp()->accept(this);
|
||||||
return {};
|
seen_return_ = true;
|
||||||
}
|
if (current_item_index_ + 1 != total_items_) {
|
||||||
|
throw std::runtime_error(
|
||||||
std::any SemaVisitor::visitUnaryExp(SysYParser::UnaryExpContext* ctx) {
|
FormatError("sema", "return 必须是 main 函数中的最后一条语句"));
|
||||||
if (!ctx) {
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->primaryExp()) {
|
|
||||||
ctx->primaryExp()->accept(this);
|
|
||||||
ir_ctx_.SetType(ctx, ir_ctx_.GetType(ctx->primaryExp()));
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->unaryOp() && ctx->unaryExp()) {
|
std::any visitParenExp(SysYParser::ParenExpContext* ctx) override {
|
||||||
ctx->unaryExp()->accept(this);
|
if (!ctx || !ctx->exp()) {
|
||||||
ir_ctx_.SetType(ctx, ir_ctx_.GetType(ctx->unaryExp()));
|
throw std::runtime_error(FormatError("sema", "非法括号表达式"));
|
||||||
|
}
|
||||||
|
ctx->exp()->accept(this);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->ID()) {
|
std::any visitVarExp(SysYParser::VarExpContext* ctx) override {
|
||||||
FuncInfo fn;
|
if (!ctx || !ctx->var()) {
|
||||||
void* decl_ctx = nullptr;
|
throw std::runtime_error(FormatError("sema", "非法变量表达式"));
|
||||||
if (!ir_ctx_.GetSymbolTable().LookupFunc(ctx->ID()->getText(), fn, decl_ctx)) {
|
|
||||||
RecordNodeError(ctx, "未定义函数: " + ctx->ID()->getText());
|
|
||||||
ir_ctx_.SetType(ctx, SymbolType::TYPE_UNKNOWN);
|
|
||||||
} else {
|
|
||||||
ir_ctx_.SetType(ctx, fn.ret_type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
ctx->var()->accept(this);
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitUnaryOp(SysYParser::UnaryOpContext* ctx) {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitFuncRParams(SysYParser::FuncRParamsContext* ctx) {
|
|
||||||
return visitChildren(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitMulExp(SysYParser::MulExpContext* ctx) {
|
|
||||||
if (!ctx) {
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->mulExp()) {
|
std::any visitNumberExp(SysYParser::NumberExpContext* ctx) override {
|
||||||
ctx->mulExp()->accept(this);
|
if (!ctx || !ctx->number() || !ctx->number()->ILITERAL()) {
|
||||||
|
throw std::runtime_error(FormatError("sema", "当前仅支持整数字面量"));
|
||||||
}
|
}
|
||||||
if (ctx->unaryExp()) {
|
|
||||||
ctx->unaryExp()->accept(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
SymbolType lhs = ctx->mulExp() ? ir_ctx_.GetType(ctx->mulExp())
|
|
||||||
: ir_ctx_.GetType(ctx->unaryExp());
|
|
||||||
SymbolType rhs = ir_ctx_.GetType(ctx->unaryExp());
|
|
||||||
ir_ctx_.SetType(ctx, MergeNumericType(lhs, rhs));
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitAddExp(SysYParser::AddExpContext* ctx) {
|
|
||||||
if (!ctx) {
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->addExp()) {
|
std::any visitAdditiveExp(SysYParser::AdditiveExpContext* ctx) override {
|
||||||
ctx->addExp()->accept(this);
|
if (!ctx || !ctx->exp(0) || !ctx->exp(1)) {
|
||||||
}
|
throw std::runtime_error(FormatError("sema", "暂不支持的表达式形式"));
|
||||||
if (ctx->mulExp()) {
|
|
||||||
ctx->mulExp()->accept(this);
|
|
||||||
}
|
}
|
||||||
|
ctx->exp(0)->accept(this);
|
||||||
SymbolType lhs = ctx->addExp() ? ir_ctx_.GetType(ctx->addExp())
|
ctx->exp(1)->accept(this);
|
||||||
: ir_ctx_.GetType(ctx->mulExp());
|
|
||||||
SymbolType rhs = ir_ctx_.GetType(ctx->mulExp());
|
|
||||||
ir_ctx_.SetType(ctx, MergeNumericType(lhs, rhs));
|
|
||||||
return {};
|
return {};
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitRelExp(SysYParser::RelExpContext* ctx) {
|
|
||||||
if (ctx) {
|
|
||||||
visitChildren(ctx);
|
|
||||||
ir_ctx_.SetType(ctx, SymbolType::TYPE_INT);
|
|
||||||
}
|
}
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitEqExp(SysYParser::EqExpContext* ctx) {
|
std::any visitVar(SysYParser::VarContext* ctx) override {
|
||||||
if (ctx) {
|
if (!ctx || !ctx->ID()) {
|
||||||
visitChildren(ctx);
|
throw std::runtime_error(FormatError("sema", "非法变量引用"));
|
||||||
ir_ctx_.SetType(ctx, SymbolType::TYPE_INT);
|
|
||||||
}
|
}
|
||||||
return {};
|
const std::string name = ctx->ID()->getText();
|
||||||
}
|
auto* decl = table_.Lookup(name);
|
||||||
|
if (!decl) {
|
||||||
std::any SemaVisitor::visitLAndExp(SysYParser::LAndExpContext* ctx) {
|
throw std::runtime_error(FormatError("sema", "使用了未定义的变量: " + name));
|
||||||
if (ctx) {
|
|
||||||
visitChildren(ctx);
|
|
||||||
ir_ctx_.SetType(ctx, SymbolType::TYPE_INT);
|
|
||||||
}
|
}
|
||||||
|
sema_.BindVarUse(ctx, decl);
|
||||||
return {};
|
return {};
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitLOrExp(SysYParser::LOrExpContext* ctx) {
|
|
||||||
if (ctx) {
|
|
||||||
visitChildren(ctx);
|
|
||||||
ir_ctx_.SetType(ctx, SymbolType::TYPE_INT);
|
|
||||||
}
|
}
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::any SemaVisitor::visitConstExp(SysYParser::ConstExpContext* ctx) {
|
SemanticContext TakeSemanticContext() { return std::move(sema_); }
|
||||||
if (!ctx || !ctx->addExp()) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
ctx->addExp()->accept(this);
|
|
||||||
ir_ctx_.SetType(ctx, ir_ctx_.GetType(ctx->addExp()));
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunSemanticAnalysis(SysYParser::CompUnitContext* ctx, IRGenContext& ir_ctx) {
|
private:
|
||||||
if (!ctx) {
|
SymbolTable table_;
|
||||||
throw std::invalid_argument("CompUnitContext is null");
|
SemanticContext sema_;
|
||||||
}
|
bool seen_return_ = false;
|
||||||
|
size_t current_item_index_ = 0;
|
||||||
|
size_t total_items_ = 0;
|
||||||
|
};
|
||||||
|
|
||||||
ir_ctx.EnterScope();
|
} // namespace
|
||||||
SemaVisitor visitor(ir_ctx, nullptr);
|
|
||||||
visitor.visit(ctx);
|
|
||||||
ir_ctx.LeaveScope();
|
|
||||||
}
|
|
||||||
|
|
||||||
SemanticContext RunSema(SysYParser::CompUnitContext& comp_unit) {
|
SemanticContext RunSema(SysYParser::CompUnitContext& comp_unit) {
|
||||||
IRGenContext ctx;
|
SemaVisitor visitor;
|
||||||
SemanticContext sema_ctx;
|
comp_unit.accept(&visitor);
|
||||||
ctx.EnterScope();
|
return visitor.TakeSemanticContext();
|
||||||
SemaVisitor visitor(ctx, &sema_ctx);
|
|
||||||
visitor.visit(&comp_unit);
|
|
||||||
ctx.LeaveScope();
|
|
||||||
return sema_ctx;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,164 +1,17 @@
|
|||||||
#include "../../include/sem/SymbolTable.h"
|
// 维护局部变量声明的注册与查找。
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
// 进入新作用域
|
#include "sem/SymbolTable.h"
|
||||||
void SymbolTable::EnterScope() {
|
|
||||||
scopes_.push(ScopeEntry());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 离开当前作用域
|
|
||||||
void SymbolTable::LeaveScope() {
|
|
||||||
if (scopes_.empty()) {
|
|
||||||
throw std::runtime_error("SymbolTable Error: 作用域栈为空,无法退出");
|
|
||||||
}
|
|
||||||
scopes_.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 绑定变量到当前作用域
|
|
||||||
void SymbolTable::BindVar(const std::string& name, const VarInfo& info, void* decl_ctx) {
|
|
||||||
if (CurrentScopeHasVar(name)) {
|
|
||||||
throw std::runtime_error("变量'" + name + "'在当前作用域重复定义");
|
|
||||||
}
|
|
||||||
scopes_.top().var_symbols[name] = {info, decl_ctx};
|
|
||||||
}
|
|
||||||
|
|
||||||
// 绑定函数到当前作用域
|
|
||||||
void SymbolTable::BindFunc(const std::string& name, const FuncInfo& info, void* decl_ctx) {
|
|
||||||
if (CurrentScopeHasFunc(name)) {
|
|
||||||
throw std::runtime_error("函数'" + name + "'在当前作用域重复定义");
|
|
||||||
}
|
|
||||||
scopes_.top().func_symbols[name] = {info, decl_ctx};
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查找变量(从当前作用域向上遍历)
|
void SymbolTable::Add(const std::string& name,
|
||||||
bool SymbolTable::LookupVar(const std::string& name, VarInfo& out_info, void*& out_decl_ctx) const {
|
SysYParser::VarDefContext* decl) {
|
||||||
if (scopes_.empty()) {
|
table_[name] = decl;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
auto temp_stack = scopes_;
|
|
||||||
while (!temp_stack.empty()) {
|
|
||||||
auto& scope = temp_stack.top();
|
|
||||||
auto it = scope.var_symbols.find(name);
|
|
||||||
if (it != scope.var_symbols.end()) {
|
|
||||||
out_info = it->second.first;
|
|
||||||
out_decl_ctx = it->second.second;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
temp_stack.pop();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找函数(从当前作用域向上遍历,通常函数在全局作用域)
|
bool SymbolTable::Contains(const std::string& name) const {
|
||||||
bool SymbolTable::LookupFunc(const std::string& name, FuncInfo& out_info, void*& out_decl_ctx) const {
|
return table_.find(name) != table_.end();
|
||||||
if (scopes_.empty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
auto temp_stack = scopes_;
|
|
||||||
while (!temp_stack.empty()) {
|
|
||||||
auto& scope = temp_stack.top();
|
|
||||||
auto it = scope.func_symbols.find(name);
|
|
||||||
if (it != scope.func_symbols.end()) {
|
|
||||||
out_info = it->second.first;
|
|
||||||
out_decl_ctx = it->second.second;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
temp_stack.pop();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查当前作用域是否包含指定变量
|
SysYParser::VarDefContext* SymbolTable::Lookup(const std::string& name) const {
|
||||||
bool SymbolTable::CurrentScopeHasVar(const std::string& name) const {
|
auto it = table_.find(name);
|
||||||
if (scopes_.empty()) {
|
return it == table_.end() ? nullptr : it->second;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return scopes_.top().var_symbols.count(name) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查当前作用域是否包含指定函数
|
|
||||||
bool SymbolTable::CurrentScopeHasFunc(const std::string& name) const {
|
|
||||||
if (scopes_.empty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return scopes_.top().func_symbols.count(name) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 进入循环
|
|
||||||
void SymbolTable::EnterLoop() {
|
|
||||||
loop_depth_++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 离开循环
|
|
||||||
void SymbolTable::ExitLoop() {
|
|
||||||
if (loop_depth_ > 0) loop_depth_--;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查是否在循环内
|
|
||||||
bool SymbolTable::InLoop() const {
|
|
||||||
return loop_depth_ > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 清空所有作用域和状态
|
|
||||||
void SymbolTable::Clear() {
|
|
||||||
while (!scopes_.empty()) {
|
|
||||||
scopes_.pop();
|
|
||||||
}
|
|
||||||
loop_depth_ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取当前作用域中所有变量名
|
|
||||||
std::vector<std::string> SymbolTable::GetCurrentScopeVarNames() const {
|
|
||||||
std::vector<std::string> names;
|
|
||||||
if (!scopes_.empty()) {
|
|
||||||
for (const auto& pair : scopes_.top().var_symbols) {
|
|
||||||
names.push_back(pair.first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取当前作用域中所有函数名
|
|
||||||
std::vector<std::string> SymbolTable::GetCurrentScopeFuncNames() const {
|
|
||||||
std::vector<std::string> names;
|
|
||||||
if (!scopes_.empty()) {
|
|
||||||
for (const auto& pair : scopes_.top().func_symbols) {
|
|
||||||
names.push_back(pair.first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 调试:打印符号表内容
|
|
||||||
void SymbolTable::Dump() const {
|
|
||||||
std::cout << "符号表内容 (作用域深度: " << scopes_.size() << "):\n";
|
|
||||||
int scope_idx = 0;
|
|
||||||
auto temp_stack = scopes_;
|
|
||||||
|
|
||||||
while (!temp_stack.empty()) {
|
|
||||||
std::cout << "\n作用域 " << scope_idx++ << ":\n";
|
|
||||||
auto& scope = temp_stack.top();
|
|
||||||
|
|
||||||
std::cout << " 变量:\n";
|
|
||||||
for (const auto& var_pair : scope.var_symbols) {
|
|
||||||
const VarInfo& info = var_pair.second.first;
|
|
||||||
std::cout << " " << var_pair.first << ": "
|
|
||||||
<< SymbolTypeToString(info.type)
|
|
||||||
<< (info.is_const ? " (const)" : "")
|
|
||||||
<< (info.IsArray() ? " [数组]" : "")
|
|
||||||
<< "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << " 函数:\n";
|
|
||||||
for (const auto& func_pair : scope.func_symbols) {
|
|
||||||
const FuncInfo& info = func_pair.second.first;
|
|
||||||
std::cout << " " << func_pair.first << ": "
|
|
||||||
<< SymbolTypeToString(info.ret_type) << " ("
|
|
||||||
<< info.param_types.size() << " 个参数)\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
temp_stack.pop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in new issue