Skip to content

Commit

Permalink
add __int128, __float128 to lexer and typeSpecifier (also added Tint6…
Browse files Browse the repository at this point in the history
…4), unclear if all this is needed

#8
  • Loading branch information
vogler committed Nov 6, 2019
1 parent 53946cd commit 225f65d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/frontc/cabs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ type typeSpecifier = (* Merge all specifiers into one type *)
| Tshort
| Tint
| Tlong
| Tint64
| Tint64 (* TODO needed? *)
| Tint128 (* TODO needed? *)
| Tfloat
| Tfloat128 (* TODO needed? *)
| Tdouble
| Tsigned
| Tsizet (* used temporarily to translate offsetof() *)
Expand Down
4 changes: 3 additions & 1 deletion src/frontc/clexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ let init_lexicon _ =
("char", fun loc -> CHAR loc);
("int", fun loc -> INT loc);
("float", fun loc -> FLOAT loc);
("__float128", fun loc -> FLOAT128 loc);
("double", fun loc -> DOUBLE loc);
("void", fun loc -> VOID loc);
("enum", fun loc -> ENUM loc);
Expand Down Expand Up @@ -193,8 +194,9 @@ let init_lexicon _ =
("restrict", fun loc -> RESTRICT loc);
(* ("__extension__", EXTENSION); *)
(**** MS VC ***)
("__int64", fun _ -> INT64 (currentLoc ()));
("__int32", fun loc -> INT loc);
("__int64", fun _ -> INT64 (currentLoc ()));
("__int128", fun _ -> INT128 (currentLoc ()));
("_cdecl", fun _ -> MSATTR ("_cdecl", currentLoc ()));
("__cdecl", fun _ -> MSATTR ("__cdecl", currentLoc ()));
("_stdcall", fun _ -> MSATTR ("_stdcall", currentLoc ()));
Expand Down
8 changes: 7 additions & 1 deletion src/frontc/cparser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,10 @@ let transformOffsetOf (speclist, dtype) member =

%token EOF
%token<Cabs.cabsloc> CHAR INT BOOL DOUBLE FLOAT VOID INT64 INT32
%token<Cabs.cabsloc> INT128 FLOAT128 COMPLEX /* C99 */
%token<Cabs.cabsloc> ENUM STRUCT TYPEDEF UNION
%token<Cabs.cabsloc> SIGNED UNSIGNED LONG SHORT
%token<Cabs.cabsloc> VOLATILE EXTERN STATIC CONST RESTRICT AUTO REGISTER COMPLEX HIDDEN
%token<Cabs.cabsloc> VOLATILE EXTERN STATIC CONST RESTRICT AUTO REGISTER HIDDEN
%token<Cabs.cabsloc> THREAD

%token<Cabs.cabsloc> SIZEOF ALIGNOF
Expand Down Expand Up @@ -977,8 +978,13 @@ type_spec: /* ISO 6.7.2 */
| INT { Tint, $1 }
| LONG { Tlong, $1 }
| INT64 { Tint64, $1 }
| INT128 { Tint128, $1 }
| FLOAT { Tfloat, $1 }
| FLOAT128 { Tfloat128, $1 }
| DOUBLE { Tdouble, $1 }
/* | COMPLEX FLOAT { Tfloat, $2 } */
/* | COMPLEX FLOAT128{ Tfloat128, $2 } */
/* | COMPLEX DOUBLE { Tdouble, $2 } */
| SIGNED { Tsigned, $1 }
| UNSIGNED { Tunsigned, $1 }
| STRUCT id_or_typename
Expand Down
2 changes: 2 additions & 0 deletions src/frontc/cprint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ and print_type_spec = function
| Tint -> print "int "
| Tlong -> print "long "
| Tint64 -> print "__int64 "
| Tint128 -> print "__int128 "
| Tfloat -> print "float "
| Tfloat128 -> print "__float128"
| Tdouble -> print "double "
| Tsigned -> printu "signed"
| Tunsigned -> print "unsigned "
Expand Down

0 comments on commit 225f65d

Please # to comment.