(a2ps.info)Declaring keywords and operators


Next: Declaring sequences Prev: Syntax for the P-Rules Up: Style Sheets Implementation
Enter node , (file) or (file)node

7.6.6 Declaring the keywords and the operators
----------------------------------------------

Basically, keywords and operators are lists of rules.  The syntax is:
     keywords are
       RULES
     end keywords

or
     keywords in FACE-KEYWORD are
       RULES
     end keywords

in which case the default face is set to FACE-KEYWORD.

   As an example:
     keywords in Keyword_strong are
       /foo*/,
       "bar" "BAR" Keyword,
       -> \rightarrow
     end keywords

is valid.

   The syntax for the operators is the same, and both constructs can be
qualified with an 'optional' flag, in which case they are taken into
account in the heavy highlighting mode (Note: Pretty Print Options).

   This is an extract of the 'C' style sheet:
     optional operators are
        -> \rightarrow,
        && \wedge,
        || \vee,
        != \neq,
        == \equiv,
        # We need to protect these, so that <= is not replaced in <<=
        <<=,
        >>=,
        <= \leq,
        >= \geq,
        ! \not
     end operators

   Note how '<<=' and '>>=' are protected (there are defined to be
written as is when met in the source).  This is to prevent the two last
characters of '<<=' from being converted into a 'less or equal' sign.

   The order in which you define the elements of a category (but the
sequences) does not matter.  But since a2ps sorts them at run time, it
may save time if the alphabetical 'C'-order is more or less followed.

   You should be aware that when declaring a keyword with a regular
expression as lhs, then a2ps automatically makes this expression
matching only if there are no character of the first alphabet both just
before, and just after the string.

   In term of implementation, it means that
     keywords are
       /foo|bar/
     end keywords

is exactly the same as
     operators are
       /\\b(foo|bar)\\b/
     end operators

   This can cause problems if you use anchors (e.g.  '$', or '^') in
keywords: the matcher will be broken.  In this particular case, define
your keywords as operators, taking care of the '\\b' by yourself.

   Note: Match-word-boundary Operator,
 for details on '\b'.


automatically generated by info2www version 1.2.2.9