can parse global variable declarations

This commit is contained in:
nora 2022-06-25 19:09:27 +02:00
parent f53c054a9a
commit 4b646b9128
5 changed files with 189 additions and 74 deletions

View file

@ -371,10 +371,20 @@ where
span.extend(span2),
))
} else {
expect!(self, Tok::Punct(Punct::Semicolon));
Ok((ExternalDecl::Decl(declaration), span))
}
}
fn external_declarations(&mut self) -> Result<Vec<Spanned<ExternalDecl>>> {
let mut decls = Vec::new();
while self.peek_t().is_ok() {
let decl = self.external_declaration()?;
decls.push(decl);
}
Ok(decls)
}
fn function_param_declaration_list(&mut self) -> Result<FunctionParams> {
// If the declarator includes a parameter type list, the declaration of each parameter shall
// include an identifier, except for the special case of a parameter list consisting of a single