You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
869 B

import re
class VariableType:
'''Базовый класс для типов.'''
def check(self, value: str) -> bool:
pass
class StringType(VariableType):
pass
class IntegerType(VariableType):
integer_pattern = re.compile(r"^-?\d+$")
def check(self, value) -> bool:
return self.integer_pattern.match(value)
class FloatType(VariableType):
float_pattern = re.compile(r"^-?\d+(\.\d+)?$")
def check(self, value) -> bool:
return self.integer_pattern.match(value)
class BooleanType(VariableType):
pass
class ListType(VariableType):
pass
class ReadonlyType(VariableType):
pass
class Variable:
def __init__(self, variable_type: VariableType):
self.var_type = variable_type
class Namespace:
def __init__(self, name=''):
self._name = name
self.variables = dict()