Skip to content

Commit

Permalink
WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
efritz committed Jun 13, 2023
1 parent 231eb01 commit 7305420
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions bindings/go/scip/symbol.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ func (s *symbolParser) error(message string) error {
}

func (s *symbolParser) current() rune {
return s.Symbol[s.index]
if s.index < len(s.Symbol) {
return s.Symbol[s.index]
}
return '\x00'
}

func (s *symbolParser) peekNext() rune {
Expand All @@ -119,6 +122,7 @@ func (s *symbolParser) parseDescriptors() ([]*Descriptor, error) {
}

func (s *symbolParser) parseDescriptor() (*Descriptor, error) {
start := s.index
switch s.peekNext() {
case '(':
s.index++
Expand Down Expand Up @@ -168,7 +172,12 @@ func (s *symbolParser) parseDescriptor() (*Descriptor, error) {
default:
}
}
return nil, nil

end := s.index
if s.index > len(s.Symbol) {
end = len(s.Symbol)
}
return nil, errors.Newf("unrecognized descriptor %q", string(s.Symbol[start:end]))
}

func (s *symbolParser) acceptIdentifier(what string) (string, error) {
Expand Down

0 comments on commit 7305420

Please sign in to comment.