зеркало из https://github.com/golang/tools.git
godoc: accept scanner.RawString too during EBNF parsing
Commit c8915a0696ddb53399e9c7ebae1cd1158f27175 changed the text/scanner package to return a scanner.RawString (rather than a scanner.String) token for raw string literals. This broke the EBNF parser which didn't look for scanner.RawString. Updated the EBNF parser code to reflect that change. Fixes golang/go#25986 Change-Id: Ib9c133a7c357dd750a4038d2ed39be86a245995c Reviewed-on: https://go-review.googlesource.com/120659 Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Родитель
25b95b4822
Коммит
3c1bb8b785
|
@ -74,7 +74,7 @@ func (p *ebnfParser) parseTerm() bool {
|
|||
case scanner.Ident:
|
||||
p.parseIdentifier(false)
|
||||
|
||||
case scanner.String:
|
||||
case scanner.String, scanner.RawString:
|
||||
p.next()
|
||||
const ellipsis = '…' // U+2026, the horizontal ellipsis character
|
||||
if p.tok == ellipsis {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package godoc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseEBNFString(t *testing.T) {
|
||||
var p ebnfParser
|
||||
var buf bytes.Buffer
|
||||
src := []byte("octal_byte_value = `\\` octal_digit octal_digit octal_digit .")
|
||||
p.parse(&buf, src)
|
||||
|
||||
if strings.Contains(buf.String(), "error") {
|
||||
t.Error(buf.String())
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче