mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 19:07:42 +02:00
Better errors and more fleshed out semantics
This commit is contained in:
@ -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())),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user