Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix nonstdid parsing and $ parsing in import #313

Merged
merged 4 commits into from
Nov 3, 2021
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
10 changes: 7 additions & 3 deletions src/components/internals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,17 @@ function parse_importexport_item(ps, is_colon = false)
pushtotrivia!(a, accept_rparen(ps))
a
elseif kindof(ps.nt) === Tokens.EX_OR
@closer ps :comma parse_expression(ps)
parse_unary(ps, INSTANCE(next(ps)))
elseif !is_colon && isoperator(ps.nt)
next(ps)
EXPR(:OPERATOR, ps.nt.startbyte - ps.t.startbyte, 1 + ps.t.endbyte - ps.t.startbyte, val(ps.t, ps))
elseif VERSION > v"1.3.0-" && isidentifier(ps.nt) && isemptyws(ps.nws) && (kindof(ps.nnt) === Tokens.STRING || kindof(ps.nnt) === Tokens.TRIPLE_STRING)
EXPR(:NONSTDIDENTIFIER, EXPR[INSTANCE(next(ps)), INSTANCE(next(ps))])
#TODO fix nonstdid handling
id = INSTANCE(next(ps))
if valof(id) == "var"
EXPR(:NONSTDIDENTIFIER, EXPR[id, INSTANCE(next(ps))])
else
mErrorToken(ps, EXPR(:NONSTDIDENTIFIER, EXPR[id, INSTANCE(next(ps))]), UnexpectedToken)
end
else
INSTANCE(next(ps))
end
Expand Down
11 changes: 11 additions & 0 deletions test/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1324,4 +1324,15 @@ end
x, ps = CSTParser.parse(CSTParser.ParseState(str), true)
@test ps.errored == false
end

@testset "#310" begin
x, ps = CSTParser.parse(CSTParser.ParseState("""import a.notvar"papa" """), true)
@test ps.errored == true
x, ps = CSTParser.parse(CSTParser.ParseState("""import notvar"papa" """), true)
@test ps.errored == true
end

@testset "#311" begin
@test test_expr(raw"import a.$b.c")
end
end