diff --git a/src/language.yacc b/src/language.yacc index fe6ca29e81b6c8e8c835461cae1b978d42cc2c9f..946ae0ad7784dae3e5b2b9cbf296ab913b35806d 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -98,6 +98,7 @@ %token TOK_OPTIONAL %token TOK_SAFE_INDEX %token TOK_SAFE_START_INDEX +%token TOK_BITS %right '=' @@ -290,6 +291,7 @@ int yylex(YYSTYPE *yylval); %type <n> string %type <n> TOK_STRING %type <n> TOK_NUMBER +%type <n> TOK_BITS %type <n> optional_attributes %type <n> optional_rename_inherit %type <n> optional_identifier @@ -1499,6 +1501,11 @@ opt_int_range: /* Empty */ { push_int_type(MIN_INT_TYPE, MAX_INT_TYPE); } + | '(' TOK_BITS ')' + { + push_int_type( 0, (1<<$2->u.sval.u.integer)-1 ); + free_node( $2 ); + } | '(' number_or_minint expected_dot_dot number_or_maxint ')' { INT_TYPE min = MIN_INT_TYPE; diff --git a/src/lexer.h b/src/lexer.h index 8b36bf67442f36168ef61c80eac7470b9c3aee3f..b52e42387d173624f52d686331666928635aea26 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -885,7 +885,7 @@ unknown_directive: case '0': { int base = 0; - + if(GOBBLE('b') || GOBBLE('B')) { base = 2; @@ -909,7 +909,7 @@ unknown_directive: return TOK_NUMBER; } } - + case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { @@ -985,7 +985,16 @@ unknown_directive: free_svalue(&sval); debug_malloc_touch(yylval->n); lex->pos=p2; - if (lex_isidchar (LOOK())) { + if (lex_isidchar (LOOK())) + { + if( GOBBLE('b') ) + if( GOBBLE( 'i' ) ) + if( GOBBLE( 't' ) ) + { + GOBBLE('s'); + return TOK_BITS; + } + my_yyerror ("Invalid char '%c' in constant.", LOOK()); do SKIP(); while (lex_isidchar (LOOK())); }