Skip to content

Commit

Permalink
use default error listener or diagnostics when AZM_DIAGNOSTICS=1
Browse files Browse the repository at this point in the history
  • Loading branch information
gertd committed Mar 7, 2024
1 parent 37fb637 commit 559d8de
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion parser/parse.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package parser

import (
"os"

"github.com/antlr4-go/antlr/v4"
"github.com/aserto-dev/azm/model"
)
Expand All @@ -25,6 +27,9 @@ func newParser(input string) *AzmParser {
lexer := NewAzmLexer(antlr.NewInputStream(input))
stream := antlr.NewCommonTokenStream(lexer, 0)
p := NewAzmParser(stream)
p.AddErrorListener(antlr.NewDiagnosticErrorListener(true))
p.AddErrorListener(&antlr.DefaultErrorListener{})
if os.Getenv("AZM_DEBUG") == "1" {
p.AddErrorListener(antlr.NewDiagnosticErrorListener(true))
}
return p
}

0 comments on commit 559d8de

Please sign in to comment.