eric6/ThirdParty/Pygments/pygments/lexers/prolog.py

changeset 7547
21b0534faebc
parent 6942
2602857055c5
child 7701
25f42e208e08
equal deleted inserted replaced
7546:bf5f777260a6 7547:21b0534faebc
3 pygments.lexers.prolog 3 pygments.lexers.prolog
4 ~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for Prolog and Prolog-like languages. 6 Lexers for Prolog and Prolog-like languages.
7 7
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2019 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 import re 12 import re
13 13
29 29
30 flags = re.UNICODE | re.MULTILINE 30 flags = re.UNICODE | re.MULTILINE
31 31
32 tokens = { 32 tokens = {
33 'root': [ 33 'root': [
34 (r'^#.*', Comment.Single),
35 (r'/\*', Comment.Multiline, 'nested-comment'), 34 (r'/\*', Comment.Multiline, 'nested-comment'),
36 (r'%.*', Comment.Single), 35 (r'%.*', Comment.Single),
37 # character literal 36 # character literal
38 (r'0\'.', String.Char), 37 (r'0\'.', String.Char),
39 (r'0b[01]+', Number.Bin), 38 (r'0b[01]+', Number.Bin),
106 (r'/\*(.|\n)*?\*/', Comment), 105 (r'/\*(.|\n)*?\*/', Comment),
107 # Whitespace 106 # Whitespace
108 (r'\n', Text), 107 (r'\n', Text),
109 (r'\s+', Text), 108 (r'\s+', Text),
110 # Numbers 109 # Numbers
111 (r"0'.", Number), 110 (r"0'[\\]?.", Number),
112 (r'0b[01]+', Number.Bin), 111 (r'0b[01]+', Number.Bin),
113 (r'0o[0-7]+', Number.Oct), 112 (r'0o[0-7]+', Number.Oct),
114 (r'0x[0-9a-fA-F]+', Number.Hex), 113 (r'0x[0-9a-fA-F]+', Number.Hex),
115 (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number), 114 (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
116 # Variables 115 # Variables
117 (r'([A-Z_]\w*)', Name.Variable), 116 (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
118 # Event handlers 117 # Event handlers
119 (r'(after|before)(?=[(])', Keyword), 118 (r'(after|before)(?=[(])', Keyword),
120 # Message forwarding handler 119 # Message forwarding handler
121 (r'forward(?=[(])', Keyword), 120 (r'forward(?=[(])', Keyword),
122 # Execution-context methods 121 # Execution-context methods
123 (r'(parameter|this|se(lf|nder))(?=[(])', Keyword), 122 (r'(context|parameter|this|se(lf|nder))(?=[(])', Keyword),
124 # Reflection 123 # Reflection
125 (r'(current_predicate|predicate_property)(?=[(])', Keyword), 124 (r'(current_predicate|predicate_property)(?=[(])', Keyword),
126 # DCGs and term expansion 125 # DCGs and term expansion
127 (r'(expand_(goal|term)|(goal|term)_expansion|phrase)(?=[(])', Keyword), 126 (r'(expand_(goal|term)|(goal|term)_expansion|phrase)(?=[(])', Keyword),
128 # Entity 127 # Entity
134 (r'imp(lements_protocol|orts_category)(?=[(])', Keyword), 133 (r'imp(lements_protocol|orts_category)(?=[(])', Keyword),
135 (r'(instantiat|specializ)es_class(?=[(])', Keyword), 134 (r'(instantiat|specializ)es_class(?=[(])', Keyword),
136 # Events 135 # Events
137 (r'(current_event|(abolish|define)_events)(?=[(])', Keyword), 136 (r'(current_event|(abolish|define)_events)(?=[(])', Keyword),
138 # Flags 137 # Flags
139 (r'(current|set)_logtalk_flag(?=[(])', Keyword), 138 (r'(create|current|set)_logtalk_flag(?=[(])', Keyword),
140 # Compiling, loading, and library paths 139 # Compiling, loading, and library paths
141 (r'logtalk_(compile|l(ibrary_path|oad|oad_context)|make)(?=[(])', Keyword), 140 (r'logtalk_(compile|l(ibrary_path|oad|oad_context)|make(_target_action)?)(?=[(])', Keyword),
142 (r'\blogtalk_make\b', Keyword), 141 (r'\blogtalk_make\b', Keyword),
143 # Database 142 # Database
144 (r'(clause|retract(all)?)(?=[(])', Keyword), 143 (r'(clause|retract(all)?)(?=[(])', Keyword),
145 (r'a(bolish|ssert(a|z))(?=[(])', Keyword), 144 (r'a(bolish|ssert(a|z))(?=[(])', Keyword),
146 # Control constructs 145 # Control constructs
147 (r'(ca(ll|tch)|throw)(?=[(])', Keyword), 146 (r'(ca(ll|tch)|throw)(?=[(])', Keyword),
148 (r'(fa(il|lse)|true)\b', Keyword), 147 (r'(fa(il|lse)|true|(instantiation|system)_error)\b', Keyword),
148 (r'(type|domain|existence|permission|representation|evaluation|resource|syntax)_error(?=[(])', Keyword),
149 # All solutions 149 # All solutions
150 (r'((bag|set)of|f(ind|or)all)(?=[(])', Keyword), 150 (r'((bag|set)of|f(ind|or)all)(?=[(])', Keyword),
151 # Multi-threading meta-predicates 151 # Multi-threading predicates
152 (r'threaded(_(call|once|ignore|exit|peek|wait|notify))?(?=[(])', Keyword), 152 (r'threaded(_(ca(ll|ncel)|once|ignore|exit|peek|wait|notify))?(?=[(])', Keyword),
153 # Engine predicates
154 (r'threaded_engine(_(create|destroy|self|next|next_reified|yield|post|fetch))?(?=[(])', Keyword),
153 # Term unification 155 # Term unification
154 (r'(subsumes_term|unify_with_occurs_check)(?=[(])', Keyword), 156 (r'(subsumes_term|unify_with_occurs_check)(?=[(])', Keyword),
155 # Term creation and decomposition 157 # Term creation and decomposition
156 (r'(functor|arg|copy_term|numbervars|term_variables)(?=[(])', Keyword), 158 (r'(functor|arg|copy_term|numbervars|term_variables)(?=[(])', Keyword),
157 # Evaluable functors 159 # Evaluable functors
159 (r'float(_(integer|fractional)_part)?(?=[(])', Keyword), 161 (r'float(_(integer|fractional)_part)?(?=[(])', Keyword),
160 (r'(floor|t(an|runcate)|round|ceiling)(?=[(])', Keyword), 162 (r'(floor|t(an|runcate)|round|ceiling)(?=[(])', Keyword),
161 # Other arithmetic functors 163 # Other arithmetic functors
162 (r'(cos|a(cos|sin|tan|tan2)|exp|log|s(in|qrt)|xor)(?=[(])', Keyword), 164 (r'(cos|a(cos|sin|tan|tan2)|exp|log|s(in|qrt)|xor)(?=[(])', Keyword),
163 # Term testing 165 # Term testing
164 (r'(var|atom(ic)?|integer|float|c(allable|ompound)|n(onvar|umber)|' 166 (r'(var|atom(ic)?|integer|float|c(allable|ompound)|n(onvar|umber)|ground|acyclic_term)(?=[(])', Keyword),
165 r'ground|acyclic_term)(?=[(])', Keyword),
166 # Term comparison 167 # Term comparison
167 (r'compare(?=[(])', Keyword), 168 (r'compare(?=[(])', Keyword),
168 # Stream selection and control 169 # Stream selection and control
169 (r'(curren|se)t_(in|out)put(?=[(])', Keyword), 170 (r'(curren|se)t_(in|out)put(?=[(])', Keyword),
170 (r'(open|close)(?=[(])', Keyword), 171 (r'(open|close)(?=[(])', Keyword),
225 (r'[?@]', Operator), 226 (r'[?@]', Operator),
226 # Existential quantifier 227 # Existential quantifier
227 (r'\^', Operator), 228 (r'\^', Operator),
228 # Strings 229 # Strings
229 (r'"(\\\\|\\"|[^"])*"', String), 230 (r'"(\\\\|\\"|[^"])*"', String),
230 # Ponctuation 231 # Punctuation
231 (r'[()\[\],.|]', Text), 232 (r'[()\[\],.|]', Text),
232 # Atoms 233 # Atoms
233 (r"[a-z]\w*", Text), 234 (r"[a-z][a-zA-Z0-9_]*", Text),
234 (r"'", String, 'quoted_atom'), 235 (r"'", String, 'quoted_atom'),
235 ], 236 ],
236 237
237 'quoted_atom': [ 238 'quoted_atom': [
238 (r"''", String), 239 (r"''", String),
243 ], 244 ],
244 245
245 'directive': [ 246 'directive': [
246 # Conditional compilation directives 247 # Conditional compilation directives
247 (r'(el)?if(?=[(])', Keyword, 'root'), 248 (r'(el)?if(?=[(])', Keyword, 'root'),
248 (r'(e(lse|ndif))[.]', Keyword, 'root'), 249 (r'(e(lse|ndif))(?=[.])', Keyword, 'root'),
249 # Entity directives 250 # Entity directives
250 (r'(category|object|protocol)(?=[(])', Keyword, 'entityrelations'), 251 (r'(category|object|protocol)(?=[(])', Keyword, 'entityrelations'),
251 (r'(end_(category|object|protocol))[.]', Keyword, 'root'), 252 (r'(end_(category|object|protocol))(?=[.])', Keyword, 'root'),
252 # Predicate scope directives 253 # Predicate scope directives
253 (r'(public|protected|private)(?=[(])', Keyword, 'root'), 254 (r'(public|protected|private)(?=[(])', Keyword, 'root'),
254 # Other directives 255 # Other directives
255 (r'e(n(coding|sure_loaded)|xport)(?=[(])', Keyword, 'root'), 256 (r'e(n(coding|sure_loaded)|xport)(?=[(])', Keyword, 'root'),
256 (r'in(clude|itialization|fo)(?=[(])', Keyword, 'root'), 257 (r'in(clude|itialization|fo)(?=[(])', Keyword, 'root'),
257 (r'(built_in|dynamic|synchronized|threaded)[.]', Keyword, 'root'), 258 (r'(built_in|dynamic|synchronized|threaded)(?=[.])', Keyword, 'root'),
258 (r'(alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|ode|ultifile)|' 259 (r'(alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|ode|ultifile)|s(et_(logtalk|prolog)_flag|ynchronized))(?=[(])', Keyword, 'root'),
259 r's(et_(logtalk|prolog)_flag|ynchronized))(?=[(])', Keyword, 'root'),
260 (r'op(?=[(])', Keyword, 'root'), 260 (r'op(?=[(])', Keyword, 'root'),
261 (r'(c(alls|oinductive)|module|reexport|use(s|_module))(?=[(])', Keyword, 'root'), 261 (r'(c(alls|oinductive)|module|reexport|use(s|_module))(?=[(])', Keyword, 'root'),
262 (r'[a-z]\w*(?=[(])', Text, 'root'), 262 (r'[a-z][a-zA-Z0-9_]*(?=[(])', Text, 'root'),
263 (r'[a-z]\w*[.]', Text, 'root'), 263 (r'[a-z][a-zA-Z0-9_]*(?=[.])', Text, 'root'),
264 ], 264 ],
265 265
266 'entityrelations': [ 266 'entityrelations': [
267 (r'(complements|extends|i(nstantiates|mp(lements|orts))|specializes)(?=[(])', Keyword), 267 (r'(complements|extends|i(nstantiates|mp(lements|orts))|specializes)(?=[(])', Keyword),
268 # Numbers 268 # Numbers
269 (r"0'.", Number), 269 (r"0'[\\]?.", Number),
270 (r'0b[01]+', Number.Bin), 270 (r'0b[01]+', Number.Bin),
271 (r'0o[0-7]+', Number.Oct), 271 (r'0o[0-7]+', Number.Oct),
272 (r'0x[0-9a-fA-F]+', Number.Hex), 272 (r'0x[0-9a-fA-F]+', Number.Hex),
273 (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number), 273 (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
274 # Variables 274 # Variables
275 (r'([A-Z_]\w*)', Name.Variable), 275 (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
276 # Atoms 276 # Atoms
277 (r"[a-z]\w*", Text), 277 (r"[a-z][a-zA-Z0-9_]*", Text),
278 (r"'", String, 'quoted_atom'), 278 (r"'", String, 'quoted_atom'),
279 # Strings 279 # Strings
280 (r'"(\\\\|\\"|[^"])*"', String), 280 (r'"(\\\\|\\"|[^"])*"', String),
281 # End of entity-opening directive 281 # End of entity-opening directive
282 (r'([)]\.)', Text, 'root'), 282 (r'([)]\.)', Text, 'root'),
283 # Scope operator 283 # Scope operator
284 (r'(::)', Operator), 284 (r'(::)', Operator),
285 # Ponctuation 285 # Punctuation
286 (r'[()\[\],.|]', Text), 286 (r'[()\[\],.|]', Text),
287 # Comments 287 # Comments
288 (r'%.*?\n', Comment), 288 (r'%.*?\n', Comment),
289 (r'/\*(.|\n)*?\*/', Comment), 289 (r'/\*(.|\n)*?\*/', Comment),
290 # Whitespace 290 # Whitespace

eric ide

mercurial