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