mirror of
https://github.com/nushell/nushell.git
synced 2025-02-23 22:11:53 +01:00
This commit should finish the `coloring_in_tokens` feature, which moves the shape accumulator into the token stream. This allows rollbacks of the token stream to also roll back any shapes that were added. This commit also adds a much nicer syntax highlighter trace, which shows all of the paths the highlighter took to arrive at a particular coloring output. This change is fairly substantial, but really improves the understandability of the flow. I intend to update the normal parser with a similar tracing view. In general, this change also fleshes out the concept of "atomic" token stream operations. A good next step would be to try to make the parser more error-correcting, using the coloring infrastructure. A follow-up step would involve merging the parser and highlighter shapes themselves.
31 lines
1002 B
Rust
31 lines
1002 B
Rust
pub(crate) mod deserializer;
|
|
pub(crate) mod hir;
|
|
pub(crate) mod parse;
|
|
pub(crate) mod parse_command;
|
|
pub(crate) mod registry;
|
|
|
|
use crate::errors::ShellError;
|
|
|
|
pub(crate) use deserializer::ConfigDeserializer;
|
|
pub(crate) use hir::syntax_shape::flat_shape::FlatShape;
|
|
pub(crate) use hir::TokensIterator;
|
|
pub(crate) use parse::call_node::CallNode;
|
|
pub(crate) use parse::files::Files;
|
|
pub(crate) use parse::flag::{Flag, FlagKind};
|
|
pub(crate) use parse::operator::Operator;
|
|
pub(crate) use parse::parser::{nom_input, pipeline};
|
|
pub(crate) use parse::text::Text;
|
|
pub(crate) use parse::token_tree::{DelimitedNode, Delimiter, TokenNode};
|
|
pub(crate) use parse::tokens::{RawNumber, RawToken};
|
|
pub(crate) use parse::unit::Unit;
|
|
pub(crate) use registry::CommandRegistry;
|
|
|
|
pub fn parse(input: &str) -> Result<TokenNode, ShellError> {
|
|
let _ = pretty_env_logger::try_init();
|
|
|
|
match pipeline(nom_input(input)) {
|
|
Ok((_rest, val)) => Ok(val),
|
|
Err(err) => Err(ShellError::parse_error(err)),
|
|
}
|
|
}
|