mbtcc
is a C compiler written in Moonbit, aiming to support the full C11 standard. This project is currently under development.
You can compile a C source file as follows:
mbtcc -file your_source_file.c
Or compile a string directly:
mbtcc -code "int main() { return 0; }"
-code <code>
: Compile the given code string.-file <file>
: Compile the code from the specified file.--print-toks
: Print the tokens after lexing.--stop-after=lex
: Stop after the lexing phase.--stop-after=parse
: Stop after the parsing phase.--help
: Show the help message.
- Improve Preprocessing: Enhance the preprocessing mechanism to be more robust and feature-complete.
- GNU Extensions: Add support for common GNU extensions to improve compatibility with existing C codebases.
- Compiler Options: Introduce more granular and standardized compiler options for better control over the compilation process.
- Semantic Analysis: Implement comprehensive semantic checks.
- Diagnostics: Provide user-friendly error and warning messages.
- Self-Hosting: Bootstrap the compiler with the C backend generated by the Moonbit compiler itself.
- Large-scale Projects: Compile complex and large-scale projects like Lua or SQLite to test and improve the compiler's capabilities.
This project is experimental and under heavy development. It is not suitable for production environments. Please use it for educational or experimental purposes only.
mbtcc
是一个使用 Moonbit 编写的 C 语言编译器,目标是支持完整的 C11 标准。项目正在积极开发中。
你可以像下面这样编译一个 C 源文件:
mbtcc -file your_source_file.c
或者直接编译一个代码字符串:
mbtcc -code "int main() { return 0; }"
-code <code>
: 编译给定的代码字符串。-file <file>
: 编译指定的源文件。--print-toks
: 在词法分析后打印 token 序列。--stop-after=lex
: 在词法分析阶段结束后停止。--stop-after=parse
: 在语法分析阶段结束后停止。--help
: 显示帮助信息。
- 完善预处理机制: 增强预处理器,使其功能更完整、更健壮。
- 支持 GNU 扩展: 增加对常见 GNU 扩展的支持,以提高与现有 C 代码库的兼容性。
- 更多编译选项: 引入更多、更规范的编译选项,以便更好地控制编译过程。
- 语义检查: 实现全面的语义检查。
- 诊断信息: 提供友好的错误和警告提示。
- 自举: 使用 Moonbit 编译器自身生成的 C 后端来编译本编译器。
- 大型项目: 编译例如 Lua、SQLite 等复杂大型项目,以测试和提升编译器能力。
本项目是实验性的,正在密集开发中,不适合在生产环境中使用。请仅将其用于学习或实验目的。