pub fn parse_fallible(code: &str, lua_version: LuaVersion) -> AstResultExpand description
Given code and a pinned Lua version, will produce an ast::AstResult.
This AstResult always produces some Ast, regardless of errors.
If a partial Ast is produced (i.e. if there are any errors), a few guarantees are lost:
- Tokens may be produced that aren’t in the code itself. For example,
if x == 2 code()will produce a phantomthentoken in order to produce a usableIfstruct. These phantom tokens will have a null position. If you need accurate positions from the phantom tokens, you can callAst::update_positions. - The code, when printed, is not guaranteed to be valid Lua.
This can happen in the case of something like
local x = if, which will produce aLocalAssignmentthat would print tolocal x =. - There are no stability guarantees for partial Ast results, but they are consistent within the same exact version of full-moon.