@@ -100,7 +100,7 @@ function lexnext(state::LexerState, bytes::DenseVector{UInt8}, start::UInt32)
100100 Token (settag (K " >item" , tag (state. ctx)), start - 0x1 , start - 0x1 ), start
101101 elseif K " clock" ∈ state. ctx
102102 Token (K " >clock" , start - 0x1 , start - 0x1 ), start
103- elseif chr == UInt8 (' *' ) && pos == linestart && ischarat (bytes, pos + countsame (bytes, pos, ' *' ), ' ' )
103+ elseif chr == UInt8 (' *' ) && pos == linestart && ischarat (bytes, skipchars (bytes, pos, ' *' ), ' ' )
104104 lex_heading (state, bytes, pos)
105105 elseif chr == UInt8 (' :' )
106106 if length (bytes) > pos && iswhitespace (bytes, pos + 0x1 ) || islineend (bytes, pos + 0x1 )
186186# Greater element lexing
187187
188188function lex_heading (:: LexerState , bytes:: DenseVector{UInt8} , pos:: UInt32 )
189- depth = countsame (bytes, pos, ' *' )
189+ depth = skipchars (bytes, pos, ' *' ) - pos
190190 Token (settag (K " heading" , depth % UInt8), pos, lineend (bytes, pos) - 1 ),
191191 pos + depth
192192end
@@ -237,8 +237,8 @@ function lex_item(state::LexerState, bytes::DenseVector{UInt8}, linestart::UInt3
237237 nextchar (bytes, pos, (' ' , ' \n ' , ' \r ' )) < bulletend
238238 return zero (pos)
239239 end
240- bulletend == skipcharsets (bytes, pos, ' 0' :' 9' ) ||
241- bulletend == skipcharsets (bytes, pos, ' a' :' z' , ' A' :' Z' ) ||
240+ bulletend == skipchars (bytes, pos, ' 0' :' 9' ) ||
241+ bulletend == skipchars (bytes, pos, ' a' :' z' , ' A' :' Z' ) ||
242242 return zero (pos)
243243 bulletend
244244 end
@@ -365,7 +365,7 @@ function lex_clock(::LexerState, bytes::DenseVector{UInt8}, start::UInt32)
365365 end
366366 hasduration = if hasprefix (bytes, pos, " =>" )
367367 pos = skipspaces (bytes, pos + ncodeunits (" =>" ) % UInt32). stop
368- pos = skipcharsets (bytes, pos, ' 0' :' 9' , ' :' )
368+ pos = skipchars (bytes, pos, ' 0' :' 9' , ' :' )
369369 pos = skipspaces (bytes, pos). stop
370370 true
371371 else
@@ -464,7 +464,7 @@ function lex_fixedwidth(::LexerState, bytes::DenseVector{UInt8}, start::UInt32)
464464end
465465
466466function lex_hrule (:: LexerState , bytes:: DenseVector{UInt8} , pos:: UInt32 )
467- rend = skipcharsets (bytes, pos, ' -' )
467+ rend = skipchars (bytes, pos, ' -' )
468468 rend - pos >= 5 || return NONE_TOKEN
469469 lend = lineend (bytes, pos)
470470 rend == lend ||
476476function lex_latexenv (:: LexerState , bytes:: DenseVector{UInt8} , start:: UInt32 )
477477 hasprefix (bytes, start, " \\ begin{" ) || return NONE_TOKEN
478478 namestart = start + ncodeunits (" \\ begin{" ) % UInt32
479- nameend = skipcharsets (bytes, namestart, (' a' :' z' , ' A' :' Z' , ' 0' :' 9' , ' *' ))
479+ nameend = skipchars (bytes, namestart, (' a' :' z' , ' A' :' Z' , ' 0' :' 9' , ' *' ))
480480 nameend < length (bytes) && bytes[nameend] == UInt8 (' }' ) || return NONE_TOKEN
481481 namelen = nameend - namestart
482482 pos = start
@@ -768,7 +768,7 @@ function skipwords(bytes::DenseVector{UInt8}, pos::I, extras::NTuple{N, C} = ();
768768end
769769
770770"""
771- skipcharsets (bytes::DenseVector{UInt8}, pos::Integer, charsets...) -> Integer
771+ skipchars (bytes::DenseVector{UInt8}, pos::Integer, charsets...) -> Integer
772772
773773Skip over all characters in `bytes` starting at `pos` that are in the given
774774character sets.
@@ -780,26 +780,26 @@ Each character set can be a single character or a range of characters.
780780```julia-repl
781781julia> strv = codeunits("abc0123 .--");
782782
783- julia> skipcharsets (strv, 1, 'a':'z')
783+ julia> skipchars (strv, 1, 'a':'z')
7847844
785785
786- julia> skipcharsets (strv, 1, 'a':'z', '0':'9')
786+ julia> skipchars (strv, 1, 'a':'z', '0':'9')
7877878
788788
789- julia> skipcharsets (strv, 1, 'a':'z', '0':'9', ' ')
789+ julia> skipchars (strv, 1, 'a':'z', '0':'9', ' ')
7907909
791791
792- julia> skipcharsets (strv, 1, 'a':'z', '0':'9', ' ', '-')
792+ julia> skipchars (strv, 1, 'a':'z', '0':'9', ' ', '-')
7937939
794794
795- julia> skipcharsets (strv, 1, 'a':'z', '0':'9', ' ', '.')
795+ julia> skipchars (strv, 1, 'a':'z', '0':'9', ' ', '.')
79679610
797797
798- julia> skipcharsets (strv, 1, 'a':'z', '0':'9', ' ', '.', '-')
798+ julia> skipchars (strv, 1, 'a':'z', '0':'9', ' ', '.', '-')
79979912
800800```
801801"""
802- function skipcharsets (bytes:: DenseVector{UInt8} , pos:: Integer , charsets:: NTuple{N, Union{StepRange{Char}, Char}} ; limit:: Integer = length (bytes) % typeof (pos)) where {N}
802+ function skipchars (bytes:: DenseVector{UInt8} , pos:: Integer , charsets:: NTuple{N, Union{StepRange{Char}, Char}} ; limit:: Integer = length (bytes) % typeof (pos)) where {N}
803803 skipranges = map (c -> if c isa Char UInt8 (c) else
804804 UInt8 (first (c)): UInt8 (last (c)) end ,
805805 charsets)
@@ -812,8 +812,8 @@ function skipcharsets(bytes::DenseVector{UInt8}, pos::Integer, charsets::NTuple{
812812 next
813813end
814814
815- skipcharsets (bytes:: DenseVector{UInt8} , pos:: Integer , charsets:: Union{StepRange{Char}, Char} ...; limit:: Integer = length (bytes) % typeof (pos)) =
816- skipcharsets (bytes, pos, Tuple (charsets); limit)
815+ skipchars (bytes:: DenseVector{UInt8} , pos:: Integer , charsets:: Union{StepRange{Char}, Char} ...; limit:: Integer = length (bytes) % typeof (pos)) =
816+ skipchars (bytes, pos, Tuple (charsets); limit)
817817
818818"""
819819 skipbalanced(bytes::DenseVector{UInt8}, pos::Integer, bpair::Pair{Char, Char},
@@ -903,14 +903,6 @@ function hasprefix(bytes::DenseVector{UInt8}, start::Integer, pattern::String; l
903903 true
904904end
905905
906- function countsame (bytes:: DenseVector{UInt8} , pos:: I , char:: Char ; limit:: I = length (bytes) % I):: I where {I <: Integer }
907- uchar = UInt8 (char)
908- for p in pos: limit
909- bytes[p] != uchar && return p - pos
910- end
911- limit + 0x1
912- end
913-
914906function nextchar (bytes:: DenseVector{UInt8} , pos:: I , char:: UInt8 ; limit:: I = length (bytes) % I):: I where {I <: Integer }
915907 for p in pos: limit
916908 bytes[p] == char && return p
0 commit comments