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