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

Syntactic unary operator should not look across newline #11496

Closed
yuyichao opened this issue May 30, 2015 · 0 comments · Fixed by #11497
Closed

Syntactic unary operator should not look across newline #11496

yuyichao opened this issue May 30, 2015 · 0 comments · Fixed by #11497
Labels
breaking This change will break code needs decision A decision on this change is needed parser Language parsing and surface syntax

Comments

@yuyichao
Copy link
Contributor

As brought up in #11338 (comment) .

IMHO, if a expression/statement is complete at the end of line, it should not look across the new line to continue.

julia> function parseall(str)
           pos = start(str)
           exs = []
           while !done(str, pos)
               ex, pos = parse(str, pos)
               push!(exs, ex)
           end
           if length(exs) == 0
               throw(ParseError("end of input"))
           elseif length(exs) == 1
               return exs[1]
           else
               return Expr(:block, exs...)
           end
       end
parseall (generic function with 1 method)                                         

julia> parseall("&")
:&                                                                                

julia> parseall("&\na")
:(&a)                                                                             

julia> parseall("&\n")
:($(Expr(:incomplete, "incomplete: premature end of input")))                    

(parseall taken from #11495)

@JeffBezanson JeffBezanson added needs decision A decision on this change is needed breaking This change will break code parser Language parsing and surface syntax labels May 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break code needs decision A decision on this change is needed parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants