Core Module

The core package implements every aspect of nldsl that is not target dependent.

Its primary interface is the CodeGenerator class, which serves as a common base class for every CodeGenerator with a specific target. The CodeGenerator also implements the dictonary API via inheritance from the CodeMap.

Adding new grammar rules via python is implemented by the GrammarFunction and its associated GrammarParser. The grammar decorator provides syntactic sugar for generating instances of GrammarFunction from normal python functions.

The PipeFunction is called into action once a DSL statement, which defines a new grammar rule, is observed by the CodeGenerator. The PipeFunction then synthesizes a new pipeline using the already exist dynamic grammar rules.

Code Generation

This module contains the CodeMap, CodeGenerator and Recommendation classes.

The CodeMap is essentially a dispatcher dict, which contains all dynamically added grammar rules. It stores them in his __dict__ attribute. It implements the interface of a python dictonary.

The CodeGenerator generates executable code from DSL statements. In generall one want to derive from this class to crate a CodeGenerator with a specific target, such a Pandas, Spark, R, etc.

A Recommendation is returned by the CodeGenerator instead of executable code in case no code could be generated due to an incomplete or incorrect DSL argument list.

Example

First import:

from nldsl import CodeGenerator, grammar

Create custom code generator:

class MyCodeGenerator(CodeGenerator):
    def __init__(my_env_var_1, ..., my_env_var_n=default_val):
        # all arguments passed to super.__int__() will be added to the environment,
        # which in turn will be passed to any dynamic grammar rule if requested.
        super().__init__(my_env_var_1=my_env_var_1, ..., my_env_var_n=my_env_var_n)

Create a grammar rule, specifing the env parameter request the environment dict:

@grammar
def my_grammar_rule(code, args, env):
    """My grammar rule doc...
    Grammar:
        parse my expression !expr
    """
    return code + args["expr"] + env["my_var_1"]

Add to the code generators class itself:

MyCodeGenerator.register_function(my_grammar_rule)

Or only add it to specific instance instead:

code_gen = MyCodeGenerator(my_env_var_1)
code_gen["parse my expression"] = my_grammar_rule

One may also tell the code generator to infer the name:

code_gen["__infer__"] = my_grammar_rule
class nldsl.core.CodeMap[source]

Bases: collections.abc.MutableMapping

A CodeMap maps the names of DSL functions to python functions.

The names of DSL function are expected to be a sequence of lower case letters seperated by whitespaces. A CodeMap implements the dictonary interface.

A new function may either be added to a specific instance of CodeMap:

my_CodeMap["my dsl function name"] = my_function

Or to the class itself:

CodeMap.register_function(my_function, "my dsl function name")
__getitem__(name)[source]

Access the function that is associated with name and attached to this instance.

Parameters

name (str) – A name corresponding to the desired function.

Returns

(function) A python function, which takes a list as argument and returns a string.

Raises

KeyError – If no function corresponding to name exists.

__setitem__(name, fun)[source]

Define a function that will be associated with name only for this instance.

Parameters
  • name (str) – The name to be assoicated with the function.

  • fun (function) – The function this name should map to.

Returns

(class CodeMap) this instance of the class

__delitem__(name)[source]

Delete the function that is associated with name and attached to this instance.

Parameters

name (str) – A name corresponding to the desired function.

Returns

(class CodeMap) this instance of the class.

Raises

KeyError – If no function corresponding to name exists.

__iter__()[source]

Create an iterator over all dynmically added methods.

Returns

(iterator) Said iterator.

__len__()[source]

The number of all dynamically added methods.

Returns

(int) The number of of dynamically added methods.

property longest_name

The length of the longest sequence of tokens, which correspond to a function name.

update(other)[source]

Updated the CodeMap with other.

Parameters

other (CodeMap) – Another instance of CodeMap.

Returns

(CodeMap) This instance.

classmethod request_function(name)[source]

Access the function that is associated with name for all instances of this class.

Parameters

name (str) – A name corresponding to the desired function.

Returns

(function) A python function, or None.

classmethod register_function(fun, name=None)[source]

Define a function that will be associated with name for all instances of this class.

Parameters
  • fun (function) – The function this name should map to.

  • name (str) – The name to be assoicated with the function.

classmethod remove_function(name)[source]

Delete the function that is associated with name from all instances of this class

Parameters

