Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 C# 中有一些 Lua 代码作为字符串,我想检查它是否有效(任何语法错误,诸如此类)。
我怎样才能快速有效地做到这一点?
编辑:另一个建议的重复问题不仅检查有效语法,而且检查有效代码,如果该有效行需要在其之前声明的其他变量,则当向其提供一行有效 lua 代码时,luaL_loadstirng 将失败。
编译它。打电话Lua.LoadString。这会给你编译时错误(语法错误)。要查找运行时错误,您只需要运行它。
Lua.LoadString