forked from extern/nushell
Start working on highlighter
This commit is contained in:
parent
1ac0c0bfc5
commit
07c22c7e81
@ -74,7 +74,7 @@ fn main() -> std::io::Result<()> {
|
||||
.required("y", SyntaxShape::Int, "y value");
|
||||
working_set.add_decl(sig.into());
|
||||
|
||||
working_set.delta
|
||||
working_set.render()
|
||||
};
|
||||
|
||||
{
|
||||
@ -134,7 +134,7 @@ fn main() -> std::io::Result<()> {
|
||||
);
|
||||
println!("{:#?}", output);
|
||||
println!("Error: {:?}", err);
|
||||
working_set.delta
|
||||
working_set.render()
|
||||
};
|
||||
|
||||
ParserState::merge_delta(&mut *parser_state.borrow_mut(), delta);
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::{parser::Block, Declaration, Span};
|
||||
use std::{cell::RefCell, collections::HashMap, rc::Rc, sync::Arc};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ParserState {
|
||||
@ -327,6 +327,10 @@ impl<'a> ParserWorkingSet<'a> {
|
||||
self.delta.decls.get(decl_id - num_permanent_decls).cloned()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render(self) -> ParserDelta {
|
||||
self.delta
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -362,7 +366,7 @@ mod parser_state_tests {
|
||||
let delta = {
|
||||
let mut working_set = ParserWorkingSet::new(&parser_state);
|
||||
working_set.add_file("child.nu".into(), &[]);
|
||||
working_set.delta
|
||||
working_set.render()
|
||||
};
|
||||
|
||||
ParserState::merge_delta(&mut parser_state, delta);
|
||||
|
@ -1,24 +1,36 @@
|
||||
use std::sync::Arc;
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use crate::{Block, Expr, Expression, ParserState, ParserWorkingSet, Statement};
|
||||
|
||||
fn syntax_highlight<'a, 'b>(parser_state: &'a ParserState, input: &'b [u8]) {
|
||||
// let mut working_set = ParserWorkingSet::new(parser_state);
|
||||
|
||||
// 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
|
||||
struct Highlighter {
|
||||
parser_state: Rc<RefCell<ParserState>>,
|
||||
}
|
||||
|
||||
fn highlight_expression(expression: &Expression) {
|
||||
// match &expression.expr {
|
||||
// Expr::BinaryOp()
|
||||
// }
|
||||
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);
|
||||
|
||||
block
|
||||
};
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
fn highlight_expression(expression: &Expression) {
|
||||
// match &expression.expr {
|
||||
// Expr::BinaryOp()
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user