From f5794ce52f76a5aa6c7d8d21544040cf86aa6fed Mon Sep 17 00:00:00 2001 From: Shadow Date: Sun, 31 May 2020 11:54:26 +0200 Subject: [PATCH] Fix des erreurs --- compylateur.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/compylateur.py b/compylateur.py index 6108e89..b7243ce 100644 --- a/compylateur.py +++ b/compylateur.py @@ -16,16 +16,10 @@ # --- Tokens --- # class Token(): - def __init_(self, token_type, token_value): + def __init__(self, token_type, token_value): self.type = token_type self.value = token_value - def type(self): - return self.type - - def value(self): - return self.value - class TokenList(): def __init__(self, l_token = []): self.index = -1 @@ -41,6 +35,9 @@ class TokenList(): else: return False + def reset(self): + self.index = -1 + # --- Abstract Syntax Tree (AST) --- # class AST(): @@ -127,10 +124,10 @@ def parser(l_token): # --- Secondary functions --- # -def expect(target = [], l_token): +def expect(l_token, token_see, target = []): last = token_see token_see = l_token.get() - if target != [] and last.type() not in target: + if target != [] and last.type not in target: raise SyntaxError("unknown operand, one of these is expected : " + ", ".join(target)) return last