Previous: , Up: Syntax Descriptors   [Contents][Index]


45.2.2 Syntax Flags

In addition to the classes, entries for characters in a syntax table can include flags. There are eleven possible flags, represented by the digits ‘1’–‘8’, and the lowercase letters ‘a’, ‘b’, and ‘p’.

All the flags except ‘p’ are used to describe comment delimiters. The digit flags indicate that a character can also be part of a multi-character comment sequence, in addition to the syntactic properties associated with its character class. The flags must be independent of the class and each other for the sake of characters such as ‘*’ in C mode, which is a punctuation character, and the second character of a start-of-comment sequence (‘/*’), and the first character of an end-of-comment sequence (‘*/’).

SXEmacs supports two comment styles simultaneously in any one syntax table. This is for the sake of C++. Each style of comment syntax has its own comment-start sequence and its own comment-end sequence. Each comment must stick to one style or the other; thus, if it starts with the comment-start sequence of style “b”, it must also end with the comment-end sequence of style “b”.

As an extension to GNU Emacs 19 and 20, SXEmacs supports two arbitrary comment-start sequences and two arbitrary comment-end sequences. (Thus the need for 8 flags.) GNU Emacs restricts the comment-start sequences to start with the same character, SXEmacs does not. This means that for two-character sequences, where GNU Emacs uses the ‘b’ flag, SXEmacs uses the digit flags ‘5’–‘8’.

A one character comment-end sequence applies to the “b” style if its first character has the ‘b’ flag set; otherwise, it applies to the “a” style. The ‘a’ flag is optional. These flags have no effect on non-comment characters; two-character styles are determined by the digit flags.

The flags for a character c are:

Lisp (as you would expect) has a simple comment syntax.

;

<

newline

>

Note that no flags are used. This defines two comment-delimiting sequences:

;

This is a single-character comment-start sequence because the syntax class is ‘<’.

newline

This is a single character comment-end sequence because the syntax class is ‘>’ and the ‘b’ flag is not set.

C++ (again, as you would expect) has a baroque, overrich, and excessively complex comment syntax.

/

1456

*

23

newline

>b

Note that the “b” style mixes one-character and two-character sequences. The table above defines four comment-delimiting sequences:

/*

This is a comment-start sequence for “a” style because the ‘1’ flag is set on ‘/’ and the ‘2’ flag is set on ‘*’.

//

This is a comment-start sequence for “b” style because both the ‘5’ and the ‘6’ flags are set on ‘/’.

*/

This is a comment-end sequence for “a” style because the ‘3’ flag is set on ‘*’ and the ‘4’ flag is set on ‘/’.

newline

This is a comment-end sequence for “b” style, because the newline character has the ‘b’ flag.


Previous: , Up: Syntax Descriptors   [Contents][Index]