(a2ps.info)Declaring sequences


Next: Checking a Style Sheet Prev: Declaring keywords and operators Up: Style Sheets Implementation
Enter node , (file) or (file)node

7.6.7 Declaring the sequences
-----------------------------

Sequences admit several declarations too:
     SEQUENCES      ::= sequences are
                          SEQUENCE_1 ',' SEQUENCE_2...
                        end sequences
     SEQUENCE       ::= RULE IN_FACE CLOSE_OPT EXCEPTIONS_OPT
                      | C-string
                      | C-char
                      ;
     CLOSE_OPT      ::= RULE
                      | closers are
                          RULES
                        end closers
                      | <nothing>
                      ;
     EXCEPTIONS_OPT ::= exceptions are
                          RULES
                        end exceptions
                      | <nothing>
                      ;

   The rules are:
   - The default face is then IN_FACE.

   - If no closing rule is given, '"\n"' (i.e., end-of-line) is used.

   As a first example, here is the correct definition for a 'C' string:
     sequences are
      "\"" Plain String "\"" Plain
          exceptions are
             "\\\\", "\\\""
          end exceptions
     end sequences
   Since a great deal of languages uses this kind of constructs, you may
use 'C-string' to mean exactly this, and 'C-char' for manifest
characters defined the 'C' way.

   The following example comes from 'ssh.ssh', the style sheet for style
sheet files, in which there are two kinds of pseudo-strings: the strings
('"example"'), and the regular expressions ('/example/').  We do not
want the content of the pseudo-strings in the face 'String'.

     sequences are
       # The comments
       "#" Comment,

       # The name of the style sheet
       "style " Keyword_strong (Label + Index1) " is" Keyword_strong,

       # Strings are exactly the C-strings, though we don't want to
       # have them in the "string" face
       "\"" Plain "\""
          exceptions are
             "\\\\", "\\\""
          end exceptions,

       # Regexps
       "/" Plain "/"
          exceptions are
             "\\\\", "\\\/"
          end exceptions

     end sequences

   The order between sequences does matter.  For instance in Java, '/**'
introduces strong comments, and '/*' comments.  '/**' _must_ be declared
before '/*', or it will be hidden.

   There are actually some sequences that could have been implemented as
operators with a specific regular expression (that goes up to the
closer).  Nevertheless be aware of a big difference: regular expression
are applied to a single line of the source file, hence, they cannot
match on several lines.  For instance, the 'C' comments,
     /*
      * a comment
      */

cannot be implemented with operators, though 'C++' comments can:
     //
     // a comment
     //


automatically generated by info2www version 1.2.2.9