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

Pancake syntax errors for if/else reported at wrong location #1011

Open
talsewell opened this issue Jul 11, 2024 · 1 comment
Open

Pancake syntax errors for if/else reported at wrong location #1011

talsewell opened this issue Jul 11, 2024 · 1 comment

Comments

@talsewell
Copy link
Contributor

It happens that pancake doesn't support if ( ) { } else if ( ) { } else { }, that is, the else if pair is not supported and the second if has to be enclosed in { .. }. That is a grumble but not a show stopper.

However, given this syntax, for some reason, the error reported is "failed to see expected token" at var yv = y;, which
is much too early:

fun foo (1 x, 1 y) {
  var xv = x;
  while (x < y) {
    var yv = y;
    if (xv <= y) {
      x = x + 8;
    }
    else if (xv > y) {
      x = x + 2;
    }
    else {
      x = x + 1;
    }
  }
  return x;
}

This is quite a nuisance, it requires an overcomplicated process of splicing out sections of the file to try to figure out what the error actually is.

@IlmariReissumies
Copy link
Member

Thanks for reporting. Adding else if shouldn't be too hard. The error reporting is pretty bare bones and really just pretty-prints the error messages we get from the PEG infrastructure; there's lots of room for improvement but it's better than nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants