From 31f4d9ed1410b6cc2605b13b6382a9eead5478d8 Mon Sep 17 00:00:00 2001 From: Nathan R Date: Wed, 11 Aug 2021 11:54:17 +0200 Subject: [PATCH] updated grammar + added some types --- ccmeta.leg | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ccmeta.leg b/ccmeta.leg index bf0e219..423da65 100644 --- a/ccmeta.leg +++ b/ccmeta.leg @@ -1405,6 +1405,8 @@ declaration = @{ C_declarationBegin() } declarationSpecifiers = @{ int specified= 0 } { listBegin() } ( s:storageClassSpecifier { listAppend(s) } | s:typeSpecifier @{ specified++ } { listAppend(s) } + # Any list of specifiers and qualifiers at the start of a declaration may contain attribute specifiers + | s:attributeSpecifier &{gnu} { listAppend(s) } | s:typedefName &{ !specified++ } { listAppend(s) } | s:typeQualifier { listAppend(s) } | s:functionSpecifier { listAppend(s) } @@ -1418,7 +1420,7 @@ initDeclaratorList = d:initDeclarator { listWith(d) } )* { $$= listEnd() } initDeclarator = d:declarator - ( a:ASSIGN i:initializer { d= new_C_binary(d, a, i) } + ( a:ASSIGN i:initializer &{ !typedeffing } { d= new_C_binary(d, a, i) } )? { $$= d } # 6.7.1 @@ -1434,11 +1436,10 @@ functionStorageClassSpecifier = EXTERN | STATIC # 6.7.2 -typeSpecifier = VOID | CHAR | SHORT | INT | LONG | FLOAT | DOUBLE | SIGNED | UNSIGNED | BOOL | COMPLEX +typeSpecifier = VOID | CHAR | SHORT | INT | LONG | FLOAT | DOUBLE | SIGNED | UNSIGNED | BOOL | COMPLEX + | ( BUILTIN_VA_LIST | _FLOAT128 ) | structOrUnionSpecifier | enumSpecifier - # Any list of specifiers and qualifiers at the start of a declaration may contain attribute specifiers - | attributeSpecifier &{gnu} # 6.7.2.1 @@ -1510,11 +1511,13 @@ enumerator = i:id # 6.7.3 -typeQualifier = CONST | RESTRICT | VOLATILE +typeQualifier = CONST | RESTRICT | VOLATILE + | __RESTRICT # 6.7.4 functionSpecifier = INLINE + | __INLINE # 6.7.5 @@ -1710,7 +1713,7 @@ externalDeclaration = { yylval = newComment(yytext); } | ( SEMI &{gnu} | declaration | functionDefinition -#| | meta + | meta | &. &{ errmsg= "declaration expected" } error ) { yylval= $$; } @@ -1943,6 +1946,11 @@ IMAG = '__imag__' !IDREST &{gnu} { $$= newToken("__imag__" ) } - LABEL = '__label__' !IDREST &{gnu} { $$= newToken("__label__") } - REAL = '__real__' !IDREST &{gnu} { $$= newToken("__real__" ) } - +BUILTIN_VA_LIST = '__builtin_va_list' !IDREST &{gnu} { $$= newToken("__builtin_va_list" ) } - +__RESTRICT = '__restrict' !IDREST &{gnu} { $$= newToken("__restrict" ) } - +__INLINE = '__inline' !IDREST &{gnu} { $$= newToken("__inline" ) } - +_FLOAT128 = '_Float128' !IDREST &{gnu} { $$= newToken("_Float128" ) } - + %% ;