Skip to content

Commit

Permalink
Change digit separator to single quotation mark
Browse files Browse the repository at this point in the history
  • Loading branch information
positively-charged committed Jan 31, 2017
1 parent 00fb0cc commit 18187bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 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
16 changes: 8 additions & 8 deletions src/parse/token/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,7 @@ void read_token( struct parse* parse, struct token* token ) {
}
// Underscores can be used to improve readability of a numeric literal
// by grouping digits, and are ignored.
else if ( ch == '_' ) {
else if ( ch == '\'' ) {
ch = read_ch( parse );
if ( ! ( ch == '0' || ch == '1' ) ) {
struct pos pos;
Expand Down Expand Up @@ -2184,7 +2184,7 @@ void read_token( struct parse* parse, struct token* token ) {
append_ch( text, ch );
ch = read_ch( parse );
}
else if ( ch == '_' ) {
else if ( ch == '\'' ) {
ch = read_ch( parse );
if ( ! isxdigit( ch ) ) {
struct pos pos;
Expand Down Expand Up @@ -2223,7 +2223,7 @@ void read_token( struct parse* parse, struct token* token ) {
append_ch( text, ch );
ch = read_ch( parse );
}
else if ( ch == '_' ) {
else if ( ch == '\'' ) {
ch = read_ch( parse );
if ( ! ( ch >= '0' && ch <= '7' ) ) {
struct pos pos;
Expand Down Expand Up @@ -2256,10 +2256,10 @@ void read_token( struct parse* parse, struct token* token ) {

zero:
// -----------------------------------------------------------------------
while ( ch == '0' || ( ch == '_' && peek_ch( parse ) == '0' ) ) {
while ( ch == '0' || ( ch == '\'' && peek_ch( parse ) == '0' ) ) {
ch = read_ch( parse );
}
if ( isdigit( ch ) || ch == '_' ) {
if ( isdigit( ch ) || ch == '\'' ) {
goto decimal_literal;
}
else if ( ch == '.' ) {
Expand Down Expand Up @@ -2291,7 +2291,7 @@ void read_token( struct parse* parse, struct token* token ) {
append_ch( text, ch );
ch = read_ch( parse );
}
else if ( ch == '_' ) {
else if ( ch == '\'' ) {
ch = read_ch( parse );
if ( ! isdigit( ch ) ) {
struct pos pos;
Expand Down Expand Up @@ -2333,7 +2333,7 @@ void read_token( struct parse* parse, struct token* token ) {
append_ch( text, ch );
ch = read_ch( parse );
}
else if ( ch == '_' ) {
else if ( ch == '\'' ) {
ch = read_ch( parse );
if ( ! isdigit( ch ) ) {
struct pos pos;
Expand Down Expand Up @@ -2371,7 +2371,7 @@ void read_token( struct parse* parse, struct token* token ) {
append_ch( &parse->temp_text, tolower( ch ) );
ch = read_ch( parse );
}
else if ( ch == '_' ) {
else if ( ch == '\'' ) {
ch = read_ch( parse );
if ( ! isalnum( ch ) ) {
struct pos pos;
Expand Down

0 comments on commit 18187bd

Please sign in to comment.