Next: Parsing hooks   Previous: Tag definition   Contents: Contents

Base definition

What the parser basically needs to know about a tag is if it takes options and a body, because this influences parsing directly. If a tag has no body but the parser looks for it, a parsing error might occur for no real reason, or bodylike source parts following the tag immediately would be misinterpreted. Providing the necessary informations is simple. Here's the example from the last section again, expanded by the related details.


  # tag declarations
  %tags=(
         EMPHASIZE => {
                       # options
                       options => TAGS_OPTIONAL,

                       # don't miss the body!
                       body    => TAGS_MANDATORY,
                      },

         COLORIZE => {...},

         FONTIFY  => {},

         ...
        );

This is easy to understand. The option and body slots express if options and body are obsolete, optional or mandatory. This is done by using constants provided by PerlPoint::Constants (which comes with the framework). The following constants are defined:

constantmeaning
TAGS_OPTIONALOptions/body can be used or not.
TAGS_MANDATORYThe option/body part must be specified.
TAGS_DISABLEDNo need to use options/body. The parser will not expect such parts. This means that with an obsolete body, an <anything> sequence will not be treated as a tag body but as plain text. Likewise, if options are declared to be obsolete and a {thing=something} follows the tag name, this will be detected as plain text, not as the tag options. This can cause syntactical errors if the body is mandatory, because in this case the parser expects the body to follow the tag name.

Omitted options or body slots mean that options or body are optional. So a descripton at least consists of an empty anonymous hash (see FONTIFY in the example above).

Next: Parsing hooks   Previous: Tag definition   Contents: Contents