Skip to main content

luaur_ast/methods/
parser_report_expr_error.rs

1use crate::records::ast_array::AstArray;
2use crate::records::ast_expr::AstExpr;
3use crate::records::ast_expr_error::AstExprError;
4use crate::records::location::Location;
5use crate::records::parser::Parser;
6
7impl Parser {
8    pub fn report_expr_error(
9        &mut self,
10        location: Location,
11        expressions: AstArray<*mut AstExpr>,
12        format: core::fmt::Arguments<'_>,
13    ) -> *mut AstExprError {
14        self.report(location, format);
15
16        let message_index = (self.parse_errors.len() as u32).saturating_sub(1);
17
18        unsafe {
19            crate::records::allocator::Allocator::alloc(
20                &mut *self.allocator,
21                AstExprError {
22                    base: AstExpr {
23                        base: crate::records::ast_node::AstNode {
24                            class_index: <AstExprError as crate::rtti::AstNodeClass>::CLASS_INDEX,
25                            location,
26                        },
27                    },
28                    expressions,
29                    message_index,
30                },
31            )
32        }
33    }
34}