#!/usr/bin/perl -w

=head1 NAME

set.rules - Rules set for acheck

=head1 DESCRIPTION

Rules set files contain rules to be check by acheck.

Lines beginning with a number sign (`B<#>') and empty lines will be ignored.
Spaces at the beginning and the end of a line will also be ignored as well as
tabulators.  If you need spaces at the end or the beginning of a value you can
use apostrophes (`B<">').
A comment starts with the number sign, there can be any number of spaces and/or
tab stops in front of the #.
Long lines can be broken into multiple lines ending with a backslash (`B<\>').
Some possible examples:

 # this line is ignored
 field    value
 field    value                               # this is a comment
 field         "value ending with space   "
 field    value\
          continuing on the next line

You have to escape number signs with a backslash to use it in a value and use
apostrophes if a value ends with a backslash.

Rule sets are made of lists of rules. Theses lists can be repeated a number of
times, until or while a condition happens.

A rule detects an error if the corresponding test succeeds and none of its
validation tests does. Each rule can then produce some fixes, a warning or an
error, and provide hints to help the operator to correct the error.

Parts of the text can be set as comments and so no rule and no spell check will
be performed on them.

=head1 RULE FILE SYNTAX

=head1 SYNTAX RULES

=head2 list

A list starts at a `I<list>' statement, and stops at the first `I<end_list>' or
at the end of the file.

Mandatory fields:

=over 4

=item I<type> type

=over 4

=item I<until>, perform the list until the current line matches `I<test>'

=item I<while>, perform the lint while the current line matches `I<test>'

=item I<loop>, perform the list `I<test>' times

=back

=item I<test> regex / number

A regex for `I<until>' and `I<while>' lists. The number of times the list must
be performed for `I<loop>', or `I<0>' for infinite loop.

=back

Optional fields:

=over 4

=item I<name> name

Use this to give the list a name.

=item I<spell> yes / no

Set it to `I<yes>' (default) or `I<no>', if you want or don't want spelling to
be checked in the lines matching this list. This value will be inherited by the
nested lists.

=back

Sub-rules:

=over 4

=item I<list> [name]

=item I<rule> [name]

=item I<comment> [name]

Followed by the name of the sub-rule or its definition for an anonymous
sub-rule.

=back

=head2 rule

A rule starts at a `I<rule>' statement, and stops at the first `I<end_rule>' or
at the beginning of a comment or a list.

Mandatory fields:

=over 4

=item I<type> type

=over 4

=item I<fix>, rule provides fixes and hints thought a menu

=item I<autofix>, rule fixes the mistake with no interaction

=item I<warning>, rule issues a warning

=item I<error>, rule issues an error

=item I<nop>, special rule that do nothing, no other field is required

=back

=item I<regex> regex

The regex to be match to found this error. Patterns can be captures and then
used in the `I<fix>' expression.

=item I<fix> expr

Provides a correction for the rule, this field can be repeated to provides more
than one choice. Only the first one will be used for `I<autofix>' rules.
`I<warning>' and `I<error>' do not provides fixes. The captured patterns can be
used here with variables `I<$1>', `I<$2>', and so on.

=item I<hint> text

Provides some explanations, this will be used as reviewer comments in review
mode.

=back

Optional fields:

=over 4

=item I<name> name

Use this to give the rule a name.

=item I<valid> [name]

Provides a validation test, it can be named or anonymous. For anonymous
validation, the test definition must follow.  This field can be repeated more
than once, if any of the validation test succeed, the rule does not apply.

=back

=head2 valid

A validation test starts at a `I<valid>' statement, and stops at the first
`I<end_valid>' or at the beginning of a rule, a comment, a list or another
validation test.

Mandatory field:

=over 4

=item I<pre> regex

=item I<in> regex>

=item I<post> regex

Try the regex before, in or after the match of the regex rule. At least one of
these test must be provided. If all tests are successful, the rule won't apply.

=back

Optional field:

=over 4

=item I<name> name

Use this to give the validation test a name.

=back

=head2 comment

A comment starts at a `I<comment>' statement, and stops at the first
`I<end_comment>' or at the beginning of a rule, a comment or a list.

Comments are just skipped, no other rule and no spelling are performed on them.

Mandatory field:

=over 4

=item I<skip> regex

A regex matching the text of the comment. Do not use `I<start>' and `I<stop>'
with this.

=item I<start> regex

=item I<stop> regex

Regexs defining the beginning and the end of the comment, all the text between
will be considered as comment. Do not use `I<skip>' with this.

=back

Optional fields:

=over 4

=item I<name> name

Use this to give the comment a name.

=item I<start_offset>

=item I<stop_offset>

Defines where the comment really starts or end. Values are `I<s>' for the place
the match starts, `I<s+E<lt>nE<gt>>' for I<n> characters after the match
starts, `I<e>' for the place the match ends, or `I<e-E<lt>nE<gt>>' for I<n>
characters before the match ends. Defaults are `I<s>' for `I<start>' matches
and `I<e>' for `I<stop>' matches.

=back

=head1 SEE ALSO

acheck(1), acheck(5)

=head1 AUTHOR

Nicolas Bertolissio <nico.bertol@free.fr>
  
=cut
