Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax: drop legacy (0644) octal literals #205

Merged
merged 1 commit into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions doc/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ has string, integer, and floating-point literals.
0 # int
123 # decimal int
0x7f # hexadecimal int
0755 # octal int
0o755 # octal int
0b1011 # binary int

0.0 0. .0 # float
Expand All @@ -307,8 +307,7 @@ Integer and floating-point literal tokens are defined by the following grammar:
```grammar {.good}
int = decimal_lit | octal_lit | hex_lit | binary_lit .
decimal_lit = ('1' … '9') {decimal_digit} .
octal_lit = '0' {octal_digit} .
| '0' ('o'|'O') octal_digit {octal_digit} .
octal_lit = '0' ('o'|'O') octal_digit {octal_digit} .
hex_lit = '0' ('x'|'X') hex_digit {hex_digit} .
binary_lit = '0' ('b'|'B') binary_digit {binary_digit} .

Expand Down
9 changes: 2 additions & 7 deletions syntax/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -951,13 +951,8 @@ func (sc *scanner) scanNumber(val *tokenValue, c rune) Token {
} else if c == 'e' || c == 'E' {
exponent = true
} else if octal && !allzeros {
// We must support old octal until the Java
// implementation groks the new one.
// TODO(adonovan): reenable the check.
if false {
sc.endToken(val)
sc.errorf(sc.pos, "obsolete form of octal literal; use 0o%s", val.raw[1:])
}
sc.endToken(val)
sc.errorf(sc.pos, "obsolete form of octal literal; use 0o%s", val.raw[1:])
}
}
} else {
Expand Down
4 changes: 1 addition & 3 deletions syntax/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ pass`, "pass newline pass EOF"}, // consecutive newlines are consolidated
{"0o12934e1", `10 9.340000e+03 EOF`},
{"0o123.", `83 . EOF`},
{"0o123.1", `83 1.000000e-01 EOF`},
// TODO(adonovan): reenable later.
// {"0123", `obsolete form of octal literal; use 0o123`},
{"0123", `83 EOF`},
{"0123", `foo.star:1:5: obsolete form of octal literal; use 0o123`},
{"012834", `foo.star:1:1: invalid int literal`},
{"012934", `foo.star:1:1: invalid int literal`},
{"i = 012934", `foo.star:1:5: invalid int literal`},
Expand Down