luaur_ast/methods/
parser_parse_break.rs1use crate::records::ast_array::AstArray;
2use crate::records::ast_stat::AstStat;
3use crate::records::ast_stat_break::AstStatBreak;
4use crate::records::function::Function;
5use crate::records::location::Location;
6use crate::records::parser::Parser;
7
8impl Parser {
9 pub fn parser_parse_break(&mut self) -> *mut AstStat {
10 let start = self.lexer.current().location;
11
12 self.next_lexeme(); if self.function_stack.last().unwrap().loop_depth == 0 {
15 return self.report_stat_error(
16 start,
17 AstArray::default(),
18 AstArray::default(),
19 format_args!("break statement must be inside a loop"),
20 ) as *mut AstStat;
21 }
22
23 unsafe { (*self.allocator).alloc(AstStatBreak::new(start)) as *mut AstStat }
24 }
25}