Skip to main content

luaur_ast/methods/
parser_parse_attributes.rs

1use crate::records::ast_array::AstArray;
2use crate::records::ast_attr::AstAttr;
3use crate::records::lexeme::Type;
4use crate::records::parser::Parser;
5use crate::records::temp_vector::TempVector;
6
7impl Parser {
8    // attributes ::= {attribute}
9    pub fn parse_attributes(&mut self) -> AstArray<*mut AstAttr> {
10        let r#type = self.lexer.current().r#type;
11
12        luaur_common::macros::luau_assert::LUAU_ASSERT!(
13            r#type == Type::Attribute || r#type == Type::AttributeOpen
14        );
15
16        let mut attributes = TempVector::new(&mut self.scratch_attr);
17
18        while self.lexer.current().r#type == Type::Attribute
19            || self.lexer.current().r#type == Type::AttributeOpen
20        {
21            self.parse_attribute(&mut attributes);
22        }
23
24        self.copy_temp_vector_t(&attributes)
25    }
26}