-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing of generators allows skipping a comma #407
Comments
Ok. Yes yuck! JuliaSyntax shares the old flisp bug too julia> parsestmt(SyntaxNode, "f(x for x = xs a)")
SyntaxNode:
[call]
f :: Identifier
[generator]
x :: Identifier
[iteration]
[in]
x :: Identifier
xs :: Identifier
a :: Identifier' |
We also have these bugs in the flisp parser: julia> JuliaSyntax.fl_parse("(a, x for x in xs c)")
:((a, (x for x = xs), c))
julia> dump(JuliaSyntax.fl_parse("(a, x for x in xs c)"))
Expr
head: Symbol tuple
args: Array{Any}((3,))
1: Symbol a
2: Expr
head: Symbol generator
args: Array{Any}((2,))
1: Symbol x
2: Expr
head: Symbol =
args: Array{Any}((2,))
1: Symbol x
2: Symbol xs
3: Symbol c
julia> JuliaSyntax.fl_parse("(a; x for x in xs c)")
:((a,; (x for x = xs), c))
julia> dump(JuliaSyntax.fl_parse("(a; x for x in xs c)"))
Expr
head: Symbol tuple
args: Array{Any}((2,))
1: Expr
head: Symbol parameters
args: Array{Any}((2,))
1: Expr
head: Symbol generator
args: Array{Any}((2,))
1: Symbol x
2: Expr
head: Symbol =
args: Array{Any}((2,))
1: Symbol x
2: Symbol xs
2: Symbol c
2: Symbol a |
The flisp parser also allows the following form and Base uses it :-( julia> JuliaSyntax.fl_parse("f(y for x = xs; a)")
:(f((y for x = xs); a)) But the following is disallowed julia> JuliaSyntax.fl_parse("(y for x = xs; a)")
ERROR: ParseError("expected \")\"")
Stacktrace:
[1] #fl_parse#129
@ ~/.julia/dev/JuliaSyntax/src/hooks.jl:366 [inlined]
[2] fl_parse
@ ~/.julia/dev/JuliaSyntax/src/hooks.jl:362 [inlined]
[3] fl_parse(str::String; raise::Bool, depwarn::Bool)
@ JuliaSyntax ~/.julia/dev/JuliaSyntax/src/hooks.jl:351
[4] fl_parse(str::String)
@ JuliaSyntax ~/.julia/dev/JuliaSyntax/src/hooks.jl:350
[5] top-level scope
@ REPL[44]:1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JuliaSyntax allows skipping a separator after a generator. In Julia 1.10 you have:
Even more strangely, depending on the separator that comes after the expression may be parsed as a block or as a tuple:
This error isn't present in the flisp parser.The error is present in the flisp parser, but only in certain contexts. In Julia 1.9, we have:The text was updated successfully, but these errors were encountered: