3 pygments.token |
3 pygments.token |
4 ~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~ |
5 |
5 |
6 Basic token types and the standard tokens. |
6 Basic token types and the standard tokens. |
7 |
7 |
8 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2017 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 |
12 class _TokenType(tuple): |
13 class _TokenType(tuple): |
13 parent = None |
14 parent = None |
14 |
15 |
15 def split(self): |
16 def split(self): |
50 def __deepcopy__(self, memo): |
51 def __deepcopy__(self, memo): |
51 # These instances are supposed to be singletons |
52 # These instances are supposed to be singletons |
52 return self |
53 return self |
53 |
54 |
54 |
55 |
55 Token = _TokenType() |
56 Token = _TokenType() |
56 |
57 |
57 # Special token types |
58 # Special token types |
58 Text = Token.Text |
59 Text = Token.Text |
59 Whitespace = Text.Whitespace |
60 Whitespace = Text.Whitespace |
60 Escape = Token.Escape |
61 Escape = Token.Escape |
61 Error = Token.Error |
62 Error = Token.Error |
62 # Text that doesn't belong to this lexer (e.g. HTML in PHP) |
63 # Text that doesn't belong to this lexer (e.g. HTML in PHP) |
63 Other = Token.Other |
64 Other = Token.Other |
64 |
65 |
65 # Common token types for source code |
66 # Common token types for source code |
66 Keyword = Token.Keyword |
67 Keyword = Token.Keyword |
67 Name = Token.Name |
68 Name = Token.Name |
68 Literal = Token.Literal |
69 Literal = Token.Literal |
69 String = Literal.String |
70 String = Literal.String |
70 Number = Literal.Number |
71 Number = Literal.Number |
71 Punctuation = Token.Punctuation |
72 Punctuation = Token.Punctuation |
72 Operator = Token.Operator |
73 Operator = Token.Operator |
73 Comment = Token.Comment |
74 Comment = Token.Comment |
74 |
75 |
75 # Generic types for non-source code |
76 # Generic types for non-source code |
76 Generic = Token.Generic |
77 Generic = Token.Generic |
77 |
78 |
78 # String and some others are not direct childs of Token. |
79 # String and some others are not direct children of Token. |
79 # alias them: |
80 # alias them: |
80 Token.Token = Token |
81 Token.Token = Token |
81 Token.String = String |
82 Token.String = String |
82 Token.Number = Number |
83 Token.Number = Number |
83 |
84 |
145 Name.Constant: 'no', |
146 Name.Constant: 'no', |
146 Name.Decorator: 'nd', |
147 Name.Decorator: 'nd', |
147 Name.Entity: 'ni', |
148 Name.Entity: 'ni', |
148 Name.Exception: 'ne', |
149 Name.Exception: 'ne', |
149 Name.Function: 'nf', |
150 Name.Function: 'nf', |
|
151 Name.Function.Magic: 'fm', |
150 Name.Property: 'py', |
152 Name.Property: 'py', |
151 Name.Label: 'nl', |
153 Name.Label: 'nl', |
152 Name.Namespace: 'nn', |
154 Name.Namespace: 'nn', |
153 Name.Other: 'nx', |
155 Name.Other: 'nx', |
154 Name.Tag: 'nt', |
156 Name.Tag: 'nt', |
155 Name.Variable: 'nv', |
157 Name.Variable: 'nv', |
156 Name.Variable.Class: 'vc', |
158 Name.Variable.Class: 'vc', |
157 Name.Variable.Global: 'vg', |
159 Name.Variable.Global: 'vg', |
158 Name.Variable.Instance: 'vi', |
160 Name.Variable.Instance: 'vi', |
|
161 Name.Variable.Magic: 'vm', |
159 |
162 |
160 Literal: 'l', |
163 Literal: 'l', |
161 Literal.Date: 'ld', |
164 Literal.Date: 'ld', |
162 |
165 |
163 String: 's', |
166 String: 's', |
|
167 String.Affix: 'sa', |
164 String.Backtick: 'sb', |
168 String.Backtick: 'sb', |
165 String.Char: 'sc', |
169 String.Char: 'sc', |
|
170 String.Delimiter: 'dl', |
166 String.Doc: 'sd', |
171 String.Doc: 'sd', |
167 String.Double: 's2', |
172 String.Double: 's2', |
168 String.Escape: 'se', |
173 String.Escape: 'se', |
169 String.Heredoc: 'sh', |
174 String.Heredoc: 'sh', |
170 String.Interpol: 'si', |
175 String.Interpol: 'si', |