Skip to main content

luaur_ast/methods/
parser_report_stat_error.rs

1use crate::records::ast_array::AstArray;
2use crate::records::ast_expr::AstExpr;
3use crate::records::ast_stat::AstStat;
4use crate::records::ast_stat_error::AstStatError;
5use crate::records::location::Location;
6use crate::records::parser::Parser;
7
8impl Parser {
9    pub fn report_stat_error(
10        &mut self,
11        location: Location,
12        expressions: AstArray<*mut AstExpr>,
13        statements: AstArray<*mut AstStat>,
14        format: core::fmt::Arguments<'_>,
15    ) -> *mut AstStatError {
16        self.report(location, format);
17
18        let message_index = (self.parse_errors.len() as u32).saturating_sub(1);
19
20        unsafe {
21            let allocator = &mut *self.allocator;
22            allocator.alloc(AstStatError::new(
23                location,
24                expressions,
25                statements,
26                message_index,
27            ))
28        }
29    }
30}