@@ -34,26 +34,21 @@ use crate::{
34
34
} ;
35
35
use std:: collections:: HashMap ;
36
36
37
- pub struct Parser < ' a > {
38
- input : Input < ' a > ,
39
- typedefs : HashMap < String , CTypedef > ,
37
+ pub struct Parser < ' input , ' diagnostics > {
38
+ input : Input < ' input > ,
39
+ pub ast_file : AstFile ,
40
+ pub typedefs : HashMap < String , CTypedef > ,
41
+ pub diagnostics : & ' diagnostics Diagnostics < ' diagnostics > ,
40
42
enum_constants : HashMap < String , Integer > ,
41
- diagnostics : & ' a Diagnostics < ' a > ,
42
43
c_file_type : CFileType ,
43
44
}
44
45
45
- impl Parser < ' _ > {
46
- pub fn typedefs ( & self ) -> & HashMap < String , CTypedef > {
47
- & self . typedefs
48
- }
49
-
50
- pub fn typedefs_mut ( & mut self ) -> & mut HashMap < String , CTypedef > {
51
- & mut self . typedefs
52
- }
53
- }
54
-
55
- impl < ' a > Parser < ' a > {
56
- pub fn new ( input : Input < ' a > , diagnostics : & ' a Diagnostics < ' a > , c_file_type : CFileType ) -> Self {
46
+ impl < ' input , ' diagnostics > Parser < ' input , ' diagnostics > {
47
+ pub fn new (
48
+ input : Input < ' input > ,
49
+ diagnostics : & ' diagnostics Diagnostics < ' diagnostics > ,
50
+ c_file_type : CFileType ,
51
+ ) -> Self {
57
52
let mut typedefs = HashMap :: default ( ) ;
58
53
59
54
diagnostics. push ( WarningDiagnostic :: new (
@@ -72,6 +67,7 @@ impl<'a> Parser<'a> {
72
67
) ;
73
68
74
69
Self {
70
+ ast_file : AstFile :: new ( ) ,
75
71
input,
76
72
typedefs,
77
73
enum_constants : HashMap :: default ( ) ,
@@ -84,7 +80,7 @@ impl<'a> Parser<'a> {
84
80
self . input . switch_input ( tokens) ;
85
81
}
86
82
87
- pub fn parse ( & mut self ) -> Result < AstFile , ParseError > {
83
+ pub fn parse ( & mut self ) -> Result < ( ) , ParseError > {
88
84
let mut ast_file = AstFile :: new ( ) ;
89
85
90
86
while !self . input . peek ( ) . is_end_of_file ( ) {
@@ -141,7 +137,7 @@ impl<'a> Parser<'a> {
141
137
}
142
138
}
143
139
144
- Ok ( ast_file )
140
+ Ok ( ( ) )
145
141
}
146
142
147
143
fn parse_external_declaration ( & mut self ) -> Result < ExternalDeclaration , ParseError > {
0 commit comments