2019-05-28 06:45:18 +00:00
|
|
|
crate mod ast;
|
2019-05-15 16:12:38 +00:00
|
|
|
crate mod completer;
|
2019-05-29 15:26:45 +00:00
|
|
|
crate mod lexer;
|
2019-05-26 06:54:41 +00:00
|
|
|
crate mod parser;
|
|
|
|
crate mod registry;
|
2019-05-30 04:19:46 +00:00
|
|
|
crate mod span;
|
2019-05-11 04:45:57 +00:00
|
|
|
|
2019-05-28 06:45:18 +00:00
|
|
|
crate use ast::{ParsedCommand, Pipeline};
|
2019-05-26 06:54:41 +00:00
|
|
|
crate use registry::{CommandConfig, CommandRegistry};
|
|
|
|
|
|
|
|
use crate::errors::ShellError;
|
2019-05-30 04:19:46 +00:00
|
|
|
use lexer::Lexer;
|
2019-05-26 06:54:41 +00:00
|
|
|
use parser::PipelineParser;
|
|
|
|
|
|
|
|
pub fn parse(input: &str, _registry: &dyn CommandRegistry) -> Result<Pipeline, ShellError> {
|
|
|
|
let parser = PipelineParser::new();
|
2019-05-30 04:19:46 +00:00
|
|
|
let tokens = Lexer::new(input);
|
2019-05-26 06:54:41 +00:00
|
|
|
|
2019-05-30 04:19:46 +00:00
|
|
|
match parser.parse(tokens) {
|
|
|
|
Ok(val) => Ok(val),
|
|
|
|
Err(err) => Err(ShellError::parse_error(err, input.to_string())),
|
|
|
|
}
|
2019-05-26 06:54:41 +00:00
|
|
|
}
|