Hacker News new | past | comments | ask | show | jobs | submit login

Silly question. The OP says:

    if (true) something()
    // Comment
    otherStatement()
> ... the comment should not be part of the if statement's node.

Why not? A comment seems like it isn’t functionally of the syntax tree, but, to the extent that one treats it like it is, it does seem like it’s in the middle of an if statement.




The first line is a complete statement that finishes at the end of the line - unless there's an else clause in the following line (not counting comments or empty lines). Expressed another way:

  if (true) {
    something()
  }

  // Comment

  otherStatement()
If this last line started with "else", then the comment would be within the if statement.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: