Comment String Label and Macro Symbols
A few miscellaneous syntactic symbols that haven’t been previously covered are illustrated by this C++ example:
bash
1: void Bass::play( int volume )
2: const
3: {
4: /* this line starts a multiline
5: * comment. This line should get 'c' syntax */
6:
7: char* a_multiline_string = "This line starts a multiline \
8: string. This line should get 'string' syntax.";
9:
10: note:
11: {
12: #ifdef LOCK
13: Lock acquire();
14: #endif // LOCK
15: slap_pop();
16: cout << "I played "
17: << "a note\n";
18: }
19: }The lines to note in this example include:
- Line 2 is assigned the
func-decl-contsyntax. - Line 4 is assigned both
defun-block-introandcomment-introsyntax. A syntactic element withcomment-introhas no anchor point. It is always accompanied by another syntactic element which does have one. - Line 5 is assigned
csyntax. - Line 6 which, even though it contains nothing but whitespace, is assigned
defun-block-intro. Note that the appearance of the comment on lines 4 and 5 do not cause line 6 to be assignedstatementsyntax because comments are considered to be syntactic whitespace, which are ignored when analyzing code. - Line 8 is assigned
stringsyntax. - Line 10 is assigned
labelsyntax. - Line 11 is assigned
block-openas well asstatementsyntax. Ablock-opensyntactic element doesn’t have an anchor position, since it always appears with another syntactic element which does have one. - Lines 12 and 14 are assigned
cpp-macrosyntax in addition to the normal syntactic symbols (statement-block-introandstatement, respectively). Normallycpp-macrois configured to cancel out the normal syntactic context to make all preprocessor directives stick to the first column, but that’s easily changed if you want preprocessor directives to be indented like the rest of the code. Likecomment-intro, a syntactic element withcpp-macrodoesn’t contain an anchor position. - Line 17 is assigned
stream-opsyntax.