:py:mod:`raesl.compile.ast.exprs` ================================= .. py:module:: raesl.compile.ast.exprs .. autoapi-nested-parse:: Expressions to store and reason about values and boundaries. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: raesl.compile.ast.exprs.DataValue raesl.compile.ast.exprs.Value raesl.compile.ast.exprs.VariableValue raesl.compile.ast.exprs.Expression raesl.compile.ast.exprs.Comparison raesl.compile.ast.exprs.RelationComparison raesl.compile.ast.exprs.ObjectiveComparison raesl.compile.ast.exprs.Disjunction Attributes ~~~~~~~~~~ .. autoapisummary:: raesl.compile.ast.exprs._MATH_OP_TRANSLATE .. py:class:: DataValue Some kind of data value. Do not use this, but use a derived class instead. .. py:method:: get_units() -> Optional[Set[str]] :abstractmethod: Obtain the units of the value. Gives a set of names without square brackets where lack of units results in the empty set, and not supporting units gives None. :returns: Names of the available units without square brackets or None. .. py:class:: Value(value: raesl.compile.scanner.Token, unit: Optional[raesl.compile.scanner.Token] = None) Bases: :py:obj:`DataValue` A value with an optional unit. Don't modify these objects in-place, create a new object instead. :param value: Stored value as text. :param unit: Either None or text describing the unit. Treat as read-only, as changing it may break the cache. .. attribute:: _unit_cache Units of the literal after normalizing self.unit. Computed on demand. .. py:method:: get_units() -> Optional[Set[str]] Obtain the units of the value. Gives a set of names without square brackets where lack of units results in the empty set, and not supporting units gives None. :returns: Names of the available units without square brackets or None. .. py:method:: __eq__(other) Return self==value. .. py:method:: __repr__() Return repr(self). .. py:class:: VariableValue(var_tok: raesl.compile.scanner.Token) Bases: :py:obj:`DataValue` Class representing a variable or parameter as value. :param var_tok: Token stating the possibly dotted name of the variable. :param var_node: If not None, the node represented by the object. Set during type checking. .. py:method:: get_units() -> Optional[Set[str]] Obtain the units of the value. Gives a set of names without square brackets where lack of units results in the empty set, and not supporting units gives None. :returns: Names of the available units without square brackets or None. .. py:class:: Expression Base class of an expression. .. py:class:: Comparison(is_constraint: bool) Bases: :py:obj:`Expression` Class storing a comparison. :param is_constraint: Whether the comparison is considered to be a constraint rather than a requirement. .. py:data:: _MATH_OP_TRANSLATE .. py:class:: RelationComparison(is_constraint: bool, lhs_var: VariableValue, isaux_tok: raesl.compile.scanner.Token, cmp_tok: raesl.compile.scanner.Token, rhs_varval: DataValue) Bases: :py:obj:`Comparison` A relation between a variable and either a value or a variable. :param is_constraint: Whether the comparison is considered to be a constraint rather than a requirement. :param lhs_var: Left hand side variable being compared. :param isaux_tok: 'is' for a constraint, else the aux word for expressing strength of the comparison. :param cmp_tok: One of the key words that expression the comparison to perform. :param math_compare: Translated 'cmp_tok', with the ascii math text. :param rhs_varval: Right hand side variable or value. .. py:method:: get_location() -> raesl.types.Location Return a location to point at the comparison for error reporting purposes. .. py:class:: ObjectiveComparison(lhs_var: VariableValue, aux_tok: raesl.compile.scanner.Token, maximize: bool) Bases: :py:obj:`Comparison` An intended direction for a variable. Note that the 'maximize' parameter controls both the 'maximize' and 'minimize' desires. :param lhs_var: Variable with the objective. :param aux_tok: One of the auxiliary verbs expressing strength of the objective. :param maximize: If set the comparison expresses the desire to maximize the variable. .. attribute:: minimize Opposite of maximize. .. py:property:: minimize :type: bool .. py:method:: get_location() -> raesl.types.Location Return a location to point at the comparison for error reporting purposes. .. py:class:: Disjunction(childs: Sequence[Expression]) Bases: :py:obj:`Expression` Disjunctive expression (also known as 'or' expression). It is true iff at least one of it child expressions is true. :param childs: Child expressions of the disjunction. It is recommended to have at least two children in an object.