luaur_ast/records/
parser.rs1use crate::enums::ast_table_access::AstTableAccess;
2use crate::enums::separator::Separator;
3use crate::records::allocator::Allocator;
4use crate::records::ast_array::AstArray;
5use crate::records::ast_attr::{AstAttr, AstAttrType};
6use crate::records::ast_declared_extern_type_property::AstDeclaredExternTypeProperty;
7use crate::records::ast_expr::AstExpr;
8use crate::records::ast_expr_error::AstExprError;
9use crate::records::ast_expr_function::AstExprFunction;
10use crate::records::ast_generic_type::AstGenericType;
11use crate::records::ast_generic_type_pack::AstGenericTypePack;
12use crate::records::ast_local::AstLocal;
13use crate::records::ast_name::AstName;
14use crate::records::ast_name_table::AstNameTable;
15use crate::records::ast_stat::AstStat;
16use crate::records::ast_stat_block::AstStatBlock;
17use crate::records::ast_stat_error::AstStatError;
18use crate::records::ast_type::AstType;
19use crate::records::ast_type_error::AstTypeError;
20use crate::records::ast_type_or_pack::AstTypeOrPack;
21use crate::records::ast_type_pack::AstTypePack;
22use crate::records::binding::Binding;
23use crate::records::comment::Comment;
24use crate::records::cst_type_instantiation::CstTypeInstantiation;
25use crate::records::function::Function;
26use crate::records::hot_comment::HotComment;
27use crate::records::lexeme::Lexeme;
28use crate::records::lexer::Lexer;
29use crate::records::location::Location;
30use crate::records::match_lexeme::MatchLexeme;
31use crate::records::name::Name;
32use crate::records::parse_error::ParseError;
33use crate::records::parse_options::ParseOptions;
34use crate::records::parse_result::ParseResult;
35use crate::records::position::Position;
36use crate::records::table_indexer_result::TableIndexerResult;
37use crate::type_aliases::ast_argument_name::AstArgumentName;
38use crate::type_aliases::ast_class_member::AstClassMember;
39use crate::type_aliases::cst_node_map::CstNodeMap;
40use luaur_common::records::dense_hash_map::DenseHashMap;
41use luaur_common::records::dense_hash_set::DenseHashSet;
42
43#[allow(non_snake_case)]
44#[derive(Debug)]
45pub struct Parser {
46 pub(crate) options: ParseOptions,
47 pub(crate) lexer: Lexer,
48 pub(crate) allocator: *mut Allocator,
49 pub(crate) comment_locations: Vec<Comment>,
50 pub(crate) hotcomments: Vec<HotComment>,
51 pub(crate) hotcomment_header: bool,
52 pub(crate) recursion_counter: u32,
53 pub(crate) name_self: AstName,
54 pub(crate) name_number: AstName,
55 pub(crate) name_error: AstName,
56 pub(crate) name_nil: AstName,
57 pub(crate) end_mismatch_suspect: Option<MatchLexeme>,
58 pub(crate) function_stack: Vec<Function>,
59 pub(crate) type_function_depth: usize,
60 pub(crate) local_map: DenseHashMap<AstName, *mut AstLocal>,
61 pub(crate) local_stack: Vec<*mut AstLocal>,
62 pub(crate) classes_within_module: DenseHashSet<AstName>,
63 pub(crate) parse_errors: Vec<ParseError>,
64 pub(crate) match_recovery_stop_on_token: Vec<u32>,
65 pub(crate) declared_export_bindings: DenseHashMap<AstName, Location>,
66 pub(crate) has_module_return: bool,
67 pub(crate) scratch_attr: Vec<*mut AstAttr>,
68 pub(crate) scratch_stat: Vec<*mut AstStat>,
69 pub(crate) scratch_string: Vec<AstArray<core::ffi::c_char>>,
70 pub(crate) scratch_string_2: Vec<AstArray<core::ffi::c_char>>,
71 pub(crate) scratch_expr: Vec<*mut AstExpr>,
72 pub(crate) scratch_expr_aux: Vec<*mut AstExpr>,
73 pub(crate) scratch_name: Vec<AstName>,
74 pub(crate) scratch_pack_name: Vec<AstName>,
75 pub(crate) scratch_binding: Vec<Binding>,
76 pub(crate) scratch_local: Vec<*mut AstLocal>,
77 pub(crate) scratch_table_type_props: Vec<crate::records::ast_table_prop::AstTableProp>,
78 pub(crate) scratch_cst_table_type_props: Vec<crate::records::cst_type_table::Item>,
79 pub(crate) scratch_type: Vec<*mut AstType>,
80 pub(crate) scratch_type_or_pack: Vec<AstTypeOrPack>,
81 pub(crate) scratch_declared_class_props: Vec<AstDeclaredExternTypeProperty>,
82 pub(crate) scratch_class_declarations: Vec<AstClassMember>,
83 pub(crate) scratch_item: Vec<crate::records::ast_expr_table::Item>,
84 pub(crate) scratch_cst_item: Vec<crate::records::cst_expr_table::Item>,
85 pub(crate) scratch_arg_name: Vec<AstArgumentName>,
86 pub(crate) scratch_generic_types: Vec<*mut AstGenericType>,
87 pub(crate) scratch_generic_type_packs: Vec<*mut AstGenericTypePack>,
88 pub(crate) scratch_opt_arg_name: Vec<Option<AstArgumentName>>,
89 pub(crate) scratch_position: Vec<Position>,
90 pub(crate) scratch_position_2: Vec<Position>,
91 pub(crate) scratch_data: String,
92 pub(crate) cst_node_map: CstNodeMap,
93}
94
95#[allow(non_snake_case)]
96#[derive(Debug, Clone, Copy)]
97pub(crate) struct Local {
98 pub(crate) local: *mut AstLocal,
99 pub(crate) offset: u32,
100}
101
102impl Default for Local {
103 fn default() -> Self {
104 Self {
105 local: core::ptr::null_mut(),
106 offset: 0,
107 }
108 }
109}