Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ package and is also licensed under the MIT "Expat" License:
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
>

1 change: 0 additions & 1 deletion docs/src/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -848,4 +848,3 @@ indentation from the syntax tree? Source formatting involves a big pile of
heuristics to get something which "looks nice"... and ML systems have become
very good at heuristics. Also, we've got huge piles of training data — just
choose some high quality, tastefully hand-formatted libraries.

1 change: 0 additions & 1 deletion docs/src/howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ To reduce startup latency you can combine with a custom system as described in
the [Julia VScode docs](https://www.julia-vscode.org/docs/dev/userguide/compilesysimage/#Creating-a-sysimage-for-the-active-environment),
combined with the precompile execution file in `sysimage/precompile_exec.jl` in the source tree.
For additional detail see the discussion in [issue #128](https://github.com/JuliaLang/JuliaSyntax.jl/issues/128).

1 change: 0 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,3 @@ Julia `Expr` can also be produced:
julia> JuliaSyntax.parsestmt(Expr, "(x + y)*z")
:((x + y) * z)
```

3 changes: 1 addition & 2 deletions docs/src/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class of tokenization errors and lets the parser deal with them.
* We use flags rather than child nodes to represent the difference between `struct` and `mutable struct`, `module` and `baremodule` (#220)
* Iterations are represented with the `iteration` and `in` heads rather than `=` within the header of a `for`. Thus `for i=is ; body end` parses to `(for (iteration (in i is)) (block body))`. Cartesian iteration as in `for a=as, b=bs body end` are represented with a nested `(iteration (in a as) (in b bs))` rather than a `block` containing `=` because these lists of iterators are neither semantically nor syntactically a sequence of statements, unlike other uses of `block`. Generators also use the `iteration` head - see information on that below.
* Short form functions like `f(x) = x + 1` are represented with the `function` head rather than the `=` head. In this case the `SHORT_FORM_FUNCTION_FLAG` flag is set to allow the surface syntactic form to be easily distinguished from long form functions.
* All kinds of updating assignment operators like `+=` are represented with a single `K"op="` head, with the operator itself in infix position. For example, `x += 1` is `(op= x + 1)`, where the plus token is of kind `K"Identifer"`. This greatly reduces the number of distinct forms here from a rather big list (`$=` `%=` `&=` `*=` `+=` `-=` `//=` `/=` `<<=` `>>=` `>>>=` `\=` `^=` `|=` `÷=` `⊻=`) and makes the operator itself appear in the AST as kind `K"Identifier"`, as it should. It also makes it possible to add further unicode updating operators while keeping the AST stable.
* All kinds of updating assignment operators like `+=` are represented with a single `K"op="` head, with the operator itself in infix position. For example, `x += 1` is `(op= x + 1)`, where the plus token is of kind `K"Identifier"`. This greatly reduces the number of distinct forms here from a rather big list (`$=` `%=` `&=` `*=` `+=` `-=` `//=` `/=` `<<=` `>>=` `>>>=` `\=` `^=` `|=` `÷=` `⊻=`) and makes the operator itself appear in the AST as kind `K"Identifier"`, as it should. It also makes it possible to add further unicode updating operators while keeping the AST stable.

## More detail on tree differences

Expand Down Expand Up @@ -324,4 +324,3 @@ Expr(:ncat)
│ └─ :d
└─ :x
```

2 changes: 1 addition & 1 deletion src/core/parse_stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ mutable struct ParseStream
lexer = Tokenize.Lexer(io)
# To avoid keeping track of the exact Julia development version where new
# features were added or comparing prerelease strings, we treat prereleases
# or dev versons as the release version using only major and minor version
# or dev versions as the release version using only major and minor version
# numbers. This means we're inexact for old dev versions but that seems
# like an acceptable tradeoff.
ver = (version.major, version.minor)
Expand Down
1 change: 0 additions & 1 deletion src/julia/literal_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,3 @@ function lower_identifier_name(name::Symbol, k::Kind)
Symbol(lower_identifier_name(string(name), k))
end
end

2 changes: 1 addition & 1 deletion src/julia/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ function parse_decl_with_initial_ex(ps::ParseState, mark)
# (x) -> y
# (x; a=1) -> y
elseif kb == K"where"
# `where` and `->` have the "wrong" precedence when writing anon functons.
# `where` and `->` have the "wrong" precedence when writing anon functions.
# So ignore this case to allow use of grouping brackets with `where`.
# This needs to worked around in lowering :-(
# (x where T) -> y ==> (-> (x where T) y)
Expand Down
1 change: 0 additions & 1 deletion sysimage/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ PackageCompiler.create_sysimage(

Use it with `julia -J "$image_path"`
"""

26 changes: 13 additions & 13 deletions test/diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ end
end

@testset "parser errors" begin
@test diagnostic("+ #==# (a,b)") ==
@test diagnostic("+ #==# (a,b)") ==
Diagnostic(2, 7, :error, "whitespace not allowed between prefix function call and argument list")
@test diagnostic("1 -+ (a=1, b=2)") ==
Diagnostic(5, 5, :error, "whitespace not allowed between prefix function call and argument list")
Expand All @@ -44,18 +44,18 @@ end
@test diagnostic("function (\$f) body end") ==
Diagnostic(10, 13, :error, "Ambiguous signature. Add a trailing comma if this is a 1-argument anonymous function; remove parentheses if this is a macro call acting as function signature.")

@test diagnostic("[email protected]", only_first=true) ==
@test diagnostic("[email protected]", only_first=true) ==
Diagnostic(3, 4, :error, "`@` must appear on first or last macro name component")
@test diagnostic("@M.(x)") ==
@test diagnostic("@M.(x)") ==
Diagnostic(1, 3, :error, "dot call syntax not supported for macros")

@test diagnostic("try x end") ==
@test diagnostic("try x end") ==
Diagnostic(1, 9, :error, "try without catch or finally")
# TODO: better range
@test diagnostic("@A.\$x a") ==
@test diagnostic("@A.\$x a") ==
Diagnostic(4, 5, :error, "invalid macro name")

@test diagnostic("a, , b") ==
@test diagnostic("a, , b") ==
Diagnostic(4, 4, :error, "unexpected `,`")
@test diagnostic(")", allow_multiple=true) == [
Diagnostic(1, 1, :error, "unexpected `)`")
Expand Down Expand Up @@ -118,15 +118,15 @@ end
end

@testset "parser warnings" begin
@test diagnostic("@(A)", only_first=true) ==
@test diagnostic("@(A)", only_first=true) ==
Diagnostic(2, 4, :warning, "parenthesizing macro names is unnecessary")
@test diagnostic("try finally catch a ; b end") ==
@test diagnostic("try finally catch a ; b end") ==
Diagnostic(13, 23, :warning, "`catch` after `finally` will execute out of order")
@test diagnostic("import . .A") ==
@test diagnostic("import . .A") ==
Diagnostic(9, 10, :warning, "space between dots in import path")
@test diagnostic("import A .==") ==
@test diagnostic("import A .==") ==
Diagnostic(9, 9, :warning, "space between dots in import path")
@test diagnostic("import A.:+") ==
@test diagnostic("import A.:+") ==
Diagnostic(10, 10, :warning, "quoting with `:` is not required here")
# No warnings for imports of `:` and parenthesized `(..)`
@test diagnostic("import A.:, :", allow_multiple=true) == []
Expand Down Expand Up @@ -244,8 +244,8 @@ end
tempdirname = mktempdir()
cd(tempdirname) do
rm(tempdirname)
# Test _file_url doesn't fail with nonexistant directories
@test isnothing(JuliaSyntax._file_url(joinpath("__nonexistant__", "test.jl")))
# Test _file_url doesn't fail with nonexistent directories
@test isnothing(JuliaSyntax._file_url(joinpath("__nonexistent__", "test.jl")))
end
end
end
1 change: 0 additions & 1 deletion test/fuzz_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1022,4 +1022,3 @@ end
#
# fuzz_test(try_hook_failure, product_token_fuzz(cutdown_tokens, 2))
# fuzz_test(try_parseall_failure, product_token_fuzz(cutdown_tokens, 2))

4 changes: 2 additions & 2 deletions test/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ tests = [
# `where` combined with `->` still parses strangely. However:
# * It's extra hard to add a tuple around the `x` in this syntax corner case.
# * The user already needs to add additional, ugly, parens to get this
# to parse correctly because the precendence of `where` is
# to parse correctly because the precedence of `where` is
# inconsistent with `::` and `->` in this case.
"(x where T)->c" => "(-> (parens (where x T)) c)"
"((x::T) where T)->c" => "(-> (parens (where (parens (::-i x T)) T)) c)"
Expand Down Expand Up @@ -963,7 +963,7 @@ tests = [
"[a \n b]" => "(vcat a b)"
# Can't mix multiple ;'s and spaces
((v=v"1.7",), "[a ;; b c]") => "(ncat-2 a (row b (error-t) c))"
# Empty nd arrays
# Empty N-dimensional arrays
((v=v"1.8",), "[;]") => "(ncat-1)"
((v=v"1.8",), "[;;]") => "(ncat-2)"
((v=v"1.8",), "[\n ;; \n ]") => "(ncat-2)"
Expand Down
1 change: 0 additions & 1 deletion test/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -482,4 +482,3 @@ function Meta_parseall(text::AbstractString; filename="none", lineno=1)
ex,_ = _Meta_parse_string(text, String(filename), lineno, 1, :all)
return ex
end

1 change: 0 additions & 1 deletion test/test_utils_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@
Expr(:block, LineNumberNode(1), 1)),
Expr(:block, LineNumberNode(1))))
end

1 change: 0 additions & 1 deletion tools/bump_in_Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,3 @@ if !isinteractive()
exit(bump_in_Base(ARGS[1], juliasyntax_dir, ARGS[2]))
end
end

Loading