raesl.compile.typechecking.expr_checker#

Check that expressions comply with the language requirements.

Module Contents#

Classes#

ExprChecker

Class for checking expressions.

class raesl.compile.typechecking.expr_checker.ExprChecker(vps: Dict[str, raesl.compile.ast.components.VarParam], diag_store: raesl.compile.diagnostics.DiagnosticStore)#

Class for checking expressions.

Parameters:
  • vps – Variables and parameters defined in the expression context.

  • diag_store – Storage for found diagnostics.

reported_names#

Names of variables and variable parts that have been reported as error, to avoid duplicate error messages.

check_expr(expr: raesl.compile.ast.exprs.Expression) bool#

Check whether the expression follows all rules of the ESL language.

Parameters:

expr – Expression to check.

Returns:

Whether the expression is considered to be sufficiently correct to continue

checking other parts of the construct around the expression.

check_relation_comparison(expr: raesl.compile.ast.exprs.RelationComparison) bool#

Check the provided relation comparison.

Parameters:

expr – Relation comparison to check.

Returns:

Whether the expression is considered to be sufficiently correct.

_check_relation_side(side: raesl.compile.ast.exprs.DataValue) Tuple[raesl.compile.scanner.Token, raesl.compile.ast.types.BaseType | None, Set[str] | None] | None#

Check one side in a relation comparison.

Parameters:

side – Side to check.

Returns:

Information about the checked side. None means an error has been reported,

otherwise a triplet of token, type, and supported units is returned for as far as the side supports each notion.

_check_variable(var: raesl.compile.ast.exprs.VariableValue) bool#

Check that the variable exists in the context.

Parameters:

var – Variable to check.

Returns:

Whether the variable was found.