2018-11-11 19:27:00 +00:00
|
|
|
mod byte;
|
2018-11-11 19:41:43 +00:00
|
|
|
mod byte_string;
|
2018-11-08 14:42:00 +00:00
|
|
|
mod char;
|
|
|
|
mod string;
|
2019-01-28 20:03:56 +00:00
|
|
|
mod block;
|
2018-11-08 14:42:00 +00:00
|
|
|
|
2019-01-07 13:15:47 +00:00
|
|
|
use crate::{
|
2019-02-20 13:16:14 +00:00
|
|
|
SourceFile, SyntaxError, AstNode,
|
2019-01-07 13:15:47 +00:00
|
|
|
ast,
|
|
|
|
algo::visit::{visitor_ctx, VisitorCtx},
|
|
|
|
};
|
|
|
|
|
|
|
|
pub(crate) fn validate(file: &SourceFile) -> Vec<SyntaxError> {
|
2018-11-08 14:42:00 +00:00
|
|
|
let mut errors = Vec::new();
|
|
|
|
for node in file.syntax().descendants() {
|
|
|
|
let _ = visitor_ctx(&mut errors)
|
2018-11-11 19:27:00 +00:00
|
|
|
.visit::<ast::Byte, _>(self::byte::validate_byte_node)
|
2018-11-11 19:41:43 +00:00
|
|
|
.visit::<ast::ByteString, _>(self::byte_string::validate_byte_string_node)
|
2018-11-08 14:42:00 +00:00
|
|
|
.visit::<ast::Char, _>(self::char::validate_char_node)
|
|
|
|
.visit::<ast::String, _>(self::string::validate_string_node)
|
2019-01-28 20:03:56 +00:00
|
|
|
.visit::<ast::Block, _>(self::block::validate_block_node)
|
2018-11-08 14:42:00 +00:00
|
|
|
.accept(node);
|
|
|
|
}
|
|
|
|
errors
|
|
|
|
}
|