diff --git a/bindings/go/scip/symbol.go b/bindings/go/scip/symbol.go index e10eec01..8a0ca020 100644 --- a/bindings/go/scip/symbol.go +++ b/bindings/go/scip/symbol.go @@ -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 @@ -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 @@ -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 {