mirror of
https://github.com/daeuniverse/dae.git
synced 2025-03-10 04:47:25 +07:00
fix: panic when there is any lexer error
This commit is contained in:
parent
83a303d786
commit
49afec8079
@ -98,7 +98,7 @@ func readConfig() (params *config.Params, err error) {
|
||||
}
|
||||
sections, err := config_parser.Parse(string(b))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("\n%w", err)
|
||||
}
|
||||
if params, err = config.New(sections); err != nil {
|
||||
return nil, err
|
||||
|
@ -18,6 +18,8 @@ type Walker struct {
|
||||
parser antlr.Parser
|
||||
|
||||
Sections []*Section
|
||||
|
||||
hasLexerError bool
|
||||
}
|
||||
|
||||
func NewWalker(parser antlr.Parser) *Walker {
|
||||
@ -249,7 +251,14 @@ func (w *Walker) parseExpression(exp dae_config.IExpressionContext) *Section {
|
||||
}
|
||||
}
|
||||
|
||||
func (w *Walker) VisitErrorNode(node antlr.ErrorNode) {
|
||||
w.hasLexerError = true
|
||||
}
|
||||
|
||||
func (w *Walker) EnterProgramStructureBlcok(ctx *dae_config.ProgramStructureBlcokContext) {
|
||||
if w.hasLexerError {
|
||||
return
|
||||
}
|
||||
section := w.parseExpression(ctx.Expression())
|
||||
if section == nil {
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user