name (str) – A name corresponding to the desired function.

Raises

KeyError – If no function corresponding to name exists.

class nldsl.core.CodeGenerator(recommend=True, **kwargs)[source]

Bases: nldsl.core.codegen.CodeMap

A CodeGenerator translates DSL statements into executable code or changes the Grammer.

There are two kind of DSL statements, the ones which can be evaluate to executable code and the ones, which extend the DSL Grammer. As a result parsing a set of DSL statements usually has two impacts. Executable code is generate and the CodeGenerator modifies itself in such a way that he is capable of parsing statements according to the new Grammer rules.

Furthermore the CodeGenerator derives from the CodeMap class and his grammer can also be extended by rules, which can not be expressed within the DSL. This is done with the __setitem__ and register_function methods.

Parameters
  • recommend (bool) – Whether to return a Recommendation if possible or always raise an error.

  • kwargs (dict) – Specify the environment, which will be passed to all grammar rules.

__call__(model, is_file=False)[source]

Convert the given model into code.

Parameters
  • model (str) – A filename or string containg DSL statements

  • is_file (bool) – True if model is filename, False otherwise.

Returns

(list) A list of strings containing executable code or recommendations.

classmethod register_dsl(model, is_file=False)[source]

Add all define statements in model to this class.

Parameters
  • model (str) – A filename or string containg DSL statements

  • is_file (bool) – True if model is filename, False otherwise.

Returns

(CodeGenerator) This class.

classmethod init_meta_model(eval_prefix='##', define_prefix='#$')[source]

Compile the model template and create the meta model.

Note

‘eval_prefix’ and ‘define_prefix’ must not be a valid sequence of tokens within the DSL nor a subset of such.

Parameters
  • eval_prefix (str) – The prefix for evaluation statements.

  • define_prefix (str) – The prefix for definition statements.

Raises

ValueError – If any of the arguments are equal to each other.

postprocessing(code_list)[source]

A hook for subclasses to modifiy the generate code list before it is returned.

Parameters

code_list (list) – A list of string containing executable code.

Returns

(list) The modified code list

extract_environment(source_lines)[source]

A hook for sublcasses, which is used by the compiler and completion generator.

Extract environment variables from the source_lines and update self.env accordingly.

Parameters

source_lines (list) – A list of strings containing source code.

class nldsl.core.Recommendation(rule, doc='')[source]

Provides recommendation on how to continue with a DSL statement.

A Recommendation is returned by the CodeGenerator instead of executable code in case no code could be generated due to an incomplete or incorrect DSL argument list.

Parameters

rule (grammar rule) – A Keyword-/Variable-/Expression-/VarListRule.

property documentation

The docstring of the grammar rule which raised this error.

property description

A string describing the arguments of the grammar rule which raised this error.

recommend()[source]

Provide a list of recommendations on how to continue with a DSL statement.

Returns

(list) Contains either a keyword, all choices for a variable or nothing.

External Dynamic Grammar

External Dynamic Grammar Rules are added via python functions.

It is advised to use the @grammar decorator for this, however it is not mandatory. The following prototypes are valid: * my_function(str: code, list: args, dict: env) -> str * my_function(str: code, list: args) -> str * my_function(str: code, dict: env) -> str * my_function(str: code) -> str

In case my_function only takes two arguments the second argument must be named args`or `env. Every class in this module contributes to the @grammar decorator.

Example

Implementation of a grammar rule for the pandas code generator:

@grammar(PandasExpressionRule)
def select_rows(code, args):
    """Select the rows of a DataFrame based on some condition.

    The condition can be composed out of boolean, comparison and arithmetic
    expression. The operator precedence is equivalent to python and it is possible
    to use brackets to modify it.

    Examples:
        1. ## x = on df | select rows df.col1 > (14.2 + z) and df.col2 == 'A'
        2. ## x = on df | select rows df.col1 != 0 and not df.col2 in [3, 5, 7]
        3. ## x = on df | select rows df.col3 % df.col1 != 2 or df.col1 <= 12

    Grammar:
        select rows !condition

    Args:
        condition (expression): A boolean expression used as a row filter.

    Type:
        Transformer
    """
    return code + "[{}]".format(args["condition"])
@nldsl.core.grammar(fun, doc=None, expr=<class 'nldsl.core.rules.ExpressionRule'>)[source]

Decorator for external grammar rules.

