diff options
author | Georg Brandl <georg@python.org> | 2019-11-29 06:09:43 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2019-11-29 06:12:04 +0100 |
commit | 50793de1862a78f36617d9b966d437c72b27a95c (patch) | |
tree | 0273b197cc366d4277e0794c8dc199fc15885f7b /pygments/lexers/zig.py | |
parent | 6e215c121f067a4a7d1270dc17526f224ec6bbad (diff) | |
download | pygments-git-50793de1862a78f36617d9b966d437c72b27a95c.tar.gz |
various: style fixups
Diffstat (limited to 'pygments/lexers/zig.py')
-rw-r--r-- | pygments/lexers/zig.py | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/pygments/lexers/zig.py b/pygments/lexers/zig.py index 7850fdf0..c9893862 100644 --- a/pygments/lexers/zig.py +++ b/pygments/lexers/zig.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ pygments.lexers.zig - ~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ Lexers for Zig. @@ -9,13 +9,13 @@ :license: BSD, see LICENSE for details. """ -import re -from pygments.lexer import RegexLexer, bygroups, include, words -from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ - Number, Punctuation, Error, Whitespace +from pygments.lexer import RegexLexer, words +from pygments.token import Comment, Operator, Keyword, Name, String, \ + Number, Punctuation, Whitespace __all__ = ['ZigLexer'] + class ZigLexer(RegexLexer): """ For `Zig <http://www.ziglang.org>`_ source code. @@ -28,13 +28,14 @@ class ZigLexer(RegexLexer): mimetypes = ['text/zig'] type_keywords = ( - words(('bool', 'f16', 'f32', 'f64', 'f128', 'void', 'noreturn', 'type', 'anyerror', 'promise', - 'i0', 'u0', 'isize', 'usize', 'comptime_int', 'comptime_float', - 'c_short', 'c_ushort', 'c_int', 'c_uint', 'c_long', 'c_ulong', 'c_longlong', 'c_ulonglong', 'c_longdouble', 'c_void' - 'i8', 'u8', 'i16', 'u16', 'i32', 'u32', 'i64', 'u64', 'i128', 'u128' - ), suffix=r'\b'), + words(('bool', 'f16', 'f32', 'f64', 'f128', 'void', 'noreturn', 'type', + 'anyerror', 'promise', 'i0', 'u0', 'isize', 'usize', 'comptime_int', + 'comptime_float', 'c_short', 'c_ushort', 'c_int', 'c_uint', 'c_long', + 'c_ulong', 'c_longlong', 'c_ulonglong', 'c_longdouble', 'c_void' + 'i8', 'u8', 'i16', 'u16', 'i32', 'u32', 'i64', 'u64', 'i128', + 'u128'), suffix=r'\b'), Keyword.Type) - + storage_keywords = ( words(('const', 'var', 'extern', 'packed', 'export', 'pub', 'noalias', 'inline', 'comptime', 'nakedcc', 'stdcallcc', 'volatile', 'allowzero', @@ -46,8 +47,8 @@ class ZigLexer(RegexLexer): Keyword) statement_keywords = ( - words(('break', 'return', 'continue', 'asm', 'defer', 'errdefer', - 'unreachable', 'try', 'catch', 'async', 'await', 'suspend', + words(('break', 'return', 'continue', 'asm', 'defer', 'errdefer', + 'unreachable', 'try', 'catch', 'async', 'await', 'suspend', 'resume', 'cancel'), suffix=r'\b'), Keyword) @@ -74,7 +75,7 @@ class ZigLexer(RegexLexer): (r'//.*?\n', Comment.Single), # Keywords - statement_keywords, + statement_keywords, storage_keywords, structure_keywords, repeat_keywords, @@ -96,25 +97,27 @@ class ZigLexer(RegexLexer): (r'[0-9]+', Number.Integer), # Identifier - (r'@[a-zA-Z_]\w*',Name.Builtin), + (r'@[a-zA-Z_]\w*', Name.Builtin), (r'[a-zA-Z_]\w*', Name), # Characters (r'\'\\\'\'', String.Escape), - (r'\'\\(|x[a-fA-F0-9]{2}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{6}|[nr\\t\'"])\'', String.Escape), + (r'\'\\(|x[a-fA-F0-9]{2}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{6}|[nr\\t\'"])\'', + String.Escape), (r'\'[^\\\']\'', String), # Strings (r'\\\\[^\n]*', String.Heredoc), (r'c\\\\[^\n]*', String.Heredoc), - (r'c?"',String, 'string'), + (r'c?"', String, 'string'), # Operators, Punctuation (r'[+%=><|^!?/\-*&~:]', Operator), (r'[{}()\[\],.;]', Punctuation) ], 'string': [ - (r'\\(x[a-fA-F0-9]{2}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{6}|[nr\\t\'"])', String.Escape), + (r'\\(x[a-fA-F0-9]{2}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{6}|[nr\\t\'"])', + String.Escape), (r'[^\\"\n]+', String), (r'"', String, '#pop') ] |