comparison MoinMoin/support/pygments/lexers/asm.py @ 5564:74fa6f714526

upgraded pygments to 1.2.2
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 21 Feb 2010 23:52:54 +0100
parents 0970ed47d2cd
children f76914e77229
comparison
equal deleted inserted replaced
5563:69ffae200796 5564:74fa6f714526
3 pygments.lexers.asm 3 pygments.lexers.asm
4 ~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for assembly languages. 6 Lexers for assembly languages.
7 7
8 :copyright: Copyright 2006-2009 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2010 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 try: 13 try:
197 filenames = ['*.ll'] 197 filenames = ['*.ll']
198 mimetypes = ['text/x-llvm'] 198 mimetypes = ['text/x-llvm']
199 199
200 #: optional Comment or Whitespace 200 #: optional Comment or Whitespace
201 string = r'"[^"]*?"' 201 string = r'"[^"]*?"'
202 identifier = r'([a-zA-Z$._][a-zA-Z$._0-9]*|' + string + ')' 202 identifier = r'([-a-zA-Z$._][-a-zA-Z$._0-9]*|' + string + ')'
203 203
204 tokens = { 204 tokens = {
205 'root': [ 205 'root': [
206 include('whitespace'), 206 include('whitespace'),
207 207
209 (r'^\s*' + identifier + '\s*:', Name.Label), 209 (r'^\s*' + identifier + '\s*:', Name.Label),
210 210
211 include('keyword'), 211 include('keyword'),
212 212
213 (r'%' + identifier, Name.Variable),#Name.Identifier.Local), 213 (r'%' + identifier, Name.Variable),#Name.Identifier.Local),
214 (r'@' + identifier, Name.Constant),#Name.Identifier.Global), 214 (r'@' + identifier, Name.Variable.Global),#Name.Identifier.Global),
215 (r'%\d+', Name.Variable.Anonymous),#Name.Identifier.Anonymous), 215 (r'%\d+', Name.Variable.Anonymous),#Name.Identifier.Anonymous),
216 (r'@\d+', Name.Variable.Global),#Name.Identifier.Anonymous),
217 (r'!' + identifier, Name.Variable),
218 (r'!\d+', Name.Variable.Anonymous),
216 (r'c?' + string, String), 219 (r'c?' + string, String),
217 220
218 (r'0[xX][a-fA-F0-9]+', Number), 221 (r'0[xX][a-fA-F0-9]+', Number),
219 (r'-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?', Number), 222 (r'-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?', Number),
220 223
221 (r'[=<>{}\[\]()*.,]|x\b', Punctuation) 224 (r'[=<>{}\[\]()*.,!]|x\b', Punctuation)
222 ], 225 ],
223 'whitespace': [ 226 'whitespace': [
224 (r'(\n|\s)+', Text), 227 (r'(\n|\s)+', Text),
225 (r';.*?\n', Comment) 228 (r';.*?\n', Comment)
226 ], 229 ],
227 'keyword': [ 230 'keyword': [
228 # Regular keywords 231 # Regular keywords
229 (r'(void|label|float|double|opaque' 232 (r'(begin|end'
230 r'|to' 233 r'|true|false'
231 r'|alias|type' 234 r'|declare|define'
232 r'|zeroext|signext|inreg|sret|noalias|noreturn|nounwind|nest' 235 r'|global|constant'
233 r'|module|asm|target|datalayout|triple' 236
234 r'|true|false|null|zeroinitializer|undef' 237 r'|private|linker_private|internal|available_externally|linkonce'
235 r'|global|internal|external|linkonce|weak|appending|extern_weak' 238 r'|linkonce_odr|weak|weak_odr|appending|dllimport|dllexport'
236 r'|dllimport|dllexport' 239 r'|common|default|hidden|protected|extern_weak|external'
237 r'|ccc|fastcc|coldcc|cc|tail' 240 r'|thread_local|zeroinitializer|undef|null|to|tail|target|triple'
238 r'|default|hidden|protected' 241 r'|deplibs|datalayout|volatile|nuw|nsw|exact|inbounds|align'
239 r'|thread_local|constant|align|section' 242 r'|addrspace|section|alias|module|asm|sideeffect|gc|dbg'
240 r'|define|declare' 243
241 244 r'|ccc|fastcc|coldcc|x86_stdcallcc|x86_fastcallcc|arm_apcscc'
242 # Statements & expressions 245 r'|arm_aapcscc|arm_aapcs_vfpcc'
243 r'|trunc|zext|sext|fptrunc|fpext|fptoui|fptosi|uitofp|sitofp' 246
244 r'|ptrtoint|inttoptr|bitcast|getelementptr|select|icmp|fcmp' 247 r'|cc|c'
245 r'|extractelement|insertelement|shufflevector' 248
246 r'|sideeffect|volatile' 249 r'|signext|zeroext|inreg|sret|nounwind|noreturn|noalias|nocapture'
247 r'|ret|br|switch|invoke|unwind|unreachable' 250 r'|byval|nest|readnone|readonly'
248 r'|add|sub|mul|udiv|sdiv|fdiv|urem|srem|frem' 251
249 r'|shl|lshr|ashr|and|or|xor' 252 r'|inlinehint|noinline|alwaysinline|optsize|ssp|sspreq|noredzone'
250 r'|malloc|free|alloca|load|store' 253 r'|noimplicitfloat|naked'
251 r'|phi|call|va_arg|va_list' 254
252 255 r'|type|opaque'
253 # Comparison condition codes for icmp 256
254 r'|eq|ne|ugt|uge|ult|ule|sgt|sge|slt|sle' 257 r'|eq|ne|slt|sgt|sle'
255 # Ditto for fcmp: (minus keywords mentioned in other contexts) 258 r'|sge|ult|ugt|ule|uge'
256 r'|oeq|ogt|oge|olt|ole|one|ord|ueq|ugt|uge|une|uno' 259 r'|oeq|one|olt|ogt|ole'
260 r'|oge|ord|uno|ueq|une'
261 r'|x'
262
263 # instructions
264 r'|add|fadd|sub|fsub|mul|fmul|udiv|sdiv|fdiv|urem|srem|frem|shl'
265 r'|lshr|ashr|and|or|xor|icmp|fcmp'
266
267 r'|phi|call|trunc|zext|sext|fptrunc|fpext|uitofp|sitofp|fptoui'
268 r'fptosi|inttoptr|ptrtoint|bitcast|select|va_arg|ret|br|switch'
269 r'|invoke|unwind|unreachable'
270
271 r'|malloc|alloca|free|load|store|getelementptr'
272
273 r'|extractelement|insertelement|shufflevector|getresult'
274 r'|extractvalue|insertvalue'
257 275
258 r')\b', Keyword), 276 r')\b', Keyword),
277
278 # Types
279 (r'void|float|double|x86_fp80|fp128|ppc_fp128|label|metadata',
280 Keyword.Type),
281
259 # Integer types 282 # Integer types
260 (r'i[1-9]\d*', Keyword) 283 (r'i[1-9]\d*', Keyword)
261 ] 284 ]
262 } 285 }
263 286
270 aliases = ['nasm'] 293 aliases = ['nasm']
271 filenames = ['*.asm', '*.ASM'] 294 filenames = ['*.asm', '*.ASM']
272 mimetypes = ['text/x-nasm'] 295 mimetypes = ['text/x-nasm']
273 296
274 identifier = r'[a-zA-Z$._?][a-zA-Z0-9$._?#@~]*' 297 identifier = r'[a-zA-Z$._?][a-zA-Z0-9$._?#@~]*'
275 hexn = r'(?:0[xX][0-9a-fA-F]+|$0[0-9a-fA-F]*|[0-9a-fA-F]+h)' 298 hexn = r'(?:0[xX][0-9a-fA-F]+|$0[0-9a-fA-F]*|[0-9]+[0-9a-fA-F]*h)'
276 octn = r'[0-7]+q' 299 octn = r'[0-7]+q'
277 binn = r'[01]+b' 300 binn = r'[01]+b'
278 decn = r'[0-9]+' 301 decn = r'[0-9]+'
279 floatn = decn + r'\.e?' + decn 302 floatn = decn + r'\.e?' + decn
280 string = r'"(\\"|[^"])*"|' + r"'(\\'|[^'])*'" 303 string = r'"(\\"|[^"])*"|' + r"'(\\'|[^'])*'"
282 register = (r'[a-d][lh]|e?[a-d]x|e?[sb]p|e?[sd]i|[c-gs]s|st[0-7]|' 305 register = (r'[a-d][lh]|e?[a-d]x|e?[sb]p|e?[sd]i|[c-gs]s|st[0-7]|'
283 r'mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]') 306 r'mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]')
284 wordop = r'seg|wrt|strict' 307 wordop = r'seg|wrt|strict'
285 type = r'byte|[dq]?word' 308 type = r'byte|[dq]?word'
286 directives = (r'BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|' 309 directives = (r'BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|'
287 r'COMMON|CPU|GROUP|UPPERCASE|IMPORT|EXPORT|LIBRARY|MODULE') 310 r'ORG|ALIGN|STRUC|ENDSTRUC|COMMON|CPU|GROUP|UPPERCASE|IMPORT|'
311 r'EXPORT|LIBRARY|MODULE')
288 312
289 flags = re.IGNORECASE | re.MULTILINE 313 flags = re.IGNORECASE | re.MULTILINE
290 tokens = { 314 tokens = {
291 'root': [ 315 'root': [
292 include('whitespace'), 316 include('whitespace'),
293 (r'^\s*%', Comment.Preproc, 'preproc'), 317 (r'^\s*%', Comment.Preproc, 'preproc'),
294 (identifier + ':', Name.Label), 318 (identifier + ':', Name.Label),
319 (r'(%s)(\s+)(equ)' % identifier,
320 bygroups(Name.Constant, Keyword.Declaration, Keyword.Declaration),
321 'instruction-args'),
295 (directives, Keyword, 'instruction-args'), 322 (directives, Keyword, 'instruction-args'),
296 (r'(%s)\s+(equ)' % identifier,
297 bygroups(Name.Constant, Keyword.Declaration),
298 'instruction-args'),
299 (declkw, Keyword.Declaration, 'instruction-args'), 323 (declkw, Keyword.Declaration, 'instruction-args'),
300 (identifier, Name.Function, 'instruction-args'), 324 (identifier, Name.Function, 'instruction-args'),
301 (r'[\r\n]+', Text) 325 (r'[\r\n]+', Text)
302 ], 326 ],
303 'instruction-args': [ 327 'instruction-args': [