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