aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-09-03 19:21:32 +0900
committernsfisis <nsfisis@gmail.com>2025-09-03 19:21:32 +0900
commit5541c597cb68f76d1fc53e01b931eb870856843c (patch)
treef7510dff0dd6ab8e9b67f85b3c8b067cfa4a3a9a /src
parentcab2491d14c6452f4382ce111a25166ed6e997c9 (diff)
downloadducc-5541c597cb68f76d1fc53e01b931eb870856843c.tar.gz
ducc-5541c597cb68f76d1fc53e01b931eb870856843c.tar.zst
ducc-5541c597cb68f76d1fc53e01b931eb870856843c.zip
feat: partially support floating point number types (parsing only)
Diffstat (limited to 'src')
-rw-r--r--src/ast.c6
-rw-r--r--src/ast.h3
-rw-r--r--src/parse.c6
3 files changed, 15 insertions, 0 deletions
diff --git a/src/ast.c b/src/ast.c
index 0d19d40..78fb2b9 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -29,6 +29,12 @@ const char* type_kind_stringify(TypeKind k) {
return "long long";
else if (k == TypeKind_ullong)
return "unsigned long long";
+ else if (k == TypeKind_float)
+ return "float";
+ else if (k == TypeKind_double)
+ return "double";
+ else if (k == TypeKind_ldouble)
+ return "long double";
else if (k == TypeKind_struct)
return "struct";
else if (k == TypeKind_union)
diff --git a/src/ast.h b/src/ast.h
index 05c20e2..00b0171 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -29,6 +29,9 @@ typedef enum {
TypeKind_ulong,
TypeKind_llong,
TypeKind_ullong,
+ TypeKind_float,
+ TypeKind_double,
+ TypeKind_ldouble,
TypeKind_struct,
TypeKind_union,
TypeKind_enum,
diff --git a/src/parse.c b/src/parse.c
index ecd8e65..9c5eaff 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -1605,6 +1605,12 @@ static Type* distinguish_type_from_type_specifiers(int type_specifiers) {
type_specifiers == (TypeSpecifierMask_unsigned + TypeSpecifierMask_long + TypeSpecifierMask_long +
TypeSpecifierMask_int)) {
return type_new(TypeKind_ullong);
+ } else if (type_specifiers == TypeSpecifierMask_float) {
+ return type_new(TypeKind_float);
+ } else if (type_specifiers == TypeSpecifierMask_double) {
+ return type_new(TypeKind_double);
+ } else if (type_specifiers == TypeSpecifierMask_long + TypeSpecifierMask_double) {
+ return type_new(TypeKind_ldouble);
} else if (type_specifiers == TypeSpecifierMask_struct) {
return NULL;
} else if (type_specifiers == TypeSpecifierMask_union) {