Beispiel #1
0
 def __init__(self, conditionProgram, trueProgram, lineno=0):
     self.lineno = lineno
     self.conditionProgram = conditionProgram
     Node.__init__(self, [conditionProgram, trueProgram])
     conditionProgramType = self.conditionProgram.getOperationType()
     if conditionProgramType is not TypeBooleanNode:
         errorList.append(
             f"NotBooleanException at line {self.lineno} : Must be a boolean for a Loop"
         )
Beispiel #2
0
    def __init__(self, value, lineno=0):
        valueType = value.getOperationType()
        self.lineno = lineno

        if valueType is not TypeShapeNode:
            errorList.append(
                f'InvalidTypeException at line {self.lineno} : Must be a shape to draw instead of {createErrorStringFromClassName(valueType)}'
            )

        Node.__init__(self, [value])
Beispiel #3
0
    def __init__(self, operation, operandes, lineno):
        Node.__init__(self, operandes)
        self.operandes = operandes
        self.operation = operation
        self.lineno = lineno

        constraints = BinaryOperation.operationTable[self.operation][1]
        op = self.getOperandeType()
        if op not in constraints:
            errorList.append(
                f'InvalidOperandeException at line {self.lineno} : For binary operation \'{self.operation}\' use \'{createErrorStringFromClassName(constraints)}\' instead of \'{createErrorStringFromClassName([op])}\''
            )
Beispiel #4
0
    def __init__(self, tokenVariableName, value, lineno=0):
        variableName = tokenVariableName.variableName
        self.lineno = lineno
        if variableName not in variablesTypes.keys():
            errorList.append(
                f'UndeclaredVariableException at line {self.lineno} : Variable \'{variableName}\' not declared'
            )
        else:
            valueType = value.getOperationType()
            variableType = variablesTypes[variableName]
            if valueType != variableType:
                errorList.append(
                    f'InvalidTypeException at line {self.lineno} : Variable \'{variableName}\' is of type \'{createErrorStringFromClassName(variableType)}\' instead of \'{createErrorStringFromClassName(valueType)}\''
                )

        Node.__init__(self, [tokenVariableName, value])
Beispiel #5
0
    def __init__(self,
                 conditionProgram,
                 trueProgram=None,
                 falseProgram=None,
                 lineno=0):
        self.evaluated = False
        self.lineno = lineno
        l = [conditionProgram]
        self.conditionProgram = conditionProgram
        conditionProgramType = self.conditionProgram.getOperationType()
        if conditionProgramType is not TypeBooleanNode:
            errorList.append(
                f"NotBooleanException at line {self.lineno} : Must be a boolean for a If"
            )

        self.trueProgram = trueProgram
        self.falseProgram = falseProgram
        if trueProgram != None:
            l.append(trueProgram)

        if falseProgram != None:
            l.append(falseProgram)
        Node.__init__(self, l)
Beispiel #6
0
 def __init__(self, value):
     Node.__init__(self)
     self.value = value
Beispiel #7
0
 def __init__(self, variableName):
     Node.__init__(self)
     self.variableName = variableName
Beispiel #8
0
 def __init__(self, content, name=None):
     Node.__init__(self, content)
     self.name = name
Beispiel #9
0
 def __init__(self, values, lineno=0):
     self.lineno = lineno
     Node.__init__(self, values)
Beispiel #10
0
 def __init__(self, shapetype, attr):
     Node.__init__(self, attr)
     self.shapetype = shapetype
Beispiel #11
0
 def __init__(self, variableType, tokenVariableName):
     Node.__init__(self, [variableType, tokenVariableName])
     variablesTypes[tokenVariableName.variableName] = type(variableType)