@@ -158,10 +158,8 @@ def size (stack : SyntaxStack) : Nat :=
158
158
def isEmpty (stack : SyntaxStack) : Bool :=
159
159
stack.size == 0
160
160
161
- def take (stack : SyntaxStack) (n : Nat) : SyntaxStack :=
162
- { stack with raw := stack.raw.take (stack.drop + n) }
163
-
164
- @[deprecated take (since := "2024-10-22")] abbrev shrink := @take
161
+ def shrink (stack : SyntaxStack) (n : Nat) : SyntaxStack :=
162
+ { stack with raw := stack.raw.shrink (stack.drop + n) }
165
163
166
164
def push (stack : SyntaxStack) (a : Syntax) : SyntaxStack :=
167
165
{ stack with raw := stack.raw.push a }
@@ -214,7 +212,7 @@ def stackSize (s : ParserState) : Nat :=
214
212
s.stxStack.size
215
213
216
214
def restore (s : ParserState) (iniStackSz : Nat) (iniPos : String.Pos) : ParserState :=
217
- { s with stxStack := s.stxStack.take iniStackSz, errorMsg := none, pos := iniPos }
215
+ { s with stxStack := s.stxStack.shrink iniStackSz, errorMsg := none, pos := iniPos }
218
216
219
217
def setPos (s : ParserState) (pos : String.Pos) : ParserState :=
220
218
{ s with pos := pos }
@@ -228,10 +226,8 @@ def pushSyntax (s : ParserState) (n : Syntax) : ParserState :=
228
226
def popSyntax (s : ParserState) : ParserState :=
229
227
{ s with stxStack := s.stxStack.pop }
230
228
231
- def takeStack (s : ParserState) (iniStackSz : Nat) : ParserState :=
232
- { s with stxStack := s.stxStack.take iniStackSz }
233
-
234
- @[deprecated takeStack (since := "2024-10-22")] abbrev shrinkStack := @takeStack
229
+ def shrinkStack (s : ParserState) (iniStackSz : Nat) : ParserState :=
230
+ { s with stxStack := s.stxStack.shrink iniStackSz }
235
231
236
232
def next (s : ParserState) (input : String) (pos : String.Pos) : ParserState :=
237
233
{ s with pos := input.next pos }
@@ -254,15 +250,15 @@ def mkNode (s : ParserState) (k : SyntaxNodeKind) (iniStackSz : Nat) : ParserSta
254
250
⟨stack, lhsPrec, pos, cache, err, recovered⟩
255
251
else
256
252
let newNode := Syntax.node SourceInfo.none k (stack.extract iniStackSz stack.size)
257
- let stack := stack.take iniStackSz
253
+ let stack := stack.shrink iniStackSz
258
254
let stack := stack.push newNode
259
255
⟨stack, lhsPrec, pos, cache, err, recovered⟩
260
256
261
257
def mkTrailingNode (s : ParserState) (k : SyntaxNodeKind) (iniStackSz : Nat) : ParserState :=
262
258
match s with
263
259
| ⟨stack, lhsPrec, pos, cache, err, errs⟩ =>
264
260
let newNode := Syntax.node SourceInfo.none k (stack.extract (iniStackSz - 1 ) stack.size)
265
- let stack := stack.take (iniStackSz - 1 )
261
+ let stack := stack.shrink (iniStackSz - 1 )
266
262
let stack := stack.push newNode
267
263
⟨stack, lhsPrec, pos, cache, err, errs⟩
268
264
@@ -287,7 +283,7 @@ def mkEOIError (s : ParserState) (expected : List String := []) : ParserState :=
287
283
def mkErrorsAt (s : ParserState) (ex : List String) (pos : String.Pos) (initStackSz? : Option Nat := none) : ParserState := Id.run do
288
284
let mut s := s.setPos pos
289
285
if let some sz := initStackSz? then
290
- s := s.takeStack sz
286
+ s := s.shrinkStack sz
291
287
s := s.setError { expected := ex }
292
288
s.pushSyntax .missing
293
289
0 commit comments