Skip to main content

svugy_parse/markdown/
diagnostic.rs

1//! Report what a Markdown diagram file holds that cannot be read, each error labelled at its source.
2
3use super::{MarkdownImport, MarkdownParse};
4use crate::diagnostic::{NoWarning, SourceError, SourceLanguage};
5
6/// Mark Markdown as a source language: its errors are Markdown errors, and it leaves every warning to the model's checks.
7#[derive(Debug, Clone, PartialEq, Eq)]
8pub struct MarkdownLanguage;
9
10/// Report a Markdown error: a part of the diagram file that cannot be read, left out of the model.
11pub type MarkdownError = SourceError<MarkdownLanguage>;
12
13/// Record the Markdown errors the layers raise, handed from one layer to the next.
14pub(crate) type Diagnostics = crate::diagnostic::Diagnostics<MarkdownLanguage>;
15
16impl SourceLanguage for MarkdownLanguage {
17    const ERROR_CODE: &'static str = "svugy::markdown";
18    type Warning = NoWarning;
19
20    fn import(source_text: &str) -> MarkdownImport {
21        let parsed = MarkdownParse::parse(source_text);
22        parsed.lower()
23    }
24}