If no grammar is specified in the functions docstring or via the doc argument this will raise an error. Otherwise the argument list of the function will be converted into a dictonary, which maps grammar variables names to values.

Parameters
  • fun (function) – The function to be wrapped

  • doc (str) – A string containing the grammar description

  • expr (ExpressionRule) – The type of expression rule to be used

Returns

(function) GrammarFunction - functor, which behaves similar to fun

class nldsl.core.GrammarFunction(fun, grammar_desc=None, expr_rule=<class 'nldsl.core.rules.ExpressionRule'>)[source]

A GrammarFunction is wrapper around a function describing a grammar rule.

It uses a GrammarRule internally to convert the args list of the function into the format returned by the Grammar Rule. If the grammar_desc parameter is ommitted, the docstring of fun will be used instead.

Note

This docstring differs for every instance of GrammarFunction, that is the __init__ methods modifies the docstring.

Parameters
  • fun (function) – The function to be wrapped

  • grammar_desc (str) – A string describing the grammar.

  • expr_rule (ExpressionRule) – The type of expression rule to be used

__call__(code, args, env=None)[source]

Apply the internal function to code and args.

The args argument is parsed by the internal GrammarParser before passing it to the function.

Parameters
  • code (str) – The already generated code

  • args (list) – A list of string representing DSL arguments

  • env (dict) – A dictionary with environment variables.

Returns

(str) The modified code.

Raises

DSLFunctionError – If a DSLArgumentError occurs while applying the grammar rules.

property grammar_parser

The Parser used for this grammar.

property grammar_rule

The GrammarRule, responsible for argument conversion.

property grammar_rule_name

The GrammarRule’s name.

property grammar_rule_type

The GrammarRule’s type.

property grammar_rule_desc

A string containing a description of the associated grammar rule.

property function

The function this GrammarRule wrappes around.

class nldsl.core.GrammarParser(input_str, expr_rule=<class 'nldsl.core.rules.ExpressionRule'>)[source]

A GrammarParser parses the argument list of a DSL sentence. The parsing procedure is defined via specification of the associated grammar. A grammar rule should be specified as follows:

<name> <variable List | <variable> | <keyword> | <expression>...
variable name 1> := { value_1, ... , value_n}
...
<variable name n> := { value_1, ... , value_m}
  1. <name> can be any sequence of words (e.g. rename columns), optionally surrounded with brackets “(<name>)”

  2. <keyword> can be any word

  3. <variable> a word prefixed by the $ sign (e.g $my_variable)

  4. <variable list> has the form $var_list_name[$variable1 keyword1 …], any number of variables and keywords may be contained within the brackets. Providing a <var_list_name> is optional and will default to the tuple ($variable1, … , $variable2)

  5. The rows of the form <variable name> := { value_1, … , value_n} are optional and specify a finite set of values { value_1, … , value_n} available to the variable.

Example

Definition of the grammar rule “group by”:

group by $columns[$col] apply $agg
agg := { min, max, avg, sum }
Parameters
  • input_str (str) – A string containing grammar rules.

  • expr_rule (ExpressionRule) – The type of expression rule to be used

__call__(args)[source]

Convert the list of arguments args into a dictinonary.

All keywords are removed from args. All variable names become keys to their corresponding values. VarLists are converted into lists of tuples, where each tuples contains the values of the variables contained in the list in order.

Parameters

args (list) – A list of strings

Returns

(dict) A dictionary, which maps from variable names to values

property grammar_rules

The GrammarRule, responsible for argument conversion.

property grammar_choices

Mapping from variable names to choices.

property grammar_rule_name

The GrammarRule’s name.

property grammar_rule_type

The GrammarRule’s type.

property grammar_rule_desc

A string containing a description of the associated grammar rule.

Internal Dynamic Grammar

The DSL provides a mechanism to add new grammar rules via DSL statements.

This mechanism is implemented by the PipeFunction class, which synthesizes new grammar rules based on a DSL statement. The Converter classes translate the arguments of the new grammar.

class nldsl.core.PipeFunction(name, instructions, fun_list)[source]

PipeFunction provides a mechanism to define functions within the DSL.

Given a DSL statement such as:

#$ prepare $x with labels $y = rename columns $x to data, $y to labels | sort by $y

The left side of the equal sign defines the instructions and from the right side we derive the fun_map, which maps functions to partially specified argument lists.

