diff --git a/parser.go b/parser.go index 71c949a..3fd23ef 100644 --- a/parser.go +++ b/parser.go @@ -141,7 +141,7 @@ func (p *Parser) Parse(fn string) (*AlrmConfig, error) { case TK_CHECK: if check == nil { if host == nil { - return nil, fmt.Errorf("host token without initialization") + return nil, fmt.Errorf("check token without initialization") } check, err = NewCheck(strings.ToLower(tk), host.GetAddress()) if err != nil { @@ -151,7 +151,14 @@ func (p *Parser) Parse(fn string) (*AlrmConfig, error) { host.Checks = append(host.Checks, check) continue } - check.Parse(tk) + cont, err := check.Parse(tk) + if err != nil { + return nil, err + } + if !cont { + p.prevState() + goto stateswitch + } default: return nil, fmt.Errorf("unknown parser state: %d", p.state()) @@ -214,6 +221,7 @@ func (p *Parser) Split(data []byte, atEOF bool) (int, []byte, error) { for i := 0; i < len(data); i++ { c := data[i] +// fmt.Printf("%c (%t) (%t)\n", c, started, ignoreline) switch c { case '\f', '\n', '\r': p.Line++ @@ -233,7 +241,7 @@ func (p *Parser) Split(data []byte, atEOF bool) (int, []byte, error) { return i + 1, data[startidx:i], nil } - if quote == 0 { + if !ignoreline && quote == 0 { quote = c } diff --git a/sample.config b/sample.config index dfa3bb8..cdc1bf8 100644 --- a/sample.config +++ b/sample.config @@ -1,4 +1,4 @@ -set alert "Don't think about it" +# set alert "Don't think about it" monitor group host www1.example.com address 10.11.135.101