1//! Parsing utilities for Rune.
23mod expectation;
4mod id;
5mod lexer;
6mod parse;
7mod parser;
8mod peek;
9mod resolve;
10mod traits;
1112pub use self::expectation::Expectation;
13pub(crate) use self::expectation::IntoExpectation;
14pub(crate) use self::id::NonZeroId;
15pub(crate) use self::lexer::{Lexer, LexerMode};
16pub use self::parse::Parse;
17pub use self::parser::{Parser, Peeker};
18pub use self::peek::Peek;
19pub(crate) use self::resolve::{Resolve, ResolveContext};
20pub(crate) use self::traits::Advance;
2122use crate::compile;
23use crate::SourceId;
2425/// Parse the given input as the given type that implements [Parse]. The
26/// specified `source_id` will be used when referencing any parsed elements.
27/// `shebang` indicates if the parser should try to parse a shebang or not.
28///
29/// This will raise an error through [Parser::eof] if the specified `source` is
30/// not fully consumed by the parser.
31pub fn parse_all<T>(source: &str, source_id: SourceId, shebang: bool) -> compile::Result<T>
32where
33T: Parse,
34{
35let mut parser = Parser::new(source, source_id, shebang);
36let ast = parser.parse::<T>()?;
37 parser.eof()?;
38Ok(ast)
39}