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: vet:
@go vet @go vet
precommit: fmt build check-full precommit: fmt vet build check-full
clean: clean:
@rm -f *.test @rm -f *.test

15
boot.go
View File

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

View File

@ -95,25 +95,6 @@ func (c *context) fail(offset int) {
c.matchLast = false 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) { func findLine(tokens []rune, offset int) (line, column int) {
tokens = tokens[:offset] tokens = tokens[:offset]
for i := range tokens { for i := range tokens {

View File

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

View File

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