Note

This docstring differs for every instance of GrammarFunction, that is the __init__ methods modifies the docstring.

Parameters
  • name (str) – The name of this PipeFunction within the DSL.

  • instructions (list) – A list of argument parsing instructions.

  • fun_list (list) – An list of (function, argument list) pairs.

__call__(code, args, env=None)[source]

Map the arguments args into a DSL pipeline and convert it to code.

Parameters

args (list) – A list of strings.

Returns

(str) A string containing executable python code.

Raises

DSLFunctionError – If a DSLArgumentError occurs while applying the grammar rules.

property grammar_rule

The GrammarRule, responsible for argument conversion.

property grammar_rule_name

The GrammarRule’s name.

property grammar_rule_desc

A string containing a description of the associated grammar rule.

property grammar_rule_type

The GrammarRule’s type.

property functions

A list of the internal functions.

property argument_converters

A list of (function, argument converters) pairs.

class nldsl.core.IdentityConverter(arg, name_dict)[source]

A converter for keyword and value arguments. It basically does nothing, it just exists for API consistency.

Parameters
  • arg (dict) – A dict containg a Keyword or Value (see nldsl.core.types).

  • name_dict (dict) – A mapping from variable names to instructions.

__call__(input_dict)[source]

Returns a list containing only the value of the arg element it received on constructions.

Parameters

input_dict (dict) – Not used, exist only for API consistency.

Returns

(list) A list containing only a single string.

property value

The value (or keyword) which will be returned by the call method

class nldsl.core.NameConverter(arg, name_dict)[source]

Converts a variable or expression name to its values.

Parameters
  • arg (dict) – Either a Variable or Expression type (see nldsl.core.types).

  • name_dict (dict) – A mapping from variable names to instructions.

Raises

ValueError – If the arg.data is not a key in name_dict.

__call__(input_dict)[source]

Returns the value of the variable name stored in input_dict.

Parameters

input_dict (dict) – A map from variable names to values

Returns

(list) A list containing only one string

property name

The name of the variable or expression.

class nldsl.core.ListConverter(arg, name_dict)[source]

Converts a variable list to its values.

Parameters
  • arg (dict) – A dict containg a VarList (see nldsl.core.types).

  • name_dict (dict) – A mapping from variable names to instructions.

Raises

ValueError – If the variable list name is not in name_dict.

__call__(input_dict)[source]

Returns the values for the variable list stored in input_dict.

Parameters

input_dict (dict) – A map from variable names to values

Returns

(list) A list containg the values corresponding to variable list

property name

The name of the variable list.

property data

The data of the target.

property map

The mapping of variable positions.

Dynamic Grammar Rules

For each DSL argument type exist a dedicated rule responsible for parsing it.

The class GrammarRule contains a list of such rules, which it uses to parse a list of different DSL arguments. Amongst all rules the ExpressionRule is the most sophistaced one and it is also intended that the a user may derive from it to adjust the parsing of expressions to his/her needs.

class nldsl.core.GrammarRule(instructions, choices=None, expr_rule=<class 'nldsl.core.rules.ExpressionRule'>)[source]

A GrammarRule consists out of a list of rules.

Parameters
  • instructions (list) – Descibes how to synthesize the rule.

  • choices (dict) – A dict, which maps variable names to values.

  • expr_rule (ExpressionRule) – The type of expression rule to be used.

__call__(args)[source]

Convert the list of arguments args into a dictinonary.

All keywords are removed from args. All variable names become keys to their corresponding values. VarLists are converted into lists of tuples, where each tuples contains the values of the variables contained in the list in order.

Parameters

args (list) – A list of strings.

Returns

(dict) A dictionary, which maps from variable names to values.

Raises
  • ValueError – Raised if too many arguments are provided.

  • DSLArgumentError – If a DSL argument is missing

property rules

A list of the internal rules.

property choices

A dictionary wich maps variable names to lists of choices.

property expression_rule

The type of expression rule that is used.

property description

A string containing a description of the grammar rule.

class nldsl.core.KeywordRule(keyword)[source]

A KeywordRule is responsible for parsing keywords.

Parameters

keyword (str) – A string describing a keyword

__call__(res_dict, args)[source]

Apply the KeywordRule.

If the first element from args is a euqal to the keyword stored in this rule, it will be removed. Otherwise an error is raised.

