Add references to error messages

That way, errors can reference other parts of the code, like duplicate
properties.
This commit is contained in:
James Westman 2022-05-27 15:06:56 -05:00
parent 824476bda1
commit d987b15374
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
2 changed files with 23 additions and 2 deletions

View file

@ -138,7 +138,10 @@ class AstNode:
if type(child) is type(self):
if check is None or check(child):
raise CompileError(error)
raise CompileError(
error,
references=[ErrorReference(child.group.start, child.group.end, "previous declaration was here")]
)
def validate(token_name=None, end_token_name=None, skip_incomplete=False):