2021-07-22 07:48:45 +00:00
|
|
|
use std::{cell::RefCell, rc::Rc};
|
2021-07-17 06:31:34 +00:00
|
|
|
|
|
|
|
use crate::{Block, Expr, Expression, ParserState, ParserWorkingSet, Statement};
|
|
|
|
|
2021-07-22 07:48:45 +00:00
|
|
|
struct Highlighter {
|
|
|
|
parser_state: Rc<RefCell<ParserState>>,
|
|
|
|
}
|
2021-07-17 06:31:34 +00:00
|
|
|
|
2021-07-22 07:48:45 +00: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 06:31:34 +00:00
|
|
|
|
2021-07-22 07:48:45 +00:00
|
|
|
block
|
|
|
|
};
|
2021-07-17 06:31:34 +00:00
|
|
|
|
2021-07-22 07:48:45 +00: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 06:31:34 +00:00
|
|
|
|
2021-07-22 07:48:45 +00:00
|
|
|
fn highlight_expression(expression: &Expression) {
|
|
|
|
// match &expression.expr {
|
|
|
|
// Expr::BinaryOp()
|
|
|
|
// }
|
|
|
|
}
|
2021-07-17 06:31:34 +00:00
|
|
|
}
|