diff options
author | Matthew Fernandez <matthew.fernandez@gmail.com> | 2016-03-17 11:00:16 +1100 |
---|---|---|
committer | Matthew Fernandez <matthew.fernandez@gmail.com> | 2016-03-17 11:00:16 +1100 |
commit | ce020b9178a3d90194454d09667252587c6face5 (patch) | |
tree | f2d3ec80952de819328b6a27e27140078ddd1305 /pygments/lexers/c_cpp.py | |
parent | fa808ea5895583bad5318b8aae23025afa6d8040 (diff) | |
download | pygments-ce020b9178a3d90194454d09667252587c6face5.tar.gz |
Add 'asm' as a C keyword.
The C standards allow the use of inline assembly with the `asm` keyword (see
?J.5.10 of C99 for example). This commit adds 'asm' as a supported keyword to
the base C lexer, `CFamilyLexer`, and removes it from `CppLexer` which inherits
from this base. The intended effect is supporting the `asm` keyword for the C
lexer, while leaving the behaviour of the C++ lexer identical.
Side-effects of adding this keyword are that 'asm' is now also supported as a
keyword in the following lexers:
- CUDA. Inline PTX assembler is supported in CUDA with this syntax, so this is
correct.
- eC. It claims to be a superset of C, so this is correct.
- nesC. As far as I can tell, nesC supports inline assembly through the same
syntax, so this is correct.
- Objective-C. I believe inline assembly is supported in Objective-C, but
using the keyword `__asm__` instead, so this is somewhat incorrect. However,
note that the Objective-C++ lexer currently incorrectly supports `asm` as
well.
Closes #1219
Diffstat (limited to 'pygments/lexers/c_cpp.py')
-rw-r--r-- | pygments/lexers/c_cpp.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/pygments/lexers/c_cpp.py b/pygments/lexers/c_cpp.py index 632871ba..a8d75c0a 100644 --- a/pygments/lexers/c_cpp.py +++ b/pygments/lexers/c_cpp.py @@ -61,10 +61,11 @@ class CFamilyLexer(RegexLexer): (r'\*/', Error), (r'[~!%^&*+=|?:<>/-]', Operator), (r'[()\[\],.]', Punctuation), - (words(('auto', 'break', 'case', 'const', 'continue', 'default', 'do', - 'else', 'enum', 'extern', 'for', 'goto', 'if', 'register', - 'restricted', 'return', 'sizeof', 'static', 'struct', - 'switch', 'typedef', 'union', 'volatile', 'while'), + (words(('asm', 'auto', 'break', 'case', 'const', 'continue', + 'default', 'do', 'else', 'enum', 'extern', 'for', 'goto', + 'if', 'register', 'restricted', 'return', 'sizeof', + 'static', 'struct', 'switch', 'typedef', 'union', + 'volatile', 'while'), suffix=r'\b'), Keyword), (r'(bool|int|long|float|short|double|char|unsigned|signed|void)\b', Keyword.Type), @@ -208,7 +209,7 @@ class CppLexer(CFamilyLexer): tokens = { 'statements': [ (words(( - 'asm', 'catch', 'const_cast', 'delete', 'dynamic_cast', 'explicit', + 'catch', 'const_cast', 'delete', 'dynamic_cast', 'explicit', 'export', 'friend', 'mutable', 'namespace', 'new', 'operator', 'private', 'protected', 'public', 'reinterpret_cast', 'restrict', 'static_cast', 'template', 'this', 'throw', 'throws', |