It reads the longest condition expression on the line that it can and then stops. In the both cases that's x < x. The y has to be part of a new expression. In the second case the second expression is y and it's followed by another y, which is illegal.
> On Jul 19, 2014, at 3:51 PM, Matthew Frank <[email protected]> wrote: > > Can you at least give a concise statement of the intuition behind the > decisions the parser makes? It's not the longest match as Matt Bauman > implied. It doesn't seem to be the shortest match (like Perl regular > expressions). Something like Go's "if the newline comes after a token that > could end a statement, insert a semicolon?" > > I can't figure out a coherent rule that would explain why > x=1; y=2 > if x < x y > y > x+y > else > x-y > end > > returns -1 > > But > > if x < x y y > gives "ERROR: syntax: extra tokey "y" after end of expression." > > Sorry, I can't be the volunteer to write a grammar for a language with an > ad-hoc parser. If you decide to switch to using a parser generator I'll be > glad to help out. Please don't end up like Ruby. > > Thanks, > -Matt > >> On Saturday, July 19, 2014 3:49:54 PM UTC-5, Stefan Karpinski wrote: > >> Newline definitely is significant in some places. In certain contexts spaces >> are too. There's no context free grammar for Julia – in fact, it's syntax >> probably isn't context free, although there's a very limited amount of >> context required. If someone wanted to try to come up with one, that would >> be cool. Keeping it in sync with the actual parser might be a pain, but the >> parser has mostly settled down at this point. >> >> >>> On Sat, Jul 19, 2014 at 12:52 PM, Matthew Frank <[email protected]> >>> wrote: >>> I don't understand your claim that the newline isn't considered. I gave >>> several examples where "x - y" is parsed differenly depending on a newline. >>
