nushell/src/parser.rs

24 lines
596 B
Rust
Raw Normal View History

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;
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;
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();
let tokens = Lexer::new(input);
2019-05-26 06:54:41 +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
}