Skip to content

Commit

Permalink
Add YAML 1.1 b-char function. (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paalon authored Jun 17, 2024
1 parent 5bb060a commit ad56c62
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/scanner.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# YAML 1.1 [27] b-char ::= b-line-feed | b-carriage-return | b-next-line | b-line-separator | b-paragraph-separator
yaml_1_1_is_b_char(c::Char) = c == '\n' || c == '\r' || c == '\u85' || c == '\u2028' || c == '\u2029'

# YAML 1.1 [41] ns-ascii-letter ::= [#x41-#x5A] /*A-Z*/ | [#61-#x7A] /*a-z*/
# YAML 1.2 [37] ns-ascii-letter ::= [x41-x5A] | [x61-x7A] # A-Z a-z
is_ns_ascii_letter(c::Char) = 'A' c 'Z' || 'a' c 'z'
Expand Down Expand Up @@ -1214,7 +1217,7 @@ function scan_block_scalar_breaks(stream::TokenStream, indent)
forwardchars!(stream)
end

while in(peek(stream.input), "\r\n\u0085\u2028\u2029")
while yaml_1_1_is_b_char(peek(stream.input))
push!(chunks, scan_line_break(stream))
end_mark = get_mark(stream)
while stream.column < indent && peek(stream.input) == ' '
Expand Down Expand Up @@ -1314,7 +1317,7 @@ function scan_flow_scalar_non_spaces(stream::TokenStream, double::Bool,
end
push!(chunks, Char(parse(Int, prefix(stream.input, length), base = 16)))
forwardchars!(stream, length)
elseif in(c, "\r\n\u0085\u2028\u2029")
elseif yaml_1_1_is_b_char(c)
scan_line_break(stream)
append!(chunks, scan_flow_scalar_breaks(stream, double, start_mark))
else
Expand Down Expand Up @@ -1344,7 +1347,7 @@ function scan_flow_scalar_spaces(stream::TokenStream, double::Bool,
if c == '\0'
throw(ScannerError("while scanning a quoted scalar", start_mark,
"found unexpected end of stream", get_mark(stream)))
elseif in(c, "\r\n\u0085\u2028\u2029")
elseif yaml_1_1_is_b_char(c)
line_break = scan_line_break(stream)
breaks = scan_flow_scalar_breaks(stream, double, start_mark)
if line_break != '\n'
Expand Down Expand Up @@ -1377,7 +1380,7 @@ function scan_flow_scalar_breaks(stream::TokenStream, double::Bool,
forward!(stream.input)
end

if in(peek(stream.input), "\r\n\u0085\u2028\u2029")
if yaml_1_1_is_b_char(peek(stream.input))
push!(chunks, scan_line_break(stream))
else
return chunks
Expand Down Expand Up @@ -1461,7 +1464,7 @@ function scan_plain_spaces(stream::TokenStream, indent::Integer,
whitespaces = prefix(stream.input, length)
forwardchars!(stream, length)
c = peek(stream.input)
if in(c, "\r\n\u0085\u2028\u2029")
if yaml_1_1_is_b_char(c)
line_break = scan_line_break(stream)
stream.allow_simple_key = true
if peek(stream.input) == '\uFEFF'
Expand Down

0 comments on commit ad56c62

Please sign in to comment.