Skip to content

Commit

Permalink
Fix index logic in detecting descriptor kind
Browse files Browse the repository at this point in the history
  • Loading branch information
varungandhi-src committed Jun 27, 2024
1 parent 3afd2e2 commit 7a119d6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions bindings/go/scip/symbol.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,9 @@ func (z *zeroAllocSymbolParser) Advance(nextRune rune, nextRuneByteLength int32)

func (z *zeroAllocSymbolParser) parseDescriptor(out *RawDescriptorList) error {
start := z.byteIndex
nextRune, nextRuneByteLength := z.peekNext()
switch nextRune {
switch z.currentRune {
case '(':
z.Advance('(', nextRuneByteLength)
z.advanceRune()
z.advanceOneByte('(')
name, err := z.acceptIdentifier(parseCtxParameterName)
if err != nil {
return err
Expand All @@ -524,8 +522,7 @@ func (z *zeroAllocSymbolParser) parseDescriptor(out *RawDescriptorList) error {
return z.acceptOneByte(')', parseCtxClosingParameterName)
//return &Descriptor{Name: name, Suffix: Descriptor_Parameter}, z.acceptCharacter(')', "closing parameter name")
case '[':
z.Advance('[', nextRuneByteLength)
z.advanceRune()
z.advanceOneByte('[')
name, err := z.acceptIdentifier(parseCtxTypeParameterName)
if err != nil {
return err
Expand Down Expand Up @@ -608,12 +605,15 @@ func (s *symbolParser) acceptIdentifier(what string) (string, error) {
func (z *zeroAllocSymbolParser) advanceOneByte(_ byte) {
// TODO: Add build tag with asserts and check that current byte matches the passed in byte.
nextRune, nextRuneByteLength := z.peekNext()
z.Advance(nextRune, nextRuneByteLength)
// z.byteIndex can become equal to len(z.SymbolString) here
z.byteIndex += 1
z.currentRune = nextRune
z.bytesToNextRune = nextRuneByteLength
}

func (z *zeroAllocSymbolParser) advanceRune() {
nextRune, nextRuneByteLength := z.peekNext()
z.Advance(nextRune, nextRuneByteLength)
z.Advance(nextRune, min(nextRuneByteLength, 1))
}

func (z *zeroAllocSymbolParser) acceptOneByte(b byte, what parseCtx) error {
Expand Down

0 comments on commit 7a119d6

Please sign in to comment.