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:
Jakob Stoklund Olesen
2016-09-13 11:01:21 -07:00
parent c80934d084
commit fcec517fc5
7 changed files with 20 additions and 17 deletions

View File

@@ -8,7 +8,7 @@ use std::io::{self, Read};
use CommandResult;
use cton_reader::parser::Parser;
use cton_reader::parse_functions;
use cretonne::write::write_function;
pub fn run(files: Vec<String>) -> CommandResult {
@@ -26,7 +26,7 @@ fn cat_one(filename: String) -> CommandResult {
let mut buffer = String::new();
try!(file.read_to_string(&mut buffer)
.map_err(|e| format!("Couldn't read {}: {}", filename, e)));
let items = try!(Parser::parse(&buffer).map_err(|e| format!("{}: {}", filename, e)));
let items = try!(parse_functions(&buffer).map_err(|e| format!("{}: {}", filename, e)));
for (idx, func) in items.into_iter().enumerate() {
if idx != 0 {