Matthew Brush:
> It would also be useful (for more reasons than this) if the styles could be introspected at runtime, then applications could be coded to decide what to do based on the set of styles available.
Perhaps this, allowing both runtime introspection and build-time tools to grab the block started with LexicalClass.
/*
26 Tags: Less useful marked with '~'.
character
comment
default
documentation
eol
error
escapesequence
~globalclass
hash
identifier
keyword
line
literal
multiline
numeric
operator
preprocessor
quoted
~raw
regex
string
~taskmarker
~triple
user
uuid
~verbatim
Others that may be useful:
obsolete
unicode/wide/narrow
interpolated
*/
LexicalClass lexicalClasses[] = {
0, "SCE_C_DEFAULT", "default",
1, "SCE_C_COMMENT", "comment",
2, "SCE_C_COMMENTLINE", "comment line",
3, "SCE_C_COMMENTDOC", "comment documentation",
4, "SCE_C_NUMBER", "literal numeric",
5, "SCE_C_WORD", "keyword",
6, "SCE_C_STRING", "literal quoted string",
7, "SCE_C_CHARACTER", "literal quoted string character",
8, "SCE_C_UUID", "literal quoted uuid",
9, "SCE_C_PREPROCESSOR", "preprocessor",
10, "SCE_C_OPERATOR", "operator",
11, "SCE_C_IDENTIFIER", "identifier",
12, "SCE_C_STRINGEOL", "error string eol",
13, "SCE_C_VERBATIM", "literal quoted string multiline verbatim",
14, "SCE_C_REGEX", "literal quoted regex",
15, "SCE_C_COMMENTLINEDOC", "comment line documentation",
16, "SCE_C_WORD2", "keyword",
17, "SCE_C_COMMENTDOCKEYWORD", "comment documentation keyword",
18, "SCE_C_COMMENTDOCKEYWORDERROR", "error comment documentation keyword",
19, "SCE_C_GLOBALCLASS", "identifier globalclass",
20, "SCE_C_STRINGRAW", "literal quoted string multiline raw",
21, "SCE_C_TRIPLEVERBATIM", "literal quoted string multiline triple",
22, "SCE_C_HASHQUOTEDSTRING", "literal quoted string multiline hash",
23, "SCE_C_PREPROCESSORCOMMENT", "preprocessor comment",
24, "SCE_C_PREPROCESSORCOMMENTDOC", "preprocessor comment documentation",
25, "SCE_C_USERLITERAL", "literal user",
26, "SCE_C_TASKMARKER", "comment taskmarker",
27, "SCE_C_ESCAPESEQUENCE", "literal quoted string escapesequence",
};
// ILexer additions:
int SCI_METHOD LexerCPP::MaximumNamedStyle() {
return (sizeof(lexicalClasses) / sizeof(lexicalClasses[0]))-1;
}
const char * SCI_METHOD LexerCPP::NameOfStyle(int style) {
return lexicalClasses[style].name;
}
const char * SCI_METHOD LexerCPP::DescriptionOfStyle(int style) {
return lexicalClasses[style].description;
}
The style words were ordered to match my sense of how I’d want styling: error goes first so that it strongly matches and so shows distinctly (if error is defined at all) instead of inheriting from the parent style and hence appear invisible if that particular sequence doesn’t have a defined appearance.
There could be both informal (candidates for list boxes) and formal parts of the description:
8, "SCE_C_UUID", “IDL UUID like uuid(ba209999-0c6c-11d2-97cf-00c04f8eea45)[literal quoted uuid]",
21, "SCE_C_TRIPLEVERBATIM", “Vala \”\”\"triple-quoted\”\”\" strings[literal quoted string multiline triple]”,
Using strings can result in misspellings but its likely that symbolication will be uglier and not extensible.
Neil