Skip to content

Commit

Permalink
remove stack
Browse files Browse the repository at this point in the history
  • Loading branch information
goropikari committed Aug 14, 2022
1 parent e340211 commit 5b78b65
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions golex.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,16 @@ func (lex *RegexLexer) readBody() string {
lex.skipWhitespace()
s := []byte{'{'}
lex.next()
stack := []struct{}{{}}
nlparen := 1
for {
if lex.peek() == '}' {
if len(stack) == 1 {
if nlparen == 1 {
break
}
stack = stack[0 : len(stack)-1]
nlparen--
}
if lex.peek() == '{' {
stack = append(stack, struct{}{})
nlparen++
}
s = append(s, lex.peek())
lex.next()
Expand Down

0 comments on commit 5b78b65

Please sign in to comment.