-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(objectivec) Sync preprocessor highlighting with cpp (#2265)
The objectivec highlighting had a few bugs and was missing a few features: - Expressions with < were misidentified as a string like <stdio.h> (fixes #1964). - Keywords like if, else, endif, etc. were not highlighted. - The escape sequences in string literals were not parsed. - Line continuations were not parsed. - Comments were not parsed. Fix all these by adapting cpp's preprocessor definition. Pull in the preprocessor test from cpp. (This is actually objectivec's first markup test. It probably could do with tests beyond just this feature.)
- Loading branch information
1 parent
5ef8249
commit 980ac21
Showing
7 changed files
with
67 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string"><iostream></span></span> | ||
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> foo 1<<16</span> | ||
|
||
<span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> DEBUG</span> | ||
TYPE1 foo(<span class="hljs-keyword">void</span>) | ||
<span class="hljs-meta">#<span class="hljs-meta-keyword">else</span></span> | ||
<span class="hljs-keyword">int</span> foo(<span class="hljs-keyword">void</span>) | ||
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span> | ||
{ } | ||
|
||
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> x(v) ((v))</span> | ||
<span class="hljs-meta"># <span class="hljs-meta-keyword">define</span> x(v) ((v))</span> | ||
<span class="hljs-meta"># <span class="hljs-meta-keyword">define</span> x(v) ((v))</span> | ||
|
||
<span class="hljs-meta">#<span class="hljs-meta-keyword">if</span> MACRO_WITH_STRING_ARG(<span class="hljs-meta-string">"hello \"world\""</span>)</span> | ||
<span class="hljs-meta">#<span class="hljs-meta-keyword">elif</span> MULTI_LINE <span class="hljs-comment">/* comment */</span> < \ | ||
EXPRESSION</span> | ||
<span class="hljs-keyword">int</span> bar; | ||
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span> <span class="hljs-comment">// comment</span></span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <iostream> | ||
#define foo 1<<16 | ||
|
||
#ifdef DEBUG | ||
TYPE1 foo(void) | ||
#else | ||
int foo(void) | ||
#endif | ||
{ } | ||
|
||
#define x(v) ((v)) | ||
# define x(v) ((v)) | ||
# define x(v) ((v)) | ||
|
||
#if MACRO_WITH_STRING_ARG("hello \"world\"") | ||
#elif MULTI_LINE /* comment */ < \ | ||
EXPRESSION | ||
int bar; | ||
#endif // comment |