language-c 0.9.1 → 0.9.2
raw patch · 7 files changed
+34/−14 lines, 7 filesdep ~deepseqnew-uploader
Dependency ranges changed: deepseq
Files
- ChangeLog +4/−0
- language-c.cabal +2/−2
- src/Language/C/Parser/Lexer.x +16/−11
- src/Language/C/Parser/Parser.y +4/−0
- src/Language/C/Parser/Tokens.hs +5/−0
- src/Language/C/Pretty.hs +2/−1
- src/Language/C/Syntax/AST.hs +1/−0
ChangeLog view
@@ -2,6 +2,10 @@ ## WIP +## 0.9.2++- Add support for 128 bit builtin integer types+ ## 0.9.1 - Support parsing an empty list of clobbers after a colon in `asm` statements
language-c.cabal view
@@ -1,5 +1,5 @@ Name: language-c-Version: 0.9.1+Version: 0.9.2 Cabal-Version: >= 1.10 Build-Type: Simple License: BSD3@@ -16,7 +16,7 @@ It features a complete, well tested parser and pretty printer for all of C99 and a large set of C11 and clang/GNU extensions. Category: Language-Tested-With: GHC == 8.0.*, GHC == 8.2.*, GHC == 8.4.*, GHC == 8.6.*, GHC == 8.8.*, GHC == 8.10.*+Tested-With: GHC == 8.4.*, GHC == 8.6.*, GHC == 8.8.*, GHC == 8.10.*, GHC == 9.0.*, GHC == 9.2.* Extra-Source-Files: AUTHORS AUTHORS.c2hs ChangeLog README src/Language/C/Parser/Lexer.x
src/Language/C/Parser/Lexer.x view
@@ -292,7 +292,7 @@ generic _Generic, goto, if, inline @__, int,-int128 __int128,+__int128 __int128_t, long, noreturn _Noreturn, nullable _Nullable __nullable,@@ -303,6 +303,7 @@ struct, switch, typedef, typeof @__, thread __thread _Thread_local+(CTokUInt128) __uint128 __uint128_t, union, unsigned, void,@@ -324,12 +325,21 @@ (CTokGnuC GnuCTyCompat) __builtin_types_compatible_p (flip CTokClangC ClangBuiltinConvertVector) __builtin_convertvector -}--- Tokens: _Alignas _Alignof __alignof alignof __alignof__ __asm asm __asm__ _Atomic auto break _Bool case char __const const __const__ continue _Complex __complex__ default do double else enum extern float for _Generic goto if __inline inline __inline__ int __int128 long _Noreturn _Nullable __nullable _Nonnull __nonnull register __restrict restrict __restrict__ return short __signed signed __signed__ sizeof static _Static_assert struct switch typedef __typeof typeof __typeof__ __thread _Thread_local union unsigned void __volatile volatile __volatile__ while __label__ _Float32 _Float32x _Float64 _Float64x _Float128 __float128 _Float128x __attribute __attribute__ __extension__ __real __real__ __imag __imag__ __builtin_va_arg __builtin_offsetof __builtin_types_compatible_p __builtin_convertvector++-- Tokens: _Alignas _Alignof __alignof alignof __alignof__ __asm asm __asm__ _Atomic auto break _Bool case char __const const __const__ continue _Complex __complex__ default do double else enum extern float for _Generic goto if __inline inline __inline__ int __int128 __int128_t long _Noreturn _Nullable __nullable _Nonnull __nonnull register __restrict restrict __restrict__ return short __signed signed __signed__ sizeof static _Static_assert struct switch typedef __typeof typeof __typeof__ __thread _Thread_local __uint128 __uint128_t union unsigned void __volatile volatile __volatile__ while __label__ _Float32 _Float32x _Float64 _Float64x _Float128 __float128 _Float128x __attribute __attribute__ __extension__ __real __real__ __imag __imag__ __builtin_va_arg __builtin_offsetof __builtin_types_compatible_p __builtin_convertvector idkwtok ('_' : 'A' : 'l' : 'i' : 'g' : 'n' : 'a' : 's' : []) = tok 8 CTokAlignas idkwtok ('_' : 'A' : 'l' : 'i' : 'g' : 'n' : 'o' : 'f' : []) = tok 8 CTokAlignof idkwtok ('_' : 'A' : 't' : 'o' : 'm' : 'i' : 'c' : []) = tok 7 CTokAtomic idkwtok ('_' : 'B' : 'o' : 'o' : 'l' : []) = tok 5 CTokBool idkwtok ('_' : 'C' : 'o' : 'm' : 'p' : 'l' : 'e' : 'x' : []) = tok 8 CTokComplex+#ifdef IEC_60559_TYPES_EXT+idkwtok ('_' : 'F' : 'l' : 'o' : 'a' : 't' : '1' : '2' : '8' : []) = tok 9 (CTokFloatN 128 False)+idkwtok ('_' : 'F' : 'l' : 'o' : 'a' : 't' : '1' : '2' : '8' : 'x' : []) = tok 10 (CTokFloatN 128 True)+idkwtok ('_' : 'F' : 'l' : 'o' : 'a' : 't' : '3' : '2' : []) = tok 8 (CTokFloatN 32 False)+idkwtok ('_' : 'F' : 'l' : 'o' : 'a' : 't' : '3' : '2' : 'x' : []) = tok 9 (CTokFloatN 32 True)+idkwtok ('_' : 'F' : 'l' : 'o' : 'a' : 't' : '6' : '4' : []) = tok 8 (CTokFloatN 64 False)+idkwtok ('_' : 'F' : 'l' : 'o' : 'a' : 't' : '6' : '4' : 'x' : []) = tok 9 (CTokFloatN 64 True)+#endif idkwtok ('_' : 'G' : 'e' : 'n' : 'e' : 'r' : 'i' : 'c' : []) = tok 8 CTokGeneric idkwtok ('_' : 'N' : 'o' : 'n' : 'n' : 'u' : 'l' : 'l' : []) = tok 8 CTokNonnull idkwtok ('_' : 'N' : 'o' : 'r' : 'e' : 't' : 'u' : 'r' : 'n' : []) = tok 9 CTokNoreturn@@ -356,7 +366,6 @@ idkwtok ('_' : '_' : 'c' : 'o' : 'n' : 's' : 't' : []) = tok 7 CTokConst idkwtok ('c' : 'o' : 'n' : 's' : 't' : []) = tok 5 CTokConst idkwtok ('_' : '_' : 'c' : 'o' : 'n' : 's' : 't' : '_' : '_' : []) = tok 9 CTokConst-idkwtok ('_' : '_' : 'c' : 'o' : 'n' : 's' : 't' : 'a' : 'n' : 't' : []) = tok 10 CTokConst idkwtok ('c' : 'o' : 'n' : 't' : 'i' : 'n' : 'u' : 'e' : []) = tok 8 CTokContinue idkwtok ('d' : 'e' : 'f' : 'a' : 'u' : 'l' : 't' : []) = tok 7 CTokDefault idkwtok ('d' : 'o' : []) = tok 2 CTokDo@@ -377,6 +386,7 @@ idkwtok ('_' : '_' : 'i' : 'n' : 'l' : 'i' : 'n' : 'e' : '_' : '_' : []) = tok 10 CTokInline idkwtok ('i' : 'n' : 't' : []) = tok 3 CTokInt idkwtok ('_' : '_' : 'i' : 'n' : 't' : '1' : '2' : '8' : []) = tok 8 CTokInt128+idkwtok ('_' : '_' : 'i' : 'n' : 't' : '1' : '2' : '8' : '_' : 't' : []) = tok 10 CTokInt128 idkwtok ('_' : '_' : 'l' : 'a' : 'b' : 'e' : 'l' : '_' : '_' : []) = tok 9 CTokLabel idkwtok ('l' : 'o' : 'n' : 'g' : []) = tok 4 CTokLong idkwtok ('_' : '_' : 'n' : 'o' : 'n' : 'n' : 'u' : 'l' : 'l' : []) = tok 9 CTokNonnull@@ -401,6 +411,8 @@ idkwtok ('_' : '_' : 't' : 'y' : 'p' : 'e' : 'o' : 'f' : []) = tok 8 CTokTypeof idkwtok ('t' : 'y' : 'p' : 'e' : 'o' : 'f' : []) = tok 6 CTokTypeof idkwtok ('_' : '_' : 't' : 'y' : 'p' : 'e' : 'o' : 'f' : '_' : '_' : []) = tok 10 CTokTypeof+idkwtok ('_' : '_' : 'u' : 'i' : 'n' : 't' : '1' : '2' : '8' : []) = tok 9 (CTokUInt128)+idkwtok ('_' : '_' : 'u' : 'i' : 'n' : 't' : '1' : '2' : '8' : '_' : 't' : []) = tok 11 (CTokUInt128) idkwtok ('u' : 'n' : 'i' : 'o' : 'n' : []) = tok 5 CTokUnion idkwtok ('u' : 'n' : 's' : 'i' : 'g' : 'n' : 'e' : 'd' : []) = tok 8 CTokUnsigned idkwtok ('v' : 'o' : 'i' : 'd' : []) = tok 4 CTokVoid@@ -408,14 +420,7 @@ idkwtok ('v' : 'o' : 'l' : 'a' : 't' : 'i' : 'l' : 'e' : []) = tok 8 CTokVolatile idkwtok ('_' : '_' : 'v' : 'o' : 'l' : 'a' : 't' : 'i' : 'l' : 'e' : '_' : '_' : []) = tok 12 CTokVolatile idkwtok ('w' : 'h' : 'i' : 'l' : 'e' : []) = tok 5 CTokWhile-#ifdef IEC_60559_TYPES_EXT-idkwtok ('_' : 'F' : 'l' : 'o' : 'a' : 't' : '3' : '2' : []) = tok 8 (CTokFloatN 32 False)-idkwtok ('_' : 'F' : 'l' : 'o' : 'a' : 't' : '3' : '2' : 'x' : []) = tok 9 (CTokFloatN 32 True)-idkwtok ('_' : 'F' : 'l' : 'o' : 'a' : 't' : '6' : '4' : []) = tok 8 (CTokFloatN 64 False)-idkwtok ('_' : 'F' : 'l' : 'o' : 'a' : 't' : '6' : '4' : 'x' : []) = tok 9 (CTokFloatN 64 True)-idkwtok ('_' : 'F' : 'l' : 'o' : 'a' : 't' : '1' : '2' : '8' : []) = tok 9 (CTokFloatN 128 False)-idkwtok ('_' : 'F' : 'l' : 'o' : 'a' : 't' : '1' : '2' : '8' : 'x' : []) = tok 10 (CTokFloatN 128 True)-#endif+ -- For OpenCL tokens idkwtok ('_' : '_' : 'k' : 'e' : 'r' : 'n' : 'e' : 'l' : []) = tok 8 CTokClKernel idkwtok ('_' : '_' : 'r' : 'e' : 'a' : 'd' : '_' : 'o' : 'n' : 'l' : 'y' : []) = tok 11 CTokClRdOnly
src/Language/C/Parser/Parser.y view
@@ -215,6 +215,7 @@ inline { CTokInline _ } int { CTokInt _ } "__int128" { CTokInt128 _ }+"__int128_t" { CTokInt128 _ } long { CTokLong _ } "__label__" { CTokLabel _ } "_Noreturn" { CTokNoreturn _ }@@ -234,6 +235,8 @@ typeof { CTokTypeof _ } "__thread" { CTokThread _ } union { CTokUnion _ }+"__uint128" { CTokUInt128 _ }+"__uint128_t" { CTokUInt128 _ } unsigned { CTokUnsigned _ } void { CTokVoid _ } volatile { CTokVolatile _ }@@ -892,6 +895,7 @@ | "_Bool" {% withNodeInfo $1 $ CBoolType } | "_Complex" {% withNodeInfo $1 $ CComplexType } | "__int128" {% withNodeInfo $1 $ CInt128Type }+ | "__uint128" {% withNodeInfo $1 $ CUInt128Type } | "_Float32" {% withNodeInfo $1 $ (CFloatNType 32 False) } | "_Float32x" {% withNodeInfo $1 $ (CFloatNType 32 True) } | "_Float64" {% withNodeInfo $1 $ (CFloatNType 64 False) }
src/Language/C/Parser/Tokens.hs view
@@ -102,6 +102,7 @@ -- `__inline__') | CTokInt !PosLength -- `int' | CTokInt128 !PosLength -- `__int128`+ -- (or `__int128_t`) | CTokLong !PosLength -- `long' | CTokLabel !PosLength -- `__label__ | CTokNoreturn !PosLength -- `_Noreturn'@@ -124,6 +125,8 @@ | CTokTypedef !PosLength -- `typedef' | CTokTypeof !PosLength -- `typeof' | CTokThread !PosLength -- `__thread'+ | CTokUInt128 !PosLength -- `__uint128`+ -- (or `__uint128_t`) | CTokUnion !PosLength -- `union' | CTokUnsigned !PosLength -- `unsigned' | CTokVoid !PosLength -- `void'@@ -257,6 +260,7 @@ posLenOfTok (CTokTypedef pos ) = pos posLenOfTok (CTokTypeof pos ) = pos posLenOfTok (CTokThread pos ) = pos+posLenOfTok (CTokUInt128 pos ) = pos posLenOfTok (CTokUnion pos ) = pos posLenOfTok (CTokUnsigned pos ) = pos posLenOfTok (CTokVoid pos ) = pos@@ -370,6 +374,7 @@ showsPrec _ (CTokTypedef _ ) = showString "typedef" showsPrec _ (CTokTypeof _ ) = showString "typeof" showsPrec _ (CTokThread _ ) = showString "_Thread_local"+ showsPrec _ (CTokUInt128 _ ) = showString "__uint128" showsPrec _ (CTokUnion _ ) = showString "union" showsPrec _ (CTokUnsigned _ ) = showString "unsigned" showsPrec _ (CTokVoid _ ) = showString "void"
src/Language/C/Pretty.hs view
@@ -249,13 +249,14 @@ pretty (CLongType _) = text "long" pretty (CFloatType _) = text "float" pretty (CFloatNType n x _) = text "_Float" <> text (show n) <>- (if x then text "x" else empty) + (if x then text "x" else empty) pretty (CDoubleType _) = text "double" pretty (CSignedType _) = text "signed" pretty (CUnsigType _) = text "unsigned" pretty (CBoolType _) = text "_Bool" pretty (CComplexType _) = text "_Complex" pretty (CInt128Type _) = text "__int128"+ pretty (CUInt128Type _) = text "__uint128" pretty (CSUType union _) = pretty union pretty (CEnumType enum _) = pretty enum pretty (CTypeDef ident _) = identP ident
src/Language/C/Syntax/AST.hs view
@@ -468,6 +468,7 @@ | CBoolType a | CComplexType a | CInt128Type a+ | CUInt128Type a | CFloatNType Int Bool a -- ^ IEC 60227: width (32,64,128), extended flag | CSUType (CStructureUnion a) a -- ^ Struct or Union specifier | CEnumType (CEnumeration a) a -- ^ Enumeration specifier