remove unused code

This commit is contained in:
Arpad Ryszka 2017-12-30 16:43:55 +01:00
parent b74e70080a
commit c96050347f
5 changed files with 47 additions and 63 deletions

View File

@ -47,7 +47,7 @@ check-fmt: $(SOURCES)
vet:
@go vet
precommit: fmt build check-full
precommit: fmt vet build check-full
clean:
@rm -f *.test

15
boot.go
View File

@ -13,12 +13,15 @@ func stringToCommitType(s string) CommitType {
switch s {
case "alias":
return Alias
case "ws":
return Whitespace
case "nows":
return NoWhitespace
case "failpass":
return FailPass
// not used during boot:
// case "ws":
// return Whitespace
// case "nows":
// return NoWhitespace
// case "failpass":
// return FailPass
case "root":
return Root
default:

View File

@ -95,25 +95,6 @@ func (c *context) fail(offset int) {
c.matchLast = false
}
// TODO:
// - need to know which choice branch the failure happened on because if there is a non-user branch that has the
// longest failure, it can be reported to an unrelevant user defined choice on another branch
func (c *context) recordFailure(offset int, p parser) {
if offset < c.failOffset {
return
}
if c.failingParser != nil && offset == c.failOffset {
return
}
c.failOffset = offset
if p.commitType()&userDefined != 0 && p.commitType()&Whitespace == 0 {
c.failingParser = p
}
}
func findLine(tokens []rune, offset int) (line, column int) {
tokens = tokens[:offset]
for i := range tokens {

View File

@ -267,40 +267,40 @@ func TestErrorMessage(t *testing.T) {
func TestErrorVerbose(t *testing.T) {
t.Skip()
const expected = `<input>:5:2:parse failed, parsing: string
"c":3,
}<<<
Parsing error on line: 5, column: 2, while parsing: string. Definition:
string:nows = "\"" ([^\\"\b\f\n\r\t] | "\\" (["\\/bfnrt] | "u" [0-9a-f]{4}))* "\"";
`
const doc = `{
"a":1,
"b":2,
"c":3,
}`
s, err := openSyntaxFile("examples/json.treerack")
if err != nil {
t.Error(err)
return
}
_, err = s.Parse(bytes.NewBufferString(doc))
perr, ok := err.(*ParseError)
if !ok {
t.Error("failed to return parse error")
return
}
if perr.Verbose() != expected {
t.Error("failed to get the right error message")
t.Log("got: ", perr.Verbose())
t.Log("expected:", expected)
}
// const expected = `<input>:5:2:parse failed, parsing: string
//
// "c":3,
// }<<<
//
// Parsing error on line: 5, column: 2, while parsing: string. Definition:
//
// string:nows = "\"" ([^\\"\b\f\n\r\t] | "\\" (["\\/bfnrt] | "u" [0-9a-f]{4}))* "\"";
// `
//
// const doc = `{
// "a":1,
// "b":2,
// "c":3,
// }`
//
// s, err := openSyntaxFile("examples/json.treerack")
// if err != nil {
// t.Error(err)
// return
// }
//
// _, err = s.Parse(bytes.NewBufferString(doc))
// perr, ok := err.(*ParseError)
// if !ok {
// t.Error("failed to return parse error")
// return
// }
//
// if perr.Verbose() != expected {
// t.Error("failed to get the right error message")
// t.Log("got: ", perr.Verbose())
// t.Log("expected:", expected)
// }
}
func TestLongestFail(t *testing.T) {

View File

@ -169,9 +169,9 @@ func (pe *ParseError) Error() string {
)
}
func (pe *ParseError) Verbose() string {
return ""
}
// func (pe *ParseError) Verbose() string {
// return ""
// }
func (s *Syntax) applyRoot(d definition) error {
explicitRoot := d.commitType()&Root != 0