Add errors for duplicate properties and blocks

This commit is contained in:
James Westman 2022-05-27 13:27:18 -05:00
parent f18c8b7a2d
commit 824476bda1
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
12 changed files with 122 additions and 0 deletions

View file

@ -131,6 +131,16 @@ class AstNode:
yield from child.iterate_children_recursive()
def validate_unique_in_parent(self, error, check=None):
for child in self.parent.children:
if child is self:
break
if type(child) is type(self):
if check is None or check(child):
raise CompileError(error)
def validate(token_name=None, end_token_name=None, skip_incomplete=False):
""" Decorator for functions that validate an AST node. Exceptions raised
during validation are marked with range information from the tokens. """