Skip to content

Commit cbc07f7

Browse files
committed
fix for pre 1.7
1 parent 848f549 commit cbc07f7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/lexer.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,22 @@ function Base.show(io::IO, ps::ParseState)
6464
println(io, "next : ", kindof(ps.nt), " ($(ps.nt))", " ($(wstype(ps.nws)))")
6565
end
6666
peekchar(ps::ParseState) = peekchar(ps.l)
67-
peekchar(io::Base.GenericIOBuffer) = peek(io, Char)
67+
if !applicable(Base.peek, Tuple{IOBuffer, Char})
68+
function _peek(s::IO, ::Type{T}) where T
69+
mark(s)
70+
try read(s, T)::T
71+
finally
72+
reset(s)
73+
end
74+
end
75+
peekchar(io) = _peek(io, Char)
76+
else
77+
peekchar(io) = peek(io, Char)
78+
end
79+
80+
81+
82+
6883
wstype(t::AbstractToken) = kindof(t) == EmptyWS ? "empty" :
6984
kindof(t) == NewLineWS ? "ws w/ newline" :
7085
kindof(t) == SemiColonWS ? "ws w/ semicolon" : "ws"

0 commit comments

Comments
 (0)