Skip to content

Commit

Permalink
In BCS, allow fractional part of fixed-point literal to have no digits
Browse files Browse the repository at this point in the history
ACS allows this. For compatibility reasons, allow it in BCS.
  • Loading branch information
positively-charged committed Feb 5, 2017
1 parent 99e5ef8 commit e59bead
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion doc/grammar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ hexadecimal-number:
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]+)*
Expand Down
2 changes: 1 addition & 1 deletion doc/grammar_acs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ hexadecimal-number:
0[xX][0-9a-fA-F]*

fixed-point-number:
[0-9]+[.][0-9]+
[0-9]+[.][0-9]*

radix-number:
[0-9]+[_][0-9a-zA-Z]+
Expand Down
2 changes: 1 addition & 1 deletion doc/grammar_acs95.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ hexadecimal-number:
0[xX][0-9a-fA-F]*

fixed-point-number:
[0-9]+[.][0-9]+
[0-9]+[.][0-9]*

radix-number:
[0-9]+[_][0-9a-zA-Z]+
Expand Down
13 changes: 6 additions & 7 deletions src/parse/token/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -2358,14 +2358,13 @@ void read_token( struct parse* parse, struct token* token ) {
"invalid digit in fractional part of fixed-point literal" );
p_bail( parse );
}
else if ( text->value[ text->length - 1 ] == '.' ) {
struct pos pos = { parse->source->line, column,
parse->source->file_entry_id };
p_diag( parse, DIAG_POS_ERR, &pos,
"no digits found in fractional part of fixed-point literal" );
p_bail( parse );
}
else {
if ( text->value[ text->length - 1 ] == '.' ) {
struct pos pos = { parse->source->line, column,
parse->source->file_entry_id };
p_diag( parse, DIAG_POS | DIAG_WARN, &pos,
"no digits found in fractional part of fixed-point literal" );
}
tk = TK_LIT_FIXED;
goto state_finish;
}
Expand Down

0 comments on commit e59bead

Please sign in to comment.