Browse Source

ኃጢአተኛ ነፍስህ ከመዳን በላይ ናት እናም ሰላምን ወይም

ሥቃይን አታውቅም ፣ የንስሐ ቅዝቃዜ ብቻ አብቅቷል ፣ ምክንያቱም ኃጢአቶችህ ከማንኛውም
ተልእኮ የላቀ ስለሆነ ፣ መጨረሻው ቀርቧል ፣ የኃጢአት መርከቦች
master
alexandre.aboulin 2 years ago
parent
commit
2097219638
  1. 23
      expression.py
  2. 6
      lexer.py

23
expression.py

@ -1,9 +1,4 @@
import re from lexer import Token
class Token:
OPERAND_ADDITION = "+"
OPERAND_MULTIPLICATION = "*"
NUMBER = re.compile(r'\d+') #CHANGER
class Expression: class Expression:
@ -23,16 +18,6 @@ class Expression:
return int(self.val) return int(self.val)
def __str__(self): def __str__(self):
if Token.NUMBER.match(string=self.val) is not None: if Token.NUMBER.match(str(self.val)) != None:
return self.val return str(self.val)
return "(" + self.gauche.__str__() + self.val + self.droite.__str__() + ")" return "(" + str(self.gauche.__str__()) + str(self.val) + str(self.droite.__str__()) + ")"
exp = Expression('*',
Expression(6, None, None),
Expression('+',
Expression(4, None, None),
Expression(3, None, None)
))
print(exp.evalue())
print(str(exp))

6
lexer.py

@ -0,0 +1,6 @@
import re
class Token:
OPERAND_ADDITION = "+"
OPERAND_MULTIPLICATION = "*"
NUMBER = re.compile(r'\d+') #CHANGER
Loading…
Cancel
Save