diff options
author | Juan J. Martinez <jjm@usebox.net> | 2024-05-26 21:11:22 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2024-05-26 21:11:22 +0100 |
commit | 3283d727e74c3812efd19102cccbd4dd08684e92 (patch) | |
tree | af7b80b5bd22d78393ca686727c87db178d00db5 | |
parent | a751b3de1773735ed75384b293269353d94d38bd (diff) | |
download | funco-3283d727e74c3812efd19102cccbd4dd08684e92.tar.gz funco-3283d727e74c3812efd19102cccbd4dd08684e92.zip |
More annotations
-rwxr-xr-x | funco | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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 |