mirror of
https://github.com/Noratrieb/uwucc.git
synced 2026-01-14 16:45:07 +01:00
things
This commit is contained in:
parent
475a520de3
commit
683f11c997
6 changed files with 111 additions and 13 deletions
|
|
@ -262,3 +262,25 @@ pub enum ExternalDecl {
|
|||
}
|
||||
|
||||
pub type TranslationUnit = Vec<Spanned<ExternalDecl>>;
|
||||
|
||||
impl Decl {
|
||||
pub fn uwnrap_normal(&self) -> &NormalDecl {
|
||||
match self {
|
||||
Decl::Normal(decl) => decl,
|
||||
Decl::StaticAssert => {
|
||||
panic!("Expected normal declaration, found static assert declaration")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DirectDeclarator {
|
||||
pub fn unwrap_with_params(&self) -> (&Ident, &Vec<FunctionParamDecl>) {
|
||||
match self {
|
||||
DirectDeclarator::Ident(_) => {
|
||||
panic!("Expected declarator with parameters, found single identifier declarator1")
|
||||
}
|
||||
DirectDeclarator::WithParams { ident, params } => (ident, params),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
ast::{
|
||||
Decl, DeclAttr, DeclSpec, Declarator, DirectDeclarator, ExternalDecl, FunctionDef,
|
||||
FunctionParamDecl, Ident, InitDecl, IntTy, IntTyKind, IntTySignedness, NormalDecl, Stmt,
|
||||
TypeSpecifier, TranslationUnit,
|
||||
TranslationUnit, TypeSpecifier,
|
||||
},
|
||||
pre::Punctuator as P,
|
||||
token::{Keyword as Kw, Token as Tok},
|
||||
|
|
@ -307,7 +307,7 @@ where
|
|||
kind: IntTyKind::Int,
|
||||
}),
|
||||
Tok::Kw(Kw::Long) => {
|
||||
if let Some(_) = eat!(self, Tok::Kw(Kw::Long)) {
|
||||
if eat!(self, Tok::Kw(Kw::Long)).is_some() {
|
||||
eat!(self, Tok::Kw(Kw::Int));
|
||||
TypeSpecifier::Integer(IntTy {
|
||||
sign: signedness.unwrap_or_default(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue