diff --git a/client.go b/client.go index 81d2acc..eece486 100644 --- a/client.go +++ b/client.go @@ -29,6 +29,8 @@ func client() { nav := newNav(ui.wins[0].h) app := &App{ui, nav} + app.ui.loadFile(app.nav) + if _, err := os.Stat(gConfigPath); err == nil { log.Printf("reading configuration file: %s", gConfigPath) @@ -37,21 +39,19 @@ func client() { msg := fmt.Sprintf("opening configuration file: %s", err) app.ui.message = msg log.Printf(msg) - } else { - app.ui.loadFile(app.nav) } defer rcFile.Close() p := newParser(rcFile) for p.parse() { + if p.err != nil { + app.ui.message = "see the log file for errors in the configuration file" + log.Print(p.err) + } p.expr.eval(app, nil) } - - // TODO: parser error check } - app.ui.loadFile(app.nav) - app.ui.draw(app.nav) app.handleInp() diff --git a/parse.go b/parse.go index 979a8bf..2c2b227 100644 --- a/parse.go +++ b/parse.go @@ -110,21 +110,21 @@ func (p *Parser) parseExpr() Expr { var result Expr - // TODO: syntax error check - switch s.typ { case TokenEOF: return nil - case TokenSemicolon: - s.scan() case TokenIdent: switch s.tok { case "set": + var val string + s.scan() + if s.typ != TokenIdent { + p.err = fmt.Errorf("expected identifier: %s", s.tok) + } opt := s.tok s.scan() - var val string if s.typ != TokenSemicolon { val = s.tok s.scan() @@ -195,19 +195,17 @@ func (p *Parser) parseExpr() Expr { result = &ListExpr{exprs} case TokenPrefix: + var expr string + pref := s.tok s.scan() - - var expr string if s.typ == TokenLBraces { s.scan() expr = s.tok s.scan() - } else if s.typ == TokenCommand { - expr = s.tok } else { - // TODO: handle error + expr = s.tok } s.scan() @@ -215,7 +213,7 @@ func (p *Parser) parseExpr() Expr { result = &ExecExpr{pref, expr} default: - // TODO: handle error + p.err = fmt.Errorf("unexpected token: %s", s.tok) } return result