graph/formats/dot: allow unicode inside html

This commit is contained in:
Egon Elbre
2018-06-03 12:16:45 +03:00
committed by Dan Kortschak
parent 57680b76df
commit 51a14e5e72
11 changed files with 945 additions and 827 deletions

View File

@@ -1,14 +1,14 @@
gen: dot.bnf
gocc $<
./paste_copyright.bash
go run paste_copyright.go
debug_lexer: dot.bnf
gocc -debug_lexer -v -a $<
./paste_copyright.bash
go run paste_copyright.go
debug_parser: dot.bnf
gocc -debug_parser -v -a $<
./paste_copyright.bash
go run paste_copyright.go
clean:
rm -f errors/errors.go

View File

@@ -131,6 +131,7 @@ _html_char
| '\x3D'
// skip right angle bracket (0x3E)
| '\x3F' - '\xFF'
| _unicode_byte
;
_html_chars : { _html_char } ;

View File

@@ -55,7 +55,7 @@ func (e *Error) Error() string {
w := new(bytes.Buffer)
fmt.Fprintf(w, "Error in S%d: %s, %s", e.StackTop, token.TokMap.TokenString(e.ErrorToken), e.ErrorToken.Pos.String())
if e.Err != nil {
fmt.Fprintf(w, e.Err.Error())
fmt.Fprintf(w, ": %+v", e.Err)
} else {
fmt.Fprintf(w, ", expected one of: ")
for _, expected := range e.ExpectedTokens {

View File

@@ -207,7 +207,7 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S44
Accept: 19,
Accept: 0,
Ignore: "",
},
ActionRow{ // S45
@@ -283,7 +283,7 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S63
Accept: 0,
Accept: 19,
Ignore: "",
},
ActionRow{ // S64
@@ -299,19 +299,19 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S67
Accept: 19,
Ignore: "",
},
ActionRow{ // S68
Accept: 0,
Ignore: "",
},
ActionRow{ // S69
ActionRow{ // S68
Accept: 19,
Ignore: "",
},
ActionRow{ // S69
Accept: 0,
Ignore: "",
},
ActionRow{ // S70
Accept: 19,
Accept: 0,
Ignore: "",
},
ActionRow{ // S71
@@ -387,19 +387,19 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S89
Accept: -1,
Ignore: "!comment",
Accept: 19,
Ignore: "",
},
ActionRow{ // S90
Accept: 0,
Accept: 19,
Ignore: "",
},
ActionRow{ // S91
Accept: 19,
Ignore: "",
Accept: -1,
Ignore: "!comment",
},
ActionRow{ // S92
Accept: 19,
Accept: 0,
Ignore: "",
},
ActionRow{ // S93
@@ -407,7 +407,7 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S94
Accept: 12,
Accept: 19,
Ignore: "",
},
ActionRow{ // S95
@@ -415,11 +415,11 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S96
Accept: 19,
Accept: 12,
Ignore: "",
},
ActionRow{ // S97
Accept: 11,
Accept: 19,
Ignore: "",
},
ActionRow{ // S98
@@ -427,7 +427,7 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S99
Accept: 19,
Accept: 11,
Ignore: "",
},
ActionRow{ // S100
@@ -479,7 +479,7 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S112
Accept: 6,
Accept: 19,
Ignore: "",
},
ActionRow{ // S113
@@ -487,7 +487,7 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S114
Accept: 19,
Accept: 6,
Ignore: "",
},
ActionRow{ // S115
@@ -535,7 +535,7 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S126
Accept: 5,
Accept: 19,
Ignore: "",
},
ActionRow{ // S127
@@ -543,7 +543,7 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S128
Accept: 19,
Accept: 5,
Ignore: "",
},
ActionRow{ // S129
@@ -567,7 +567,7 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S134
Accept: 7,
Accept: 19,
Ignore: "",
},
ActionRow{ // S135
@@ -575,7 +575,7 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S136
Accept: 19,
Accept: 7,
Ignore: "",
},
ActionRow{ // S137
@@ -591,6 +591,14 @@ var ActTab = ActionTable{
Ignore: "",
},
ActionRow{ // S140
Accept: 19,
Ignore: "",
},
ActionRow{ // S141
Accept: 19,
Ignore: "",
},
ActionRow{ // S142
Accept: 17,
Ignore: "",
},

View File

@@ -21,7 +21,7 @@ import (
const (
NoState = -1
NumStates = 141
NumStates = 143
NumSymbols = 184
)

View File

@@ -20,6 +20,7 @@ graph {
-20
3.14
F [label=<<div>foo</div>>]
H [label=<<div>→</div>>]
_foo
a10
}

View File

@@ -18,6 +18,7 @@ graph {
-20
3.14
F [label=<<div>foo</div>>]
H [label=<<div>→</div>>]
_foo
a10
}

File diff suppressed because it is too large Load Diff

View File

@@ -83,7 +83,12 @@ func (s *stack) String() string {
if s.attrib[i] == nil {
fmt.Fprintf(w, "nil")
} else {
fmt.Fprintf(w, "%v", s.attrib[i])
switch attr := s.attrib[i].(type) {
case *token.Token:
fmt.Fprintf(w, "%s", attr.Lit)
default:
fmt.Fprintf(w, "%v", attr)
}
}
fmt.Fprintf(w, "\n")
}
@@ -147,7 +152,7 @@ func (p *Parser) Error(err error, scanner Scanner) (recovered bool, errorAttrib
func (p *Parser) popNonRecoveryStates() (removedAttribs []parseError.ErrorSymbol) {
if rs, ok := p.firstRecoveryState(); ok {
errorSymbols := p.stack.popN(int(p.stack.topIndex() - rs))
errorSymbols := p.stack.popN(p.stack.topIndex() - rs)
removedAttribs = make([]parseError.ErrorSymbol, len(errorSymbols))
for i, e := range errorSymbols {
removedAttribs[i] = e

View File

@@ -1,17 +0,0 @@
#!/usr/bin/env bash
find . -type f -name '*.go' \
| xargs sed -i -e "s|// Code generated by gocc; DO NOT EDIT.|\
// Code generated by gocc; DO NOT EDIT.\n\
\n\
// This file is dual licensed under CC0 and The gonum license.\n\
//\n\
// Copyright ©2017 The Gonum Authors. All rights reserved.\n\
// Use of this source code is governed by a BSD-style\n\
// license that can be found in the LICENSE file.\n\
//\n\
// Copyright ©2017 Robin Eklind.\n\
// This file is made available under a Creative Commons CC0 1.0\n\
// Universal Public Domain Dedication.\
|"

View File

@@ -0,0 +1,47 @@
// +build ignore
package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
)
var location = []byte(`// Code generated by gocc; DO NOT EDIT.`)
var copyright = []byte(`// Code generated by gocc; DO NOT EDIT.
// This file is dual licensed under CC0 and The gonum license.
//
// Copyright ©2017 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Copyright ©2017 Robin Eklind.
// This file is made available under a Creative Commons CC0 1.0
// Universal Public Domain Dedication.`)
func main() {
err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() || filepath.Dir(path) == "." || filepath.Ext(path) != ".go" {
return nil
}
content, err := ioutil.ReadFile(path)
if err != nil {
return err
}
content = bytes.Replace(content, location, copyright, 1)
return ioutil.WriteFile(path, content, info.Mode())
})
if err != nil {
fmt.Printf("error walking the path: %v\n", err)
}
}