aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-02-17 14:50:07 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-02-17 14:50:07 +0100
commitb091d8b4f34efe653b10bf681df6491ddb993527 (patch)
treeb1edcaf5055b5a97e9d8c280fb83c590a6645f19
parent6efa2ebd0e44b758740120374d63874beda7ba6a (diff)
downloadsciteco-b091d8b4f34efe653b10bf681df6491ddb993527.tar.gz
The "cpp" lexer configuration has been split into "c.tes" and "cpp.tes"
* The keyword list is too different in C when compared to C++. The many additional keywords are annoying when editing plain C files. * Underscored C99 and C11 keywords (like _Bool) have been added to the "c.tes" lexer configuration. The C++ language does not contain these keywords. However, C has stdbool.h to define bool which is part of standard C++. * Therefore a macro "lexer.c.basekeywords" has been defined for all languages __directly__ derived (more or less supersets) of C. It contains most of the C99/C11 standard header shortcuts. * Objective C lexing is set up by c.tes since Objective C is a relatively strict superset of C. All Objective C keywords are handled by c.tes. Since they begin with "@", this should not cause problems when editing plain C files.
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/lexers/c.tes53
-rw-r--r--lib/lexers/cpp.tes33
3 files changed, 64 insertions, 23 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5aec511..4cbb27c 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -49,6 +49,7 @@ dist_lexer_DATA = lexers/verilog.tes \
lexers/freebasic.tes \
lexers/xml.tes \
lexers/asl.tes \
+ lexers/c.tes \
lexers/cpp.tes \
lexers/test.tes \
lexers/kix.tes \
diff --git a/lib/lexers/c.tes b/lib/lexers/c.tes
new file mode 100644
index 0000000..3dd3d95
--- /dev/null
+++ b/lib/lexers/c.tes
@@ -0,0 +1,53 @@
+!*
+ * C/ObjectiveC Lexing: Supports all keywords of C11 and treats
+ * most standard library macros for underscore-keywords like normal
+ * keywords.
+ * Header files (*.h) are handled by the "cpp" configuration
+ * since C/C++/ObjectiveC headers cannot be discerned.
+ *!
+
+@[lexer.test.c]{
+ :EN*.cQ*"S -1 '
+ :EN*.mQ*"S -1 '
+ :EN*.mmQ*
+}
+
+!* Keywords used by all languages directly derived from C *!
+[lexer.c.basekeywords]
+ alignas alignof asm auto bool break case char complex const continue
+ default do double else enum extern false float for goto
+ if imaginary inline int long noreturn register restrict return
+ short signed sizeof static static_assert struct switch
+ true typedef union unsigned void volatile wchar_t while
+!* Doxygen keywords *!
+[lexer.c.doxygenkeywords]
+ a addindex addtogroup anchor arg attention author b brief bug c class code
+ date def defgroup deprecated dontinclude e em endcode endhtmlonly endif
+ endlatexonly endlink endverbatim enum example exception f$ f[ f] file fn hideinitializer
+ htmlinclude htmlonly if image include ingroup internal invariant interface latexonly li
+ line link mainpage name namespace nosubgrouping note overload p page par param
+ param[in] param[out] post pre ref relates remarks return retval sa section see
+ showinitializer since skip skipline struct subsection test throw throws todo typedef union
+ until var verbatim verbinclude version warning weakgroup $ @ \ & < > # { }
+
+@[lexer.set.c]{
+ ESSETLEXERLANGUAGEcpp
+ 0ESSETKEYWORDS
+ Q[lexer.c.basekeywords] _Alignas _Alignof _Atomic
+ _Bool _Complex _Generic _Imaginary _Noreturn _Static_assert _Thread_local
+ @class @defs @protocol @required @optional @end @interface
+ @public @package @protected @private @property @implementation @synthesize @dynamic
+ @throw @try @catch @finally @synchronized @autoreleasepool @selector @encode
+ @compatibility_alias
+ ! Doxygen keywords !
+ 2ESSETKEYWORDSQ[lexer.c.doxygenkeywords]
+ :M[color.comment],1M[color.set]
+ :M[color.comment],2M[color.set]
+ :M[color.comment],3M[color.set]
+ :M[color.number],4M[color.set]
+ :M[color.keyword],5M[color.set]
+ :M[color.string],6M[color.set]
+ :M[color.string],7M[color.set]
+ :M[color.preproc],9M[color.set]
+ :M[color.operator],10M[color.set]
+}
diff --git a/lib/lexers/cpp.tes b/lib/lexers/cpp.tes
index 4a3a181..851e82a 100644
--- a/lib/lexers/cpp.tes
+++ b/lib/lexers/cpp.tes
@@ -1,7 +1,9 @@
-! C/C++ Lexing !
+!*
+ * C++ Lexing: Also used for all *.h headers since
+ * they cannot be distinguished.
+ *!
@[lexer.test.cpp]{
- :EN*.cQ*"S -1 '
:EN*.ccQ*"S -1 '
:EN*.cppQ*"S -1 '
:EN*.cxxQ*"S -1 '
@@ -10,34 +12,19 @@
:EN*.hppQ*"S -1 '
:EN*.hxxQ*"S -1 '
:EN*.ippQ*"S -1 '
- :EN*.mQ*"S -1 '
- :EN*.mmQ*"S -1 '
:EN*.smaQ*
}
@[lexer.set.cpp]{
ESSETLEXERLANGUAGEcpp
0ESSETKEYWORDS
- and and_eq asm auto bitand bitor bool break case catch char class compl
- const const_cast constexpr continue default delete do double dynamic_cast else
- enum explicit export extern false float for friend goto if inline int long
- mutable namespace new not not_eq operator or or_eq private protected public register
- reinterpret_cast return short signed sizeof static static_cast struct switch template this
- throw true try typedef typeid typename union unsigned using virtual void volatile
- wchar_t while xor xor_eq @class @defs @protocol @required @optional @end @interface
- @public @package @protected @private @property @implementation @synthesize @dynamic
- @throw @try @catch @finally @synchronized @autoreleasepool @selector @encode
- @compatibility_alias
+ Q[lexer.c.basekeywords]
+ and and_eq bitand bitor catch class compl const_cast constexpr delete dynamic_cast
+ explicit export friend mutable namespace new not not_eq operator or or_eq
+ private protected public reinterpret_cast static_cast template this
+ throw try typeid typename using virtual xor xor_eq
! Doxygen keywords !
- 2ESSETKEYWORDS
- a addindex addtogroup anchor arg attention author b brief bug c class code
- date def defgroup deprecated dontinclude e em endcode endhtmlonly endif
- endlatexonly endlink endverbatim enum example exception f$ f[ f] file fn hideinitializer
- htmlinclude htmlonly if image include ingroup internal invariant interface latexonly li
- line link mainpage name namespace nosubgrouping note overload p page par param
- param[in] param[out] post pre ref relates remarks return retval sa section see
- showinitializer since skip skipline struct subsection test throw throws todo typedef union
- until var verbatim verbinclude version warning weakgroup $ @ \ & < > # { }
+ 2ESSETKEYWORDSQ[lexer.c.doxygenkeywords]
:M[color.comment],1M[color.set]
:M[color.comment],2M[color.set]
:M[color.comment],3M[color.set]