3 ms·
Silly question. The OP says: if (true) something() // Comment otherStatement() > ... the comment should not be part of the if statement's node. W
by amluto 3y ago
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.
- lioeters 3y agoThe 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.