pub struct Parser<'src, V: LuaVersion> { /* private fields */ }Expand description
The main parser. Feed it Lua source code and get back an Ast.
The type parameter V selects which Lua version’s grammar to use.
Pick one of Luau, Lua51,
Lua52, Lua53, or Lua54.
§Example
use luaparse_rs::{Parser, Luau};
let parser = Parser::<Luau>::new("local x = 1").unwrap();
let ast = parser.parse().unwrap();Implementations§
Source§impl<'src, V: LuaVersion> Parser<'src, V>
impl<'src, V: LuaVersion> Parser<'src, V>
pub fn skip_generic_args(&mut self) -> Result<(), ParseError>
Source§impl<'src, V: LuaVersion> Parser<'src, V>
impl<'src, V: LuaVersion> Parser<'src, V>
Sourcepub fn new(source: &'src str) -> Result<Self, LexError>
pub fn new(source: &'src str) -> Result<Self, LexError>
Creates a new parser from a source string.
This tokenizes the input immediately. If the source contains invalid
tokens (like an unterminated string), you’ll get a LexError here.
Sourcepub fn parse(self) -> Result<Ast, ParseError>
pub fn parse(self) -> Result<Ast, ParseError>
Parses the source and returns the full syntax tree.
This consumes the parser. If you need type declarations (Luau),
use parse_with_types instead.
Sourcepub fn parse_with_types(self) -> Result<AstWithTypes, ParseError>
pub fn parse_with_types(self) -> Result<AstWithTypes, ParseError>
Parses the source and returns the syntax tree along with type declarations.
This is the Luau variant of parse. It pulls type and
export type declarations into a separate list so you can work with them
independently from the rest of the code.
Auto Trait Implementations§
impl<'src, V> Freeze for Parser<'src, V>
impl<'src, V> RefUnwindSafe for Parser<'src, V>where
V: RefUnwindSafe,
impl<'src, V> Send for Parser<'src, V>where
V: Send,
impl<'src, V> Sync for Parser<'src, V>where
V: Sync,
impl<'src, V> Unpin for Parser<'src, V>where
V: Unpin,
impl<'src, V> UnsafeUnpin for Parser<'src, V>
impl<'src, V> UnwindSafe for Parser<'src, V>where
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more