You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect this not to parse/parse with errors:
def foo():
foo()
But AFAICT there are no ERROR nodes in the tree, nor are there any nodes for which hasError() returns true. It looks like this was intentionally added in #65 ("As is often the case, I think the most practical fix is to allow a superset of what Python really allows, and treat empty blocks as valid blocks.")
I have a higher-level question: if I want to know whether a file parses correctly, can I do that with tree-sitter? Or is that not what tree-sitter is for?
The text was updated successfully, but these errors were encountered:
You can check if a block is empty by looking at its children in the syntax tree. So if you wanted to add some special handling for empty blocks (like an error message that says "Blocks must contain one or more statement"), you could do that by checking if a block contains any statements.
Thanks @maxbrunsfeld. Is it generally true that tree-sitter accepts a superset of what the programming language grammar allows? I'm trying to understand what to expect from tree-sitter, rather than trying to deal with this specific issue.
I would expect this not to parse/parse with errors:
But AFAICT there are no
ERROR
nodes in the tree, nor are there any nodes for whichhasError()
returns true. It looks like this was intentionally added in #65 ("As is often the case, I think the most practical fix is to allow a superset of what Python really allows, and treat empty blocks as valid blocks.")I have a higher-level question: if I want to know whether a file parses correctly, can I do that with tree-sitter? Or is that not what tree-sitter is for?
The text was updated successfully, but these errors were encountered: