maha.parsers.templates.value_expressions#

Module Contents#

Classes#

Value

Expression that returns a predefined value if the pattern matches.

MatchedValue

Expression that returns a predefined value of a matched expression from the input

FunctionValue

Expression that returns the output value of an input function when matched.

class Value(value, pattern, pickle=False)[source]#

Bases: maha.rexy.Expression

Expression that returns a predefined value if the pattern matches.

Parameters
  • value (Any) –

  • pattern (str) –

  • pickle (bool) –

value :Any[source]#
class MatchedValue(expressions, pattern)[source]#

Bases: Value

Expression that returns a predefined value of a matched expression from the input expressions

Parameters
  • expressions (ExpressionGroup) – The expressions to match

  • pattern (str) – The pattern to match

Returns

The result of the expression

Return type

ExpressionResult

class FunctionValue(function, pattern, pickle=True)[source]#

Bases: Value

Expression that returns the output value of an input function when matched.

Parameters
  • function (Callable) – The function to be called when the pattern matches.

  • pattern (str) – The pattern to be matched.

  • pickle (bool) –

Returns

The result of the expression.

Return type

ExpressionResult