Skip to content

Commit

Permalink
fix: parsing large repetition number out of Go capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
pandatix committed Oct 14, 2023
1 parent 4dfac75 commit e41ea54
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions grammar.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,22 +644,33 @@ func lexABNF(input []byte, path *Path) (any, error) {
if spi == nil {
// If not found, should be exact repetition match
dstr := string(input[repeat.Start:repeat.End])
d, _ := strconv.Atoi(dstr)
d, err := strconv.Atoi(dstr)
if err != nil {
return nil, err
}
min, max = d, d
} else {
// Set min
dstr := string(input[repeat.Start:*spi])
if dstr == "" {
min = 0
} else {
min, _ = strconv.Atoi(dstr)
d, err := strconv.Atoi(dstr)
if err != nil {
return nil, err
}
min = d
}
// Set max
dstr = string(input[*spi+1 : repeat.End])
if dstr == "" {
max = inf
} else {
max, _ = strconv.Atoi(dstr)
d, err := strconv.Atoi(dstr)
if err != nil {
return nil, err
}
max = d
}
}
}
Expand Down

0 comments on commit e41ea54

Please sign in to comment.