}
}
+static void parse_floating_suffix(void)
+{
+ switch(c) {
+ /* TODO: do something usefull with the suffixes... */
+ case 'f':
+ case 'F':
+ case 'l':
+ case 'L':
+ next_char();
+ break;
+ default:
+ break;
+ }
+}
+
static void parse_number_hex(void)
{
assert(c == 'x' || c == 'X');
lexer_token.type = T_FLOATINGPOINT;
lexer_token.v.floatvalue = value;
+
+ parse_floating_suffix();
}
static void parse_floatingpoint_fract(int integer_part)
lexer_token.type = T_FLOATINGPOINT;
lexer_token.v.floatvalue = value;
+
+ parse_floating_suffix();
}
static void parse_number_dec(void)
void lexer_open_stream(FILE *stream, const char *input_name)
{
input = stream;
- lexer_token.source_position.linenr = 1;
+ lexer_token.source_position.linenr = 0;
lexer_token.source_position.input_name = input_name;
- next_char();
+ /* place a virtual \n at the beginning so the lexer knows that we're
+ * at the beginning of a line */
+ c = '\n';
}
void exit_lexer(void)
switch(type->atype) {
case ATOMIC_TYPE_INVALID: s = "INVALIDATOMIC"; break;
case ATOMIC_TYPE_VOID: s = "void"; break;
- case ATOMIC_TYPE_BOOL: s = "bool"; break;
+ case ATOMIC_TYPE_BOOL: s = "_Bool"; break;
case ATOMIC_TYPE_CHAR: s = "char"; break;
case ATOMIC_TYPE_SCHAR: s = "signed char"; break;
case ATOMIC_TYPE_UCHAR: s = "unsigned char"; break;
bool is_type_integer(const type_t *type)
{
+ if(type->type == TYPE_ENUM)
+ return 1;
+
if(type->type != TYPE_ATOMIC)
return 0;
atomic_type_t *atomic_type = (atomic_type_t*) type;
switch(atomic_type->atype) {
+ case ATOMIC_TYPE_BOOL:
case ATOMIC_TYPE_CHAR:
case ATOMIC_TYPE_SCHAR:
case ATOMIC_TYPE_UCHAR:
}
}
-bool is_type_arithmetic(const type_t *type)
+bool is_type_floating(const type_t *type)
{
if(type->type != TYPE_ATOMIC)
return 0;
atomic_type_t *atomic_type = (atomic_type_t*) type;
switch(atomic_type->atype) {
- case ATOMIC_TYPE_CHAR:
- case ATOMIC_TYPE_SCHAR:
- case ATOMIC_TYPE_UCHAR:
- case ATOMIC_TYPE_SHORT:
- case ATOMIC_TYPE_USHORT:
- case ATOMIC_TYPE_INT:
- case ATOMIC_TYPE_UINT:
- case ATOMIC_TYPE_LONG:
- case ATOMIC_TYPE_ULONG:
- case ATOMIC_TYPE_LONGLONG:
- case ATOMIC_TYPE_ULONGLONG:
case ATOMIC_TYPE_FLOAT:
case ATOMIC_TYPE_DOUBLE:
case ATOMIC_TYPE_LONG_DOUBLE:
case ATOMIC_TYPE_LONG_DOUBLE_IMAGINARY:
#endif
return 1;
- case ATOMIC_TYPE_INVALID:
- case ATOMIC_TYPE_VOID:
- case ATOMIC_TYPE_BOOL:
+ default:
return 0;
}
+}
+
+bool is_type_arithmetic(const type_t *type)
+{
+ if(is_type_integer(type) || is_type_floating(type))
+ return 1;
return 0;
}
return result;
}
-type_t *make_atomic_type(atomic_type_type_t type, unsigned qualifiers)
+type_t *make_atomic_type(atomic_type_type_t type, type_qualifier_t qualifiers)
{
atomic_type_t *atomic_type
= obstack_alloc(type_obst, sizeof(atomic_type[0]));
return identify_new_type((type_t*) atomic_type);
}
-type_t *make_pointer_type(type_t *points_to, unsigned qualifiers)
+type_t *make_pointer_type(type_t *points_to, type_qualifier_t qualifiers)
{
pointer_type_t *pointer_type
= obstack_alloc(type_obst, sizeof(pointer_type[0]));