Improve statement parsing: clear diagnostics, paren validation#1804
Improve statement parsing: clear diagnostics, paren validation#1804has9sayed wants to merge 4 commits into
Conversation
mstimberg
left a comment
There was a problem hiding this comment.
Thanks, this looks generally good to me! While testing, I noticed a small issue that was already present in the previous code, but it would make sense to fix it here as well. Statements like x = (missing RHS) fail parsing (as they should), but x = # missing expression will parse fine, using the comment as the expression.I think we could catch this quite easily here as well.
|
Oh, only just realized that the test suite is failing. This is actually a silly issue, there is a test with a missing identifier (testing whether this is detected) which happens to also have a syntax error, i.e. unbalanced parentheses… Since these are now caught first, the error type is different. Please fix the unbalanced parentheses in that test: brian2/brian2/tests/test_synapses.py Lines 3664 to 3673 in a5eccc2 |
Enhance parse_statement with descriptive error messages (using pyparsing labels and the - operator), automatic balanced-parenthesis checking, and full support for # inside trailing comments. This replaces generic parsing failures with clear, caret-based error diagnostics.
For the wrong input
v = (5 + 3now it gives -