nushell/src/syntax_highlight.rs

37 lines
959 B
Rust
Raw Normal View History

2021-07-22 09:48:45 +02:00
use std::{cell::RefCell, rc::Rc};
2021-07-17 08:31:34 +02:00
use crate::{Block, Expr, Expression, ParserState, ParserWorkingSet, Statement};
2021-07-22 09:48:45 +02:00
struct Highlighter {
parser_state: Rc<RefCell<ParserState>>,
}
2021-07-17 08:31:34 +02:00
2021-07-22 09:48:45 +02:00
impl Highlighter {
fn syntax_highlight(&self, input: &[u8]) {
let block = {
let parser_state = self.parser_state.borrow();
let mut working_set = ParserWorkingSet::new(&*parser_state);
let (block, _) = working_set.parse_source(input, false);
2021-07-17 08:31:34 +02:00
2021-07-22 09:48:45 +02:00
block
};
2021-07-17 08:31:34 +02:00
2021-07-22 09:48:45 +02:00
// let (block, _) = working_set.parse_source(input, false);
// for stmt in &block.stmts {
// match stmt {
// Statement::Expression(expr) => {
// }
// }
// }
// No merge at the end because this parse is speculative
}
2021-07-17 08:31:34 +02:00
2021-07-22 09:48:45 +02:00
fn highlight_expression(expression: &Expression) {
// match &expression.expr {
// Expr::BinaryOp()
// }
}
2021-07-17 08:31:34 +02:00
}