Skip to content
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 error with global <expr> (also local) #287

Closed
domluna opened this issue Jun 19, 2021 · 2 comments · Fixed by #291
Closed

Parsing error with global <expr> (also local) #287

domluna opened this issue Jun 19, 2021 · 2 comments · Fixed by #291
Labels

Comments

@domluna
Copy link

domluna commented Jun 19, 2021

julia> ast = Meta.parse(s)
:(global a = (2, b))

julia> s
"global a=2,b"

julia> cst = CSTParser.parse(s)
  1:12  global
  1:3      1:1   OP: =
  1:1     a
  2:2     INTEGER: 2
  4:4    b

julia> ast = Meta.parse(s)
:(global a = (2, b))

The ast is parsed as

global
  binary op
    a
    =
    tuple
      2
      b

Where as the cst is parsed as

global
  binary op
    a
    =
    2
  b

ref domluna/JuliaFormatter.jl#431

@domluna
Copy link
Author

domluna commented Jun 19, 2021

julia> cst = CSTParser.parse("local a = 2, b")
  1:14  local
  1:5      1:2   OP: =
  1:2     a
  3:3     INTEGER: 2
  6:6    b

julia> cst = CSTParser.parse("const a = 2, b")
  1:14  const
  1:8      1:2   OP: =
  1:2     a
  3:6     tuple
  3:3      INTEGER: 2
  4:4      b

julia> cst = CSTParser.parse("outer a = 2, b")
  1:14  errortoken
  1:6    outer
  7:14     1:2   OP: =
  7:8     a
  9:12    tuple
  9:9      INTEGER: 2
 10:10     b

julia> cst = CSTParser.parse("return a = 2, b")
  1:15  return
  1:8      1:2   OP: =
  1:2     a
  3:6     tuple
  3:3      INTEGER: 2
  4:4      b

Looks like local is the other 1 that's broken. Not sure about outer (never seen that used anywhere so ???)

@domluna domluna changed the title Parsing error with global <expr> (maybe also const, local, etc ?) Parsing error with global <expr> (also local) Jun 19, 2021
@pfitzseb pfitzseb added the bug label Jun 19, 2021
@pfitzseb
Copy link
Member

I think outer is only allowed in for loop iteration-expressions. Will take a look at the other cases.

@davidanthoff davidanthoff added this to the Backlog milestone Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants