#![forbid(unsafe_code)]
#![warn(missing_docs)]
mod error;
pub mod logos_lexer;
mod parser;
mod span;
pub use error::{ParseError, ParseErrorKind};
pub use span::{SYNTHESIZED_FILE_ID, Span, Spanned};
use rustledger_core::Directive;
#[derive(Debug)]
pub struct ParseResult {
pub directives: Vec<Spanned<Directive>>,
pub options: Vec<(String, String, Span)>,
pub includes: Vec<(String, Span)>,
pub plugins: Vec<(String, Option<String>, Span)>,
pub comments: Vec<Spanned<String>>,
pub errors: Vec<ParseError>,
pub warnings: Vec<ParseWarning>,
}
#[derive(Debug, Clone)]
pub struct ParseWarning {
pub message: String,
pub span: Span,
}
impl ParseWarning {
pub fn new(message: impl Into<String>, span: Span) -> Self {
Self {
message: message.into(),
span,
}
}
}
pub fn parse(source: &str) -> ParseResult {
parser::parse(source)
}
pub fn parse_directives(source: &str) -> (Vec<Spanned<Directive>>, Vec<ParseError>) {
let result = parse(source);
(result.directives, result.errors)
}