luaL_loadstring
根据文档返回是否存在语法错误(如果有的话)。
有没有办法确定 Lua 首先确定存在语法错误的位置,或者除了返回值表明存在语法错误之外还有其他信息吗?
最佳答案
luaL_loadstring
来电 lua_load
进行实际工作,请参阅手册:
Loads a Lua chunk (without running it). If there are no errors, lua_load pushes the compiled chunk as a Lua function on top of the stack. Otherwise, it pushes an error message.
所以你可以检查luaL_loadstring
的返回值,如果返回错误,请检查堆栈中是否有错误消息。
关于syntax - 是否可以从 luaL_loadstring 等获取有关语法错误发生位置的更多信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18374466/