luaur_ast/methods/
parser_extract_string_details.rs1use crate::enums::quote_style_cst::QuoteStyle;
2use crate::records::lexeme::Type;
3use crate::records::parser::Parser;
4use luaur_common::macros::luau_assert::LUAU_ASSERT;
5
6impl Parser {
7 pub fn extract_string_details(&mut self) -> (QuoteStyle, u32) {
8 let mut style: QuoteStyle = QuoteStyle::QuotedDouble;
9 let mut block_depth: u32 = 0;
10
11 let current = self.lexer.current();
12
13 match current.r#type {
14 Type::QuotedString => {
15 style = if current.get_quote_style() == crate::records::lexeme::QuoteStyle::Double {
16 QuoteStyle::QuotedDouble
17 } else {
18 QuoteStyle::QuotedSingle
19 };
20 }
21 Type::InterpStringSimple => {
22 style = QuoteStyle::QuotedInterp;
23 }
24 Type::RawString => {
25 style = QuoteStyle::QuotedRaw;
26 block_depth = current.get_block_depth();
27 }
28 _ => {
29 LUAU_ASSERT!(false);
30 }
31 }
32
33 (style, block_depth)
34 }
35}