[Yunq] Move method numbers to a scheme set by the parser.

This commit is contained in:
Drew Galbraith 2024-01-11 21:00:51 -08:00
parent 3b91819a4b
commit 9e12531651
3 changed files with 5 additions and 2 deletions

View file

@ -215,8 +215,11 @@ class Parser():
methods: list[Method] = []
method_names = set()
next_method_number = 0
while self.peektype() != LexemeType.RIGHT_BRACE:
m = self.method()
m.number = next_method_number
next_method_number += 1
if m.name in method_names:
sys.exit("Method %s declared twice on %s" % (m.name, name))
method_names.add(m.name)