Better errors and more fleshed out semantics

This commit is contained in:
Yehuda Katz
2019-05-29 21:19:46 -07:00
parent 8f5d959692
commit b7d15c2afd
14 changed files with 1844 additions and 1793 deletions

View File

@ -3,17 +3,21 @@ crate mod completer;
crate mod lexer;
crate mod parser;
crate mod registry;
crate mod span;
crate use ast::{ParsedCommand, Pipeline};
crate use registry::{CommandConfig, CommandRegistry};
use crate::errors::ShellError;
use lexer::Lexer;
use parser::PipelineParser;
pub fn parse(input: &str, _registry: &dyn CommandRegistry) -> Result<Pipeline, ShellError> {
let parser = PipelineParser::new();
let tokens = Lexer::new(input);
parser
.parse(input)
.map_err(|e| ShellError::string(format!("{:?}", e)))
match parser.parse(tokens) {
Ok(val) => Ok(val),
Err(err) => Err(ShellError::parse_error(err, input.to_string())),
}
}