Skip to content

Use is_whitespace more#202

Open
Paalon wants to merge 13 commits into
JuliaData:masterfrom
Paalon:scanner-whitespace-more
Open

Use is_whitespace more#202
Paalon wants to merge 13 commits into
JuliaData:masterfrom
Paalon:scanner-whitespace-more

Conversation

@Paalon
Copy link
Copy Markdown
Contributor

@Paalon Paalon commented Jun 17, 2024

This depends on #200. Use yaml_1_1_is_whitespace more.

Paalon added 11 commits June 17, 2024 10:48
Here we use abstract type & subtyping because it's common traits pattern
in Julia.
We do not need to export these objects because we can use strings for
versions in user-facing functions like:

```julia

function load(str::AbstractString; version::YAMLVersion)
    # ...
end

function load(str::AbstractString; version::AbstractString)
    version == "1.1" ? load(str, version=YAMLV1_1()) :
    version == "1.2" ? load(str, version=YAMLV1_2()) :
    throw(ErrorException())
end

load(str, version="1.1")
```
@Paalon Paalon changed the title [Performance, No Breaking] Use yaml_1_1_is_whitespace more. Use is_whitespace more Jun 21, 2024
@Paalon Paalon mentioned this pull request Jun 22, 2024
Comment thread src/scanner.jl
# 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'

is_whitespace(::YAMLV1_1, c::Char) = c == '\0' || c == ' ' || c == '\t' || is_b_char(YAMLV1_1(), c)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Counting \0 as whitespace seems suspicious but maybe that's the best way to make sense of the existing code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't understood this whitespace meaning yet but only mechanically replacing existing code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants