From 3283d727e74c3812efd19102cccbd4dd08684e92 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 26 May 2024 21:11:22 +0100 Subject: More annotations --- funco | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/funco b/funco index d433fde..55e22ab 100755 --- a/funco +++ b/funco @@ -1,5 +1,6 @@ #!/usr/bin/python3 +from typing import Any import operator import itertools import sys @@ -78,9 +79,9 @@ class Boolean(Token): class TailRec(Exception): - def __init__(self, ident, args): + def __init__(self, ident: Ident, args: list[Any]): self.ident = ident - self.args = args + self.call_args = args class Env(dict): @@ -99,7 +100,7 @@ class Env(dict): class Function(object): - def __init__(self, ident, parms, body): + def __init__(self, ident: Ident, parms: list[Ident], body: list[Any]): self.ident = ident self.parms = parms self.body = body @@ -120,11 +121,11 @@ class Function(object): except TailRec as tr: if self.env.find(tr.ident)[tr.ident.value] != self: error(f"{tr.pos}: tagged tail call can't be optimized") - args = [eval(expr, call_env) for expr in tr.args] + args = [eval(expr, call_env) for expr in tr.call_args] class Call(object): - def __init__(self, ident, args): + def __init__(self, ident: Ident, args: list[Any]): self.ident = ident self.args = args self.tail_rec = False -- cgit v1.2.3