Parameters
  • res_dict (dict) – redundant - exists only for api consistency

  • args (list) – A list of strings

Returns

(tuple) The first element is res_dict and the second args

Raises
  • ValueError – This error is raised if the keyword is not the next argument.

  • DSLArgumentError – If the keyword is incomplete e.g (“keyw” instead of “keyword”).

property name

The name of the keyword.

property description

A string containing a description of the grammar rule.

class nldsl.core.VariableRule(variable_name, choice_rules=None)[source]

A VariableRule is responsible for parsing variables.

Parameters
  • variable_name (str) – A string containing the name of a variable

  • choice_rules (dict) – A dict mapping variable names to a list of possible values

__call__(res_dict, args)[source]

Apply the VariableRule.

Adds the first value of args to the dictionary where the internally stored variable_name is used as a key. Raises an error if a list of choices for the variable is given (via choice_rules) and the value is not contained in that list.

Parameters
  • res_dict (dict) – A dictionary mapping variable names to values

  • args (list) – A list of strings

Returns

(tuple) The first element is res_dict and the second args

Raises

ValueError – Raised if the value is not contained in the list of choices.

property name

The name of the variable.

property description

A string containing a description of the grammar rule.

class nldsl.core.VarListRule(var_list_name, internal_rules, next_keyword=None)[source]

A VariableRule is responsible for parsing variable lists.

Parameters
  • var_list_name (str) – A string containing the name of a variable

  • internal (list) – List key_word_rules or VariableRules

  • next_keyword (str) – The keyword that comes after this varlist or None

__call__(res_dict, args)[source]

Apply the VariableRule.

Adds a list to the dictionary with tuples containing the values of the variables in the list.

Parameters
  • res_dict (dict) – A dictionary mapping variable names to values

  • args (list) – A list of strings

Returns

(tuple) The first element is res_dict and the second the remaining args

Raises

DSLArgumentError – If a DSL argument is missing.

property name

The name of the variable list.

property description

A string containing a description of the grammar rule.

class nldsl.core.ExpressionRule(expr_name, next_keyword=None)[source]

An ExpressionRule is responsible for parsing expression.

Parameters
  • expr_name (str) – The name of the expression.

  • next_keyword (str) – The keyword after this expression or None

property name

The name of the expression.

property description

A string containing a description of the grammar rule.

__call__(res_dict, args)[source]

Apply the ExpressionRule.

Adds a string containing the parsed expression to ‘res_dict’

Parameters
  • res_dict (dict) – A dictionary mapping variable names to values

  • args (list) – A list of strings

Returns

(tuple) The first element is res_dict and the second the remaining args

apply_operator_seq(lhs, rhs_list)[source]

Concatenates lhs and all expressions in rhs_list.

Parameters
  • lhs (str) – The left most expression

  • rhs_list (list) – A list of (operator, expression) tuples

Returns

(str) A string containing the parsed expressions

apply_operator(operator, lhs='', rhs='')[source]

Applies the operator to the left- and right-hand-side expression

If the operator is a function the expressions will become its arguments. Otherwise they will simply be concatenated.

Parameters
  • operator (str) – A string containg an operator

  • lhs (str) – A string containg an expression

  • rhs (str) – A string containg an expression

Returns

(str) The resulting expression

factor_sign(operator)[source]

Modify an operator, which describes the sign of a base.

The default implementation simply strips all whitespaces.

Parameters

operator (str) – A string representation of the operator.

Returns

(str) The operator string stripped from preceeding and trailing whitespaces.

Argument and Operator Types

Each argument provided to a DSL statement is of a certain type. The DSL argument types are Value, Keyword, Variable, Expression and VarList. Additionally some types dedicated to the operators used by expression exists.

class nldsl.core.OperatorType[source]

Bases: enum.IntEnum

Type of operators as used by the ExpressionRule.

class nldsl.core.Type(data)[source]

Base class for DSL argument types.

Parameters

data (object) – The data associated with this object

property data

Get the data member.

class nldsl.core.Value(data)[source]

Bases: nldsl.core.types.Type

A Type for arguments which are plain values.

property value

Set the value.

class nldsl.core.Keyword(data)[source]

Bases: nldsl.core.types.Type

A Type for arguments which are keywords.

property keyword

Get the keyword.

class nldsl.core.Variable(data)[source]

