home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_2363 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  9.0 KB  |  233 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import re
  5. from pygments.lexer import RegexLexer, include, bygroups, using, DelegatingLexer
  6. from pygments.lexers.compiled import DLexer, CppLexer, CLexer
  7. from pygments.token import *
  8. __all__ = [
  9.     'GasLexer',
  10.     'ObjdumpLexer',
  11.     'DObjdumpLexer',
  12.     'CppObjdumpLexer',
  13.     'CObjdumpLexer',
  14.     'LlvmLexer',
  15.     'NasmLexer']
  16.  
  17. class GasLexer(RegexLexer):
  18.     name = 'GAS'
  19.     aliases = [
  20.         'gas']
  21.     filenames = [
  22.         '*.s',
  23.         '*.S']
  24.     mimetypes = [
  25.         'text/x-gas']
  26.     string = '"(\\\\"|[^"])*"'
  27.     char = '[a-zA-Z$._0-9@]'
  28.     identifier = '(?:[a-zA-Z$_]' + char + '*|\\.' + char + '+)'
  29.     number = '(?:0[xX][a-zA-Z0-9]+|\\d+)'
  30.     tokens = {
  31.         'root': [
  32.             include('whitespace'),
  33.             (identifier + ':', Name.Label),
  34.             ('\\.' + identifier, Name.Attribute, 'directive-args'),
  35.             ('lock|rep(n?z)?|data\\d+', Name.Attribute),
  36.             (identifier, Name.Function, 'instruction-args'),
  37.             ('[\\r\\n]+', Text)],
  38.         'directive-args': [
  39.             (identifier, Name.Constant),
  40.             (string, String),
  41.             ('@' + identifier, Name.Attribute),
  42.             (number, Number.Integer),
  43.             ('[\\r\\n]+', Text, '#pop'),
  44.             ('#.*?$', Comment, '#pop'),
  45.             include('punctuation'),
  46.             include('whitespace')],
  47.         'instruction-args': [
  48.             ('([a-z0-9]+)( )(<)(' + identifier + ')(>)', bygroups(Number.Hex, Text, Punctuation, Name.Constant, Punctuation)),
  49.             ('([a-z0-9]+)( )(<)(' + identifier + ')([-+])(' + number + ')(>)', bygroups(Number.Hex, Text, Punctuation, Name.Constant, Punctuation, Number.Integer, Punctuation)),
  50.             (identifier, Name.Constant),
  51.             (number, Number.Integer),
  52.             ('%' + identifier, Name.Variable),
  53.             ('$' + number, Number.Integer),
  54.             ('[\\r\\n]+', Text, '#pop'),
  55.             ('#.*?$', Comment, '#pop'),
  56.             include('punctuation'),
  57.             include('whitespace')],
  58.         'whitespace': [
  59.             ('\\n', Text),
  60.             ('\\s+', Text),
  61.             ('#.*?\\n', Comment)],
  62.         'punctuation': [
  63.             ('[-*,.():]+', Punctuation)] }
  64.     
  65.     def analyse_text(text):
  66.         return re.match('^\\.\\w+', text, re.M)
  67.  
  68.  
  69.  
  70. class ObjdumpLexer(RegexLexer):
  71.     name = 'objdump'
  72.     aliases = [
  73.         'objdump']
  74.     filenames = [
  75.         '*.objdump']
  76.     mimetypes = [
  77.         'text/x-objdump']
  78.     hex = '[0-9A-Za-z]'
  79.     tokens = {
  80.         'root': [
  81.             ('(.*?)(:)( +file format )(.*?)$', bygroups(Name.Label, Punctuation, Text, String)),
  82.             ('(Disassembly of section )(.*?)(:)$', bygroups(Text, Name.Label, Punctuation)),
  83.             ('(' + hex + '+)( )(<)(.*?)([-+])(0[xX][A-Za-z0-9]+)(>:)$', bygroups(Number.Hex, Text, Punctuation, Name.Function, Punctuation, Number.Hex, Punctuation)),
  84.             ('(' + hex + '+)( )(<)(.*?)(>:)$', bygroups(Number.Hex, Text, Punctuation, Name.Function, Punctuation)),
  85.             ('( *)(' + hex + '+:)(\\t)((?:' + hex + hex + ' )+)( *\t)([a-zA-Z].*?)$', bygroups(Text, Name.Label, Text, Number.Hex, Text, using(GasLexer))),
  86.             ('( *)(' + hex + '+:)(\\t)((?:' + hex + hex + ' )+)( *)(.*?)$', bygroups(Text, Name.Label, Text, Number.Hex, Text, String)),
  87.             ('( *)(' + hex + '+:)(\\t)((?:' + hex + hex + ' )+)$', bygroups(Text, Name.Label, Text, Number.Hex)),
  88.             ('\t\\.\\.\\.$', Text),
  89.             ('(\t\t\t)(' + hex + '+:)( )([^\t]+)(\t)(.*?)([-+])(0x' + hex + '+)$', bygroups(Text, Name.Label, Text, Name.Property, Text, Name.Constant, Punctuation, Number.Hex)),
  90.             ('(\t\t\t)(' + hex + '+:)( )([^\t]+)(\t)(.*?)$', bygroups(Text, Name.Label, Text, Name.Property, Text, Name.Constant)),
  91.             ('[^\n]+\n', Other)] }
  92.  
  93.  
  94. class DObjdumpLexer(DelegatingLexer):
  95.     name = 'd-objdump'
  96.     aliases = [
  97.         'd-objdump']
  98.     filenames = [
  99.         '*.d-objdump']
  100.     mimetypes = [
  101.         'text/x-d-objdump']
  102.     
  103.     def __init__(self, **options):
  104.         super(DObjdumpLexer, self).__init__(DLexer, ObjdumpLexer, **options)
  105.  
  106.  
  107.  
  108. class CppObjdumpLexer(DelegatingLexer):
  109.     name = 'cpp-objdump'
  110.     aliases = [
  111.         'cpp-objdump',
  112.         'c++-objdumb',
  113.         'cxx-objdump']
  114.     filenames = [
  115.         '*.cpp-objdump',
  116.         '*.c++-objdump',
  117.         '*.cxx-objdump']
  118.     mimetypes = [
  119.         'text/x-cpp-objdump']
  120.     
  121.     def __init__(self, **options):
  122.         super(CppObjdumpLexer, self).__init__(CppLexer, ObjdumpLexer, **options)
  123.  
  124.  
  125.  
  126. class CObjdumpLexer(DelegatingLexer):
  127.     name = 'c-objdump'
  128.     aliases = [
  129.         'c-objdump']
  130.     filenames = [
  131.         '*.c-objdump']
  132.     mimetypes = [
  133.         'text/x-c-objdump']
  134.     
  135.     def __init__(self, **options):
  136.         super(CObjdumpLexer, self).__init__(CLexer, ObjdumpLexer, **options)
  137.  
  138.  
  139.  
  140. class LlvmLexer(RegexLexer):
  141.     name = 'LLVM'
  142.     aliases = [
  143.         'llvm']
  144.     filenames = [
  145.         '*.ll']
  146.     mimetypes = [
  147.         'text/x-llvm']
  148.     string = '"[^"]*?"'
  149.     identifier = '([-a-zA-Z$._][-a-zA-Z$._0-9]*|' + string + ')'
  150.     tokens = {
  151.         'root': [
  152.             include('whitespace'),
  153.             ('^\\s*' + identifier + '\\s*:', Name.Label),
  154.             include('keyword'),
  155.             ('%' + identifier, Name.Variable),
  156.             ('@' + identifier, Name.Variable.Global),
  157.             ('%\\d+', Name.Variable.Anonymous),
  158.             ('@\\d+', Name.Variable.Global),
  159.             ('!' + identifier, Name.Variable),
  160.             ('!\\d+', Name.Variable.Anonymous),
  161.             ('c?' + string, String),
  162.             ('0[xX][a-fA-F0-9]+', Number),
  163.             ('-?\\d+(?:[.]\\d+)?(?:[eE][-+]?\\d+(?:[.]\\d+)?)?', Number),
  164.             ('[=<>{}\\[\\]()*.,!]|x\\b', Punctuation)],
  165.         'whitespace': [
  166.             ('(\\n|\\s)+', Text),
  167.             (';.*?\\n', Comment)],
  168.         'keyword': [
  169.             ('(begin|end|true|false|declare|define|global|constant|private|linker_private|internal|available_externally|linkonce|linkonce_odr|weak|weak_odr|appending|dllimport|dllexport|common|default|hidden|protected|extern_weak|external|thread_local|zeroinitializer|undef|null|to|tail|target|triple|deplibs|datalayout|volatile|nuw|nsw|exact|inbounds|align|addrspace|section|alias|module|asm|sideeffect|gc|dbg|ccc|fastcc|coldcc|x86_stdcallcc|x86_fastcallcc|arm_apcscc|arm_aapcscc|arm_aapcs_vfpcc|cc|c|signext|zeroext|inreg|sret|nounwind|noreturn|noalias|nocapture|byval|nest|readnone|readonly|inlinehint|noinline|alwaysinline|optsize|ssp|sspreq|noredzone|noimplicitfloat|naked|type|opaque|eq|ne|slt|sgt|sle|sge|ult|ugt|ule|uge|oeq|one|olt|ogt|ole|oge|ord|uno|ueq|une|x|add|fadd|sub|fsub|mul|fmul|udiv|sdiv|fdiv|urem|srem|frem|shl|lshr|ashr|and|or|xor|icmp|fcmp|phi|call|trunc|zext|sext|fptrunc|fpext|uitofp|sitofp|fptouifptosi|inttoptr|ptrtoint|bitcast|select|va_arg|ret|br|switch|invoke|unwind|unreachable|malloc|alloca|free|load|store|getelementptr|extractelement|insertelement|shufflevector|getresult|extractvalue|insertvalue)\\b', Keyword),
  170.             ('void|float|double|x86_fp80|fp128|ppc_fp128|label|metadata', Keyword.Type),
  171.             ('i[1-9]\\d*', Keyword)] }
  172.  
  173.  
  174. class NasmLexer(RegexLexer):
  175.     name = 'NASM'
  176.     aliases = [
  177.         'nasm']
  178.     filenames = [
  179.         '*.asm',
  180.         '*.ASM']
  181.     mimetypes = [
  182.         'text/x-nasm']
  183.     identifier = '[a-zA-Z$._?][a-zA-Z0-9$._?#@~]*'
  184.     hexn = '(?:0[xX][0-9a-fA-F]+|$0[0-9a-fA-F]*|[0-9]+[0-9a-fA-F]*h)'
  185.     octn = '[0-7]+q'
  186.     binn = '[01]+b'
  187.     decn = '[0-9]+'
  188.     floatn = decn + '\\.e?' + decn
  189.     string = '"(\\\\"|[^"])*"|' + "'(\\\\'|[^'])*'"
  190.     declkw = '(?:res|d)[bwdqt]|times'
  191.     register = '[a-d][lh]|e?[a-d]x|e?[sb]p|e?[sd]i|[c-gs]s|st[0-7]|mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]'
  192.     wordop = 'seg|wrt|strict'
  193.     type = 'byte|[dq]?word'
  194.     directives = 'BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|ORG|ALIGN|STRUC|ENDSTRUC|COMMON|CPU|GROUP|UPPERCASE|IMPORT|EXPORT|LIBRARY|MODULE'
  195.     flags = re.IGNORECASE | re.MULTILINE
  196.     tokens = {
  197.         'root': [
  198.             include('whitespace'),
  199.             ('^\\s*%', Comment.Preproc, 'preproc'),
  200.             (identifier + ':', Name.Label),
  201.             ('(%s)(\\s+)(equ)' % identifier, bygroups(Name.Constant, Keyword.Declaration, Keyword.Declaration), 'instruction-args'),
  202.             (directives, Keyword, 'instruction-args'),
  203.             (declkw, Keyword.Declaration, 'instruction-args'),
  204.             (identifier, Name.Function, 'instruction-args'),
  205.             ('[\\r\\n]+', Text)],
  206.         'instruction-args': [
  207.             (string, String),
  208.             (hexn, Number.Hex),
  209.             (octn, Number.Oct),
  210.             (binn, Number),
  211.             (floatn, Number.Float),
  212.             (decn, Number.Integer),
  213.             include('punctuation'),
  214.             (register, Name.Builtin),
  215.             (identifier, Name.Variable),
  216.             ('[\\r\\n]+', Text, '#pop'),
  217.             include('whitespace')],
  218.         'preproc': [
  219.             ('[^;\\n]+', Comment.Preproc),
  220.             (';.*?\\n', Comment.Single, '#pop'),
  221.             ('\\n', Comment.Preproc, '#pop')],
  222.         'whitespace': [
  223.             ('\\n', Text),
  224.             ('[ \\t]+', Text),
  225.             (';.*', Comment.Single)],
  226.         'punctuation': [
  227.             ('[,():\\[\\]]+', Punctuation),
  228.             ('[&|^<>+*/%~-]+', Operator),
  229.             ('[$]+', Keyword.Constant),
  230.             (wordop, Operator.Word),
  231.             (type, Keyword.Type)] }
  232.  
  233.