The validate module

class LexiconValidator(lexicon)[source]

Bases: object

error(msg, lexicon=None)[source]

Add message to errors.

warning(msg, lexicon=None)[source]

Add message to warnings.

validate()[source]

Validate a lexicon.

Errors and warnings are left in the errors and warnings attributes, respectively.

validate_pattern(pattern, n)[source]

Validate a regular expression pattern.

validate_rule(rule, n)[source]

Validate a rule, which should be action, target[, target, …].

Does not look at the action, but checks whether all the targets are valid (either an integer or a Lexicon).

check_default_target(target)[source]

Check whether this default target could lead to circular references.

This could hang the parser, and we wouldn’t like to have that :-)

validate_language(lang)[source]

Validate all lexicons in this language.

Errors and warnings are printed to stdout. If there are errors, this function returns False, otherwise True.

validate_transform(transform, language)[source]

Check whether the Transform has a method for every lexicon.

Returns False when method names are not defined. Prints the missing names to the console.

Prints a notice to the console when lexicons are ignored (i.e. the method name has been set to None in the Transform class) or when a transform method accepts untransformed contexts.