preserve init error
This commit is contained in:
parent
a8bec182b1
commit
ab17c3b195
6
Makefile
6
Makefile
@ -118,12 +118,10 @@ cpu: cpu.out
|
||||
go tool pprof -top cpu.out
|
||||
|
||||
fmt: $(SOURCES)
|
||||
@echo fmt
|
||||
@gofmt -w -s $(SOURCES)
|
||||
gofmt -w -s $(SOURCES)
|
||||
|
||||
checkfmt: $(SOURCES)
|
||||
@echo check fmt
|
||||
@if [ "$$(gofmt -s -d $(SOURCES))" != "" ]; then false; else true; fi
|
||||
if [ "$$(gofmt -s -d $(SOURCES))" != "" ]; then false; else true; fi
|
||||
|
||||
vet:
|
||||
go vet ./...
|
||||
|
@ -2,12 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"code.squareroundforest.org/arpio/treerack"
|
||||
"flag"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"code.squareroundforest.org/arpio/treerack"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
)
|
||||
|
||||
type fileOptions struct {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"code.squareroundforest.org/arpio/treerack"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type showOptions struct {
|
||||
|
23
syntax.go
23
syntax.go
@ -1,10 +1,10 @@
|
||||
package treerack
|
||||
|
||||
import (
|
||||
"code.squareroundforest.org/arpio/treerack/self"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"code.squareroundforest.org/arpio/treerack/self"
|
||||
)
|
||||
|
||||
// if min=0&&max=0, it means min=1,max=1
|
||||
@ -16,12 +16,12 @@ type SequenceItem struct {
|
||||
}
|
||||
|
||||
type Syntax struct {
|
||||
registry *registry
|
||||
initialized bool
|
||||
initFailed bool
|
||||
explicitRoot bool
|
||||
keywords []definition
|
||||
root definition
|
||||
registry *registry
|
||||
initialized bool
|
||||
errInitFailed error
|
||||
explicitRoot bool
|
||||
keywords []definition
|
||||
root definition
|
||||
}
|
||||
|
||||
type GeneratorOptions struct {
|
||||
@ -52,7 +52,6 @@ type definition interface {
|
||||
|
||||
var (
|
||||
ErrSyntaxInitialized = errors.New("syntax initialized")
|
||||
ErrInitFailed = errors.New("init failed")
|
||||
ErrNoParsersDefined = errors.New("no parsers defined")
|
||||
ErrInvalidEscapeCharacter = errors.New("invalid escape character")
|
||||
ErrMultipleRoots = errors.New("multiple roots")
|
||||
@ -296,8 +295,8 @@ func (s *Syntax) ReadSyntax(r io.Reader) error {
|
||||
}
|
||||
|
||||
func (s *Syntax) Init() error {
|
||||
if s.initFailed {
|
||||
return ErrInitFailed
|
||||
if s.errInitFailed != nil {
|
||||
return s.errInitFailed
|
||||
}
|
||||
|
||||
if s.initialized {
|
||||
@ -324,13 +323,13 @@ func (s *Syntax) Init() error {
|
||||
|
||||
for i := range s.keywords {
|
||||
if err := s.keywords[i].validate(s.registry); err != nil {
|
||||
s.initFailed = true
|
||||
s.errInitFailed = err
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.root.validate(s.registry); err != nil {
|
||||
s.initFailed = true
|
||||
s.errInitFailed = err
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user