Skip to content

Commit 3c1bb8b

Browse files
agnivadegriesemer
authored andcommitted
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 <[email protected]> Run-TryBot: Robert Griesemer <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 25b95b4 commit 3c1bb8b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

godoc/spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (p *ebnfParser) parseTerm() bool {
7474
case scanner.Ident:
7575
p.parseIdentifier(false)
7676

77-
case scanner.String:
77+
case scanner.String, scanner.RawString:
7878
p.next()
7979
const ellipsis = '…' // U+2026, the horizontal ellipsis character
8080
if p.tok == ellipsis {

godoc/spec_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2018 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package godoc
6+
7+
import (
8+
"bytes"
9+
"strings"
10+
"testing"
11+
)
12+
13+
func TestParseEBNFString(t *testing.T) {
14+
var p ebnfParser
15+
var buf bytes.Buffer
16+
src := []byte("octal_byte_value = `\\` octal_digit octal_digit octal_digit .")
17+
p.parse(&buf, src)
18+
19+
if strings.Contains(buf.String(), "error") {
20+
t.Error(buf.String())
21+
}
22+
}

0 commit comments

Comments
 (0)