Files
zen/core/expression/src/parser/result.rs
T
stefan-gorules 3e7cdfcde1 feat: intellisense (#244)
* local: fault tolerant parser

* fix tests

* add intellisense

* fix minor issues

* improve support

* fix fmt

* fix

* fix: improve error messages

* improve error handling and ast

* fix lint

* fix tests

* exclude zen-nodejs from rust tests
2024-09-23 09:23:48 +02:00

29 lines
705 B
Rust

use crate::parser::{Node, ParserError};
use nohash_hasher::BuildNoHashHasher;
use std::collections::HashMap;
#[derive(Debug)]
pub struct ParserResult<'a> {
pub root: &'a Node<'a>,
pub is_complete: bool,
pub metadata: Option<HashMap<usize, NodeMetadata, BuildNoHashHasher<usize>>>,
}
#[derive(Debug, Clone)]
pub struct NodeMetadata {
pub span: (u32, u32),
}
impl<'a> ParserResult<'a> {
pub fn error(&self) -> Result<(), ParserError> {
if !self.is_complete {
return Err(ParserError::Incomplete);
}
match self.root.first_error() {
None => Ok(()),
Some(err) => Err(ParserError::NodeError(err.to_string())),
}
}
}