From 3c7271f05710111bb2fc4e393773ab8026ddba26 Mon Sep 17 00:00:00 2001
From: Robert Griesemer ""
or back quotes ``
.
-The form a ... b
represents the set of characters from
-a
through b
as alternatives.
+The form a … b
represents the set of characters from
+a
through b
as alternatives. The horizontal
+ellipis … is also used elsewhere in the spec to informally denote various
+enumerations or code snippets that are not further specified. The character …
+(as opposed to the three characters ...
) is not a token of the Go
+language.
_
(U+005F) is considered a letter.
letter = unicode_letter | "_" . -decimal_digit = "0" ... "9" . -octal_digit = "0" ... "7" . -hex_digit = "0" ... "9" | "A" ... "F" | "a" ... "f" . +decimal_digit = "0" … "9" . +octal_digit = "0" … "7" . +hex_digit = "0" … "9" | "A" … "F" | "a" … "f" .
0
for octal, 0x
int_lit = decimal_lit | octal_lit | hex_lit .
-decimal_lit = ( "1" ... "9" ) { decimal_digit } .
+decimal_lit = ( "1" … "9" ) { decimal_digit } .
octal_lit = "0" { octal_digit } .
hex_lit = "0" ( "x" | "X" ) hex_digit { hex_digit } .
@@ -1053,9 +1057,9 @@ have the method set
-func (p T) Read(b Buffer) bool { return ... }
-func (p T) Write(b Buffer) bool { return ... }
-func (p T) Close() { ... }
+func (p T) Read(b Buffer) bool { return … }
+func (p T) Write(b Buffer) bool { return … }
+func (p T) Close() { … }
@@ -1093,8 +1097,8 @@ If S1
and S2
also implement
-func (p T) Lock() { ... }
-func (p T) Unlock() { ... }
+func (p T) Lock() { … }
+func (p T) Unlock() { … }
@@ -2099,7 +2103,7 @@ element index plus one. A slice literal has the form
-[]T{x1, x2, ... xn}
+[]T{x1, x2, … xn}
@@ -2107,7 +2111,7 @@ and is a shortcut for a slice operation applied to an array literal:
-[n]T{x1, x2, ... xn}[0 : n]
+[n]T{x1, x2, … xn}[0 : n]
@@ -2133,8 +2137,8 @@ parentheses.
-if x == (T{a,b,c}[i]) { ... }
-if (x == T{a,b,c}[i]) { ... }
+if x == (T{a,b,c}[i]) { … }
+if (x == T{a,b,c}[i]) { … }
@@ -2567,11 +2571,11 @@ Given an expression f
of function type
-f(a1, a2, ... an)
+f(a1, a2, … an)
-calls f
with arguments a1, a2, ... an
.
+calls f
with arguments a1, a2, … an
.
Except for one special case, arguments must be single-valued expressions
assignable to the parameter types of
F
and are evaluated before the function is called.
@@ -2650,7 +2654,7 @@ arguments bound to the final parameter and may differ for each call site.
Given the function and call
-func Greeting(prefix string, who ... string)
+func Greeting(prefix string, who ...string)
Greeting("hello:", "Joe", "Anna", "Eileen")
@@ -4891,7 +4895,7 @@ package main
import "fmt"
-// Send the sequence 2, 3, 4, ... to channel 'ch'.
+// Send the sequence 2, 3, 4, … to channel 'ch'.
func generate(ch chan<- int) {
for i := 2; ; i++ {
ch <- i // Send 'i' to channel 'ch'.
@@ -5042,7 +5046,7 @@ arguments and returns no value.
-func main() { ... }
+func main() { … }
diff --git a/src/cmd/godoc/spec.go b/src/cmd/godoc/spec.go
index f8b95e387f6..d863ca0d844 100644
--- a/src/cmd/godoc/spec.go
+++ b/src/cmd/godoc/spec.go
@@ -99,7 +99,8 @@ func (p *ebnfParser) parseTerm() bool {
case token.STRING:
p.next()
- if p.tok == token.ELLIPSIS {
+ const ellipsis = "…" // U+2026, the horizontal ellipsis character
+ if p.tok == token.ILLEGAL && p.lit == ellipsis {
p.next()
p.expect(token.STRING)
}
@@ -157,7 +158,7 @@ func (p *ebnfParser) parse(fset *token.FileSet, out io.Writer, src []byte) {
p.out = out
p.src = src
p.file = fset.AddFile("", fset.Base(), len(src))
- p.scanner.Init(p.file, src, p, 0)
+ p.scanner.Init(p.file, src, p, scanner.AllowIllegalChars)
p.next() // initializes pos, tok, lit
// process source
diff --git a/src/pkg/ebnf/ebnf_test.go b/src/pkg/ebnf/ebnf_test.go
index e77cf64adfa..2055f872ac2 100644
--- a/src/pkg/ebnf/ebnf_test.go
+++ b/src/pkg/ebnf/ebnf_test.go
@@ -22,7 +22,7 @@ var grammars = []string{
`Program = "a" | "b" "c" .`,
- `Program = "a" ... "z" .`,
+ `Program = "a" … "z" .`,
`Program = Song .
Song = { Note } .
diff --git a/src/pkg/ebnf/parser.go b/src/pkg/ebnf/parser.go
index 818168e111d..166412f990e 100644
--- a/src/pkg/ebnf/parser.go
+++ b/src/pkg/ebnf/parser.go
@@ -95,7 +95,8 @@ func (p *parser) parseTerm() (x Expression) {
case token.STRING:
tok := p.parseToken()
x = tok
- if p.tok == token.ELLIPSIS {
+ const ellipsis = "…" // U+2026, the horizontal ellipsis character
+ if p.tok == token.ILLEGAL && p.lit == ellipsis {
p.next()
x = &Range{tok, p.parseToken()}
}
@@ -177,7 +178,7 @@ func (p *parser) parse(fset *token.FileSet, filename string, src []byte) Grammar
// initialize parser
p.fset = fset
p.ErrorVector.Reset()
- p.scanner.Init(fset.AddFile(filename, fset.Base(), len(src)), src, p, 0)
+ p.scanner.Init(fset.AddFile(filename, fset.Base(), len(src)), src, p, scanner.AllowIllegalChars)
p.next() // initializes pos, tok, lit
grammar := make(Grammar)