Next: Statements, Previous: Constant Definition, Up: The Language
A rule is a sequence of statements that is executed as a unit:
combi_rule name($param1, $param2, ...): statement1 statement2 ... end name;
A rule has to begin with one of the keywords allo_rule
,
combi_rule
, end_rule
, pruning_rule
,
robust_rule
, input_filter
, output_filter
or
subrule
. It is followed by its parameter list, a list of
variable names. The variables will be assigned the
parameter values when the rule is executed. The number of parameters
depends on the rule type. The rule names have the following meanings:
allo_rule(
$lex_entry)
result
. An allomorph rule has one parameter, namely the
lexicon entry.
combi_rule(
$state,
$link,
$surf,
$index)
result
).
end_rule(
$state,
$remain_input)
result
.
pruning_rule(
$list)
return
statement with a list of the symbols yes
and/or
no
. Each state in $list corresponds to a symbol in the
result list. If the symbol is yes
, the corresponding state is
preserved. If the symbol is no
, the state is abandoned.
robust_rule(
$surface,
$remain_input)
robust
command, and a
word form could not be recognised by the combi-rules, the robust-rule is
executed with the surface of the next word form as its first
parameter. The next word form is defined as the remaining input up to
(but excluding) the next space. The optional second parameter contains
the whole remaining input. A robust-rule can accept any prefix of the
remaining input via result
.
input_filter(
$feature_structure_list)
result
).
output_filter(
$feature_structure_list)
result
).
result
).
subrule(
$param1,
$param2, ...)
return
. It can have any number of parameters (at least one).
If a rule is executed, all statements in the rule are processed sequentially.
After that, the rule execution is terminated. Thereby, the if
statement,
the foreach
statement, and the select
statement may change the
processing order. Special conditions apply if:
require
statement does not hold. In this case the
processing of the current rule path is terminated. This is not an error.
stop
statement was executed. In this case the
processing of the current rule path is terminated. This is not an error.
assert
condition does not hold. In this case the processing of
the whole grammar is terminated and an error message is displayed. This rule
termination can be used to find bugs in the rule system or in the lexicon.
error
statement was executed. In this case the processing of
the whole grammar is terminated and an error message is displayed.
return
statement was executed in a subrule or in a pruning
rule. In a subrule, this terminates the subrule int the current rule path and
immediately returns to the calling rule. In a pruning rule, this terminates
the pruning rule.