Skip to content

Commit

Permalink
Fix: digit separator not followed by digit in fixed-point literal
Browse files Browse the repository at this point in the history
  • Loading branch information
positively-charged committed Jan 31, 2017
1 parent e1700a0 commit 00fb0cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 6 additions & 6 deletions doc/grammar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -796,22 +796,22 @@ number:
<radix-number>

binary-number:
0[bB][0-1]+([_]+[0-1]+)*
0[bB][0-1]+([_]?[0-1]+)*

octal-number:
0[oO][0-7]+([_]+[0-7]+)*
0[oO][0-7]+([_]?[0-7]+)*

decimal-number:
[0-9]+([_]+[0-9]+)*
[0-9]+([_]?[0-9]+)*

hexadecimal-number:
0[xX][0-9a-fA-F]+([_]+[0-9a-fA-F]+)*
0[xX][0-9a-fA-F]+([_]?[0-9a-fA-F]+)*

fixed-point-number:
[0-9]+([_]+[0-9]+)*[.][0-9]+([_]+[0-9]+)*
[0-9]+([_]?[0-9]+)*[.][0-9]+([_]?[0-9]+)*

radix-number:
[0-9]+([_]+[0-9]+)*[rR][0-9a-zA-Z]+([_]+[0-9a-zA-Z]+)*
[0-9]+([_]?[0-9]+)*[rR][0-9a-zA-Z]+([_]?[0-9a-zA-Z]+)*

string:
"([^\\"]|\\")*"
Expand Down
8 changes: 8 additions & 0 deletions src/parse/token/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -2335,6 +2335,14 @@ void read_token( struct parse* parse, struct token* token ) {
}
else if ( ch == '_' ) {
ch = read_ch( parse );
if ( ! isdigit( ch ) ) {
struct pos pos;
t_init_pos( &pos, parse->source->file_entry_id,
parse->source->line, parse->source->column );
p_diag( parse, DIAG_POS_ERR, &pos,
"missing decimal digit after digit separator" );
p_bail( parse );
}
}
else if ( isalpha( ch ) ) {
struct pos pos = { parse->source->line, parse->source->column,
Expand Down

0 comments on commit 00fb0cc

Please sign in to comment.