Bases: nldsl.core.types.Type

A Type for arguments which are variables.

property name

Get the name.

class nldsl.core.Expression(name)[source]

Bases: nldsl.core.types.Type

A Type for arguments which are expressions.

Parameters

name (str) – The name of this variable

property name

Get the name.

class nldsl.core.VarList(name, variables)[source]

Bases: nldsl.core.types.Type

A Type for arguments which are Variable Lists.

Parameters
  • name (str) – The name of this variable list

  • variables (list) – A list of Variable or Keyword objects

property name

Get the name.

property variables

Get the variables and keywords.

nldsl.core.is_type(arg)[source]

Check if arg is an instance of Type.

Parameters

arg (object) – The object to investigate.

Returns

(bool) True if the argument is a Type, false otherwise.

nldsl.core.is_value(arg)[source]

Check if arg is an instance of Value.

Parameters

arg (object) – The object to investigate.

Returns

(bool) True if the argument is a Value, false otherwise.

nldsl.core.is_keyword(arg)[source]

Check if arg is an instance of Keyword.

Parameters

arg (object) – The object to investigate.

Returns

(bool) True if the argument is a Keyoword, false otherwise.

nldsl.core.is_variable(arg)[source]

Check if arg is an instance of Variable.

Parameters

arg (object) – The object to investigate.

Returns

(bool) True if the argument is a Variable, false otherwise.

nldsl.core.is_expression(arg)[source]

Check if arg is an instance of Expression.

Parameters

arg (object) – The object to investigate.

Returns

(bool) True if the argument is a Expression, false otherwise.

nldsl.core.is_var_list(arg)[source]

Check if arg is an instance of VarList.

Parameters

arg (object) – The object to investigate.

Returns

(bool) True if the argument is a VarList, false otherwise.

Utility functions

The utils module provides utility functions for the core package.

@nldsl.core.decorator_factory[source]

A decorator which improves the parsing of optional arguments of other decorators.

Let a decorator of the following form be given:

decorator(arg1=value1, ... , kwargsN=valueN)'

One would need to write the following in case all arguments should be left as default:

@decorator()
def myFunction ...

If we declare our decorator as follow:

@decorator_factory
def decorator(fun, arg1=value1, ... , kwargsN=valueN)

We could write instead:

@decorator
def myFunction ...

Furthermore, we do not have to write the boilderplate code necessary to implement a decorator with arguments in the first place.

nldsl.core.cast_down(value)[source]

Convert an object to an integer if no rounding is required.

If the object is a float, which can be converted to an integer without rounding int(value) is returned. Otherwise value is returned.

Parameters

value (object) – An object to possibly converted

Returns

(object or int) Either value or its integer representation.

nldsl.core.convert_function(fun)[source]

Convert the function signature if necessary

The target signature is: my_function(str: code, list: args, dict: env) -> str

The changes are strictly additive, in that no argument will be removed.

Parameters

fun (function) – The function to be converterd.

Returns

(function) A function with proper signature.

Raises

ValueError – If fun has four or more parameters.

nldsl.core.split_code(code, split_on=' = ')[source]

Split the code in half on the string specified by split_on.

Parameters
  • code (str) – A string containg code

  • split_on (str) – The string on which to split the code

Returns

(tuple) Code before and after the string split_on

nldsl.core.list_to_string(string_list)[source]

Converts a list of strings into a single string.

Unlike {}.format(some_list) this treats elements of the form “’…’” properly.

Parameters

string_list (list) – A list of strings

Returns

(str) A string containing the list.

Exceptions

A selection of exception classes to describe incomplete or incorrect DSL Arguments. All of these exceptions will be catched by the CodeGenerator class and converted into a code recommendation.

class nldsl.core.DSLError[source]

Base class for all DSL related exceptions.

class nldsl.core.DSLArgumentError(message, rule)[source]

This exception indicates that a DSL argument is missing or incorrect.

Parameters
  • message (str) – A string containing a description of the error

  • rule (grammar rule) – An instance of grammar rule class.

class nldsl.core.DSLFunctionError(message, rule, doc='')[source]

This exception indicates that a DSL function failed to generate code

This exceptions is usually raised due to a previous DSLArgumentError exception.

Parameters
  • message (str) – A string containing a description of the error

  • rule (grammar rule) – An instance of grammar rule class.