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 gen: dot.bnf
gocc $< gocc $<
./paste_copyright.bash go run paste_copyright.go
debug_lexer: dot.bnf debug_lexer: dot.bnf
gocc -debug_lexer -v -a $< gocc -debug_lexer -v -a $<
./paste_copyright.bash go run paste_copyright.go
debug_parser: dot.bnf debug_parser: dot.bnf
gocc -debug_parser -v -a $< gocc -debug_parser -v -a $<
./paste_copyright.bash go run paste_copyright.go
clean: clean:
rm -f errors/errors.go rm -f errors/errors.go

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -79,11 +79,16 @@ func (s *stack) String() string {
w := new(bytes.Buffer) w := new(bytes.Buffer)
fmt.Fprintf(w, "stack:\n") fmt.Fprintf(w, "stack:\n")
for i, st := range s.state { for i, st := range s.state {
fmt.Fprintf(w, "\t%d:%d , ", i, st) fmt.Fprintf(w, "\t%d: %d , ", i, st)
if s.attrib[i] == nil { if s.attrib[i] == nil {
fmt.Fprintf(w, "nil") fmt.Fprintf(w, "nil")
} else { } 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") 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) { func (p *Parser) popNonRecoveryStates() (removedAttribs []parseError.ErrorSymbol) {
if rs, ok := p.firstRecoveryState(); ok { 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)) removedAttribs = make([]parseError.ErrorSymbol, len(errorSymbols))
for i, e := range errorSymbols { for i, e := range errorSymbols {
removedAttribs[i] = e 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)
}
}