Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions idris2/src/Ephapax/Parse/Stream.idr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Ephapax.Parse.Stream
import Ephapax.Parse.Lexer
import Ephapax.Parse.ZigBuffer

%default partial
%default total

public export
record Stream where
Expand Down Expand Up @@ -45,12 +45,13 @@ atEnd s = s.index >= s.len

public export
remaining : Stream -> List Token
remaining s = build s.index
remaining s = buildFuel (integerToNat (cast (s.len - s.index))) s.index
where
build : Int -> List Token
build i =
buildFuel : Nat -> Int -> List Token
buildFuel Z _ = []
buildFuel (S k) i =
if i >= s.len then []
else MkToken (getTokKind s.buf i) (getTokPos s.buf i) :: build (i + 1)
else MkToken (getTokKind s.buf i) (getTokPos s.buf i) :: buildFuel k (i + 1)

public export
at : Int -> Stream -> Maybe Token
Expand Down
Loading