1 # -*- coding: utf-8 -*- |
1 # -*- coding: utf-8 -*- |
2 """ |
2 """ |
3 pygments.lexers.webidl |
3 pygments.lexers.webidl |
4 ~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Lexers for Web IDL, including some extensions. |
6 Lexers for Web IDL, including some extensions. |
7 |
7 |
8 :copyright: Copyright 2006-2016 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
10 """ |
10 """ |
11 |
11 |
12 from pygments.lexer import RegexLexer, default, include, words |
12 from pygments.lexer import RegexLexer, default, include, words |
13 from pygments.token import Comment, Keyword, Name, Number, Punctuation, \ |
13 from pygments.token import Comment, Keyword, Name, Number, Punctuation, \ |
30 # buffer source types |
30 # buffer source types |
31 'ArrayBuffer', 'DataView', 'Int8Array', 'Int16Array', 'Int32Array', |
31 'ArrayBuffer', 'DataView', 'Int8Array', 'Int16Array', 'Int32Array', |
32 # other |
32 # other |
33 'any', 'void', 'object', 'RegExp', |
33 'any', 'void', 'object', 'RegExp', |
34 ) |
34 ) |
35 _identifier = r'_?[A-Za-z][0-9A-Z_a-z-]*' |
35 _identifier = r'_?[A-Za-z][a-zA-Z0-9_-]*' |
36 _keyword_suffix = r'(?![\w-])' |
36 _keyword_suffix = r'(?![\w-])' |
37 _string = r'"[^"]*"' |
37 _string = r'"[^"]*"' |
|
38 |
38 |
39 |
39 class WebIDLLexer(RegexLexer): |
40 class WebIDLLexer(RegexLexer): |
40 """ |
41 """ |
41 For Web IDL. |
42 For Web IDL. |
42 |
43 |
130 'type_identifier': [ |
131 'type_identifier': [ |
131 (r'<', Punctuation, 'type_list'), |
132 (r'<', Punctuation, 'type_list'), |
132 default(('#pop', 'type_null')) |
133 default(('#pop', 'type_null')) |
133 ], |
134 ], |
134 'type_null': [ |
135 'type_null': [ |
135 (r'\??', Punctuation, '#pop:2'), |
136 (r'\?', Punctuation), |
|
137 default('#pop:2'), |
136 ], |
138 ], |
137 'default_value': [ |
139 'default_value': [ |
138 include('common'), |
140 include('common'), |
139 include('const_value'), |
141 include('const_value'), |
140 (_string, String, '#pop'), |
142 (_string, String, '#pop'), |