+#include "category.h"
+
+/* Then there are seven single-bit flags that have the following meanings:
+ 1. This character is the first of a two-character comment-start sequence.
+ 2. This character is the second of a two-character comment-start sequence.
+ 3. This character is the first of a two-character comment-end sequence.
+ 4. This character is the second of a two-character comment-end sequence.
+ 5. This character is a prefix, for backward-prefix-chars.
+ 6. The char is part of a delimiter for comments of style "b".
+ 7. This character is part of a nestable comment sequence.
+ 8. The char is part of a delimiter for comments of style "c".
+ Note that any two-character sequence whose first character has flag 1
+ and whose second character has flag 2 will be interpreted as a comment start.
+
+ bit 6 and 8 are used to discriminate between different comment styles.
+ Languages such as C++ allow two orthogonal syntax start/end pairs
+ and bit 6 is used to determine whether a comment-end or Scommentend
+ ends style a or b. Comment markers can start style a, b, c, or bc.
+ Style a is always the default.
+ For 2-char comment markers, the style b flag is only looked up on the second
+ char of the comment marker and on the first char of the comment ender.
+ For style c (like to for the nested flag), the flag can be placed on any
+ one of the chars.
+ */
+
+/* These macros extract specific flags from an integer
+ that holds the syntax code and the flags. */
+
+#define SYNTAX_FLAGS_COMSTART_FIRST(flags) (((flags) >> 16) & 1)
+
+#define SYNTAX_FLAGS_COMSTART_SECOND(flags) (((flags) >> 17) & 1)
+
+#define SYNTAX_FLAGS_COMEND_FIRST(flags) (((flags) >> 18) & 1)
+
+#define SYNTAX_FLAGS_COMEND_SECOND(flags) (((flags) >> 19) & 1)
+
+#define SYNTAX_FLAGS_PREFIX(flags) (((flags) >> 20) & 1)
+
+#define SYNTAX_FLAGS_COMMENT_STYLEB(flags) (((flags) >> 21) & 1)
+#define SYNTAX_FLAGS_COMMENT_STYLEC(flags) (((flags) >> 22) & 2)
+/* FLAGS should be the flags of the main char of the comment marker, e.g.
+ the second for comstart and the first for comend. */
+#define SYNTAX_FLAGS_COMMENT_STYLE(flags, other_flags) \
+ (SYNTAX_FLAGS_COMMENT_STYLEB (flags) \
+ | SYNTAX_FLAGS_COMMENT_STYLEC (flags) \
+ | SYNTAX_FLAGS_COMMENT_STYLEC (other_flags))
+
+#define SYNTAX_FLAGS_COMMENT_NESTED(flags) (((flags) >> 22) & 1)
+
+/* These macros extract a particular flag for a given character. */
+
+#define SYNTAX_COMEND_FIRST(c) \
+ (SYNTAX_FLAGS_COMEND_FIRST (SYNTAX_WITH_FLAGS (c)))
+#define SYNTAX_PREFIX(c) (SYNTAX_FLAGS_PREFIX (SYNTAX_WITH_FLAGS (c)))