Simplify the interface to cretonne-reader.
Export a single function: parse_functions() which results a vector of functions parsed from the source string. Hide the parser and lexer modules. They are not useful to external clients.
This commit is contained in:
@@ -21,6 +21,13 @@ use cretonne::ir::instructions::{InstructionFormat, InstructionData, VariableArg
|
||||
|
||||
pub use lexer::Location;
|
||||
|
||||
/// Parse the entire `text` into a list of functions.
|
||||
///
|
||||
/// Any test commands or ISA declarations are ignored.
|
||||
pub fn parse_functions(text: &str) -> Result<Vec<Function>> {
|
||||
Parser::new(text).parse_function_list()
|
||||
}
|
||||
|
||||
/// A parse error is returned when the parse failed.
|
||||
#[derive(Debug)]
|
||||
pub struct Error {
|
||||
@@ -256,11 +263,6 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse the entire string into a list of functions.
|
||||
pub fn parse(text: &'a str) -> Result<Vec<Function>> {
|
||||
Self::new(text).parse_function_list()
|
||||
}
|
||||
|
||||
// Consume the current lookahead token and return it.
|
||||
fn consume(&mut self) -> Token<'a> {
|
||||
self.lookahead.take().expect("No token to consume")
|
||||
|
||||
Reference in New Issue
Block a user