168 tokens = _objdump_lexer_tokens(GasLexer) |
168 tokens = _objdump_lexer_tokens(GasLexer) |
169 |
169 |
170 |
170 |
171 class DObjdumpLexer(DelegatingLexer): |
171 class DObjdumpLexer(DelegatingLexer): |
172 """ |
172 """ |
173 For the output of 'objdump -Sr on compiled D files' |
173 For the output of ``objdump -Sr`` on compiled D files. |
174 """ |
174 """ |
175 name = 'd-objdump' |
175 name = 'd-objdump' |
176 aliases = ['d-objdump'] |
176 aliases = ['d-objdump'] |
177 filenames = ['*.d-objdump'] |
177 filenames = ['*.d-objdump'] |
178 mimetypes = ['text/x-d-objdump'] |
178 mimetypes = ['text/x-d-objdump'] |
179 |
179 |
180 def __init__(self, **options): |
180 def __init__(self, **options): |
181 super(DObjdumpLexer, self).__init__(DLexer, ObjdumpLexer, **options) |
181 super().__init__(DLexer, ObjdumpLexer, **options) |
182 |
182 |
183 |
183 |
184 class CppObjdumpLexer(DelegatingLexer): |
184 class CppObjdumpLexer(DelegatingLexer): |
185 """ |
185 """ |
186 For the output of 'objdump -Sr on compiled C++ files' |
186 For the output of ``objdump -Sr`` on compiled C++ files. |
187 """ |
187 """ |
188 name = 'cpp-objdump' |
188 name = 'cpp-objdump' |
189 aliases = ['cpp-objdump', 'c++-objdumb', 'cxx-objdump'] |
189 aliases = ['cpp-objdump', 'c++-objdumb', 'cxx-objdump'] |
190 filenames = ['*.cpp-objdump', '*.c++-objdump', '*.cxx-objdump'] |
190 filenames = ['*.cpp-objdump', '*.c++-objdump', '*.cxx-objdump'] |
191 mimetypes = ['text/x-cpp-objdump'] |
191 mimetypes = ['text/x-cpp-objdump'] |
192 |
192 |
193 def __init__(self, **options): |
193 def __init__(self, **options): |
194 super(CppObjdumpLexer, self).__init__(CppLexer, ObjdumpLexer, **options) |
194 super().__init__(CppLexer, ObjdumpLexer, **options) |
195 |
195 |
196 |
196 |
197 class CObjdumpLexer(DelegatingLexer): |
197 class CObjdumpLexer(DelegatingLexer): |
198 """ |
198 """ |
199 For the output of 'objdump -Sr on compiled C files' |
199 For the output of ``objdump -Sr`` on compiled C files. |
200 """ |
200 """ |
201 name = 'c-objdump' |
201 name = 'c-objdump' |
202 aliases = ['c-objdump'] |
202 aliases = ['c-objdump'] |
203 filenames = ['*.c-objdump'] |
203 filenames = ['*.c-objdump'] |
204 mimetypes = ['text/x-c-objdump'] |
204 mimetypes = ['text/x-c-objdump'] |
205 |
205 |
206 def __init__(self, **options): |
206 def __init__(self, **options): |
207 super(CObjdumpLexer, self).__init__(CLexer, ObjdumpLexer, **options) |
207 super().__init__(CLexer, ObjdumpLexer, **options) |
208 |
208 |
209 |
209 |
210 class HsailLexer(RegexLexer): |
210 class HsailLexer(RegexLexer): |
211 """ |
211 """ |
212 For HSAIL assembly code. |
212 For HSAIL assembly code. |
469 tokens = { |
470 tokens = { |
470 'root': [ |
471 'root': [ |
471 # Attributes on basic blocks |
472 # Attributes on basic blocks |
472 (words(('liveins', 'successors'), suffix=':'), Keyword), |
473 (words(('liveins', 'successors'), suffix=':'), Keyword), |
473 # Basic Block Labels |
474 # Basic Block Labels |
474 (r'bb\.[0-9]+(\.[0-9a-zA-Z_.-]+)?( \(address-taken\))?:', Name.Label), |
475 (r'bb\.[0-9]+(\.[a-zA-Z0-9_.-]+)?( \(address-taken\))?:', Name.Label), |
475 (r'bb\.[0-9]+ \(%[0-9a-zA-Z_.-]+\)( \(address-taken\))?:', Name.Label), |
476 (r'bb\.[0-9]+ \(%[a-zA-Z0-9_.-]+\)( \(address-taken\))?:', Name.Label), |
476 (r'%bb\.[0-9]+(\.\w+)?', Name.Label), |
477 (r'%bb\.[0-9]+(\.\w+)?', Name.Label), |
477 # Stack references |
478 # Stack references |
478 (r'%stack\.[0-9]+(\.\w+\.addr)?', Name), |
479 (r'%stack\.[0-9]+(\.\w+\.addr)?', Name), |
479 # Subreg indices |
480 # Subreg indices |
480 (r'%subreg\.\w+', Name), |
481 (r'%subreg\.\w+', Name), |
481 # Virtual registers |
482 # Virtual registers |
482 (r'%[0-9a-zA-Z_]+ *', Name.Variable, 'vreg'), |
483 (r'%[a-zA-Z0-9_]+ *', Name.Variable, 'vreg'), |
483 # Reference to LLVM-IR global |
484 # Reference to LLVM-IR global |
484 include('global'), |
485 include('global'), |
485 # Reference to Intrinsic |
486 # Reference to Intrinsic |
486 (r'intrinsic\(\@[0-9a-zA-Z_.]+\)', Name.Variable.Global), |
487 (r'intrinsic\(\@[a-zA-Z0-9_.]+\)', Name.Variable.Global), |
487 # Comparison predicates |
488 # Comparison predicates |
488 (words(('eq', 'ne', 'sgt', 'sge', 'slt', 'sle', 'ugt', 'uge', 'ult', |
489 (words(('eq', 'ne', 'sgt', 'sge', 'slt', 'sle', 'ugt', 'uge', 'ult', |
489 'ule'), prefix=r'intpred\(', suffix=r'\)'), Name.Builtin), |
490 'ule'), prefix=r'intpred\(', suffix=r'\)'), Name.Builtin), |
490 (words(('oeq', 'one', 'ogt', 'oge', 'olt', 'ole', 'ugt', 'uge', |
491 (words(('oeq', 'one', 'ogt', 'oge', 'olt', 'ole', 'ugt', 'uge', |
491 'ult', 'ule'), prefix=r'floatpred\(', suffix=r'\)'), |
492 'ult', 'ule'), prefix=r'floatpred\(', suffix=r'\)'), |
492 Name.Builtin), |
493 Name.Builtin), |
493 # Physical registers |
494 # Physical registers |
494 (r'\$\w+', String.Single), |
495 (r'\$\w+', String.Single), |
495 # Assignment operator |
496 # Assignment operator |
496 (r'[=]', Operator), |
497 (r'=', Operator), |
497 # gMIR Opcodes |
498 # gMIR Opcodes |
498 (r'(G_ANYEXT|G_[SZ]EXT|G_SEXT_INREG|G_TRUNC|G_IMPLICIT_DEF|G_PHI|' |
499 (r'(G_ANYEXT|G_[SZ]EXT|G_SEXT_INREG|G_TRUNC|G_IMPLICIT_DEF|G_PHI|' |
499 r'G_FRAME_INDEX|G_GLOBAL_VALUE|G_INTTOPTR|G_PTRTOINT|G_BITCAST|' |
500 r'G_FRAME_INDEX|G_GLOBAL_VALUE|G_INTTOPTR|G_PTRTOINT|G_BITCAST|' |
500 r'G_CONSTANT|G_FCONSTANT|G_VASTART|G_VAARG|G_CTLZ|G_CTLZ_ZERO_UNDEF|' |
501 r'G_CONSTANT|G_FCONSTANT|G_VASTART|G_VAARG|G_CTLZ|G_CTLZ_ZERO_UNDEF|' |
501 r'G_CTTZ|G_CTTZ_ZERO_UNDEF|G_CTPOP|G_BSWAP|G_BITREVERSE|' |
502 r'G_CTTZ|G_CTTZ_ZERO_UNDEF|G_CTPOP|G_BSWAP|G_BITREVERSE|' |
524 (r'(COPY|PHI|INSERT_SUBREG|EXTRACT_SUBREG|REG_SEQUENCE)\b', |
525 (r'(COPY|PHI|INSERT_SUBREG|EXTRACT_SUBREG|REG_SEQUENCE)\b', |
525 Name.Builtin), |
526 Name.Builtin), |
526 # Flags |
527 # Flags |
527 (words(('killed', 'implicit')), Keyword), |
528 (words(('killed', 'implicit')), Keyword), |
528 # ConstantInt values |
529 # ConstantInt values |
529 (r'[i][0-9]+ +', Keyword.Type, 'constantint'), |
530 (r'i[0-9]+ +', Keyword.Type, 'constantint'), |
530 # ConstantFloat values |
531 # ConstantFloat values |
531 (r'(half|float|double) +', Keyword.Type, 'constantfloat'), |
532 (r'(half|float|double) +', Keyword.Type, 'constantfloat'), |
532 # Bare immediates |
533 # Bare immediates |
533 include('integer'), |
534 include('integer'), |
534 # MMO's |
535 # MMO's |
535 (r':: *', Operator, 'mmo'), |
536 (r':: *', Operator, 'mmo'), |
536 # MIR Comments |
537 # MIR Comments |
537 (r';.*', Comment), |
538 (r';.*', Comment), |
538 # If we get here, assume it's a target instruction |
539 # If we get here, assume it's a target instruction |
539 (r'[0-9a-zA-Z_]+', Name), |
540 (r'[a-zA-Z0-9_]+', Name), |
540 # Everything else that isn't highlighted |
541 # Everything else that isn't highlighted |
541 (r'[(), \n]+', Text), |
542 (r'[(), \n]+', Text), |
542 ], |
543 ], |
543 # The integer constant from a ConstantInt value |
544 # The integer constant from a ConstantInt value |
544 'constantint': [ |
545 'constantint': [ |
558 (r'(?=.)', Text, '#pop'), |
559 (r'(?=.)', Text, '#pop'), |
559 ], |
560 ], |
560 'vreg_bank_or_class': [ |
561 'vreg_bank_or_class': [ |
561 # The unassigned bank/class |
562 # The unassigned bank/class |
562 (r' *_', Name.Variable.Magic), |
563 (r' *_', Name.Variable.Magic), |
563 (r' *[0-9a-zA-Z_]+', Name.Variable), |
564 (r' *[a-zA-Z0-9_]+', Name.Variable), |
564 # The LLT if there is one |
565 # The LLT if there is one |
565 (r' *\(', Text, 'vreg_type'), |
566 (r' *\(', Text, 'vreg_type'), |
566 (r'(?=.)', Text, '#pop'), |
567 (r'(?=.)', Text, '#pop'), |
567 ], |
568 ], |
568 'vreg_type': [ |
569 'vreg_type': [ |
577 (r' +', Text), |
578 (r' +', Text), |
578 (words(('load', 'store', 'on', 'into', 'from', 'align', 'monotonic', |
579 (words(('load', 'store', 'on', 'into', 'from', 'align', 'monotonic', |
579 'acquire', 'release', 'acq_rel', 'seq_cst')), |
580 'acquire', 'release', 'acq_rel', 'seq_cst')), |
580 Keyword), |
581 Keyword), |
581 # IR references |
582 # IR references |
582 (r'%ir\.[0-9a-zA-Z_.-]+', Name), |
583 (r'%ir\.[a-zA-Z0-9_.-]+', Name), |
583 (r'%ir-block\.[0-9a-zA-Z_.-]+', Name), |
584 (r'%ir-block\.[a-zA-Z0-9_.-]+', Name), |
584 (r'[-+]', Operator), |
585 (r'[-+]', Operator), |
585 include('integer'), |
586 include('integer'), |
586 include('global'), |
587 include('global'), |
587 (r',', Punctuation), |
588 (r',', Punctuation), |
588 (r'\), \(', Text), |
589 (r'\), \(', Text), |
589 (r'\)', Text, '#pop'), |
590 (r'\)', Text, '#pop'), |
590 ], |
591 ], |
591 'integer': [(r'-?[0-9]+', Number.Integer),], |
592 'integer': [(r'-?[0-9]+', Number.Integer),], |
592 'float': [(r'-?[0-9]+\.[0-9]+(e[+-][0-9]+)?', Number.Float)], |
593 'float': [(r'-?[0-9]+\.[0-9]+(e[+-][0-9]+)?', Number.Float)], |
593 'global': [(r'\@[0-9a-zA-Z_.]+', Name.Variable.Global)], |
594 'global': [(r'\@[a-zA-Z0-9_.]+', Name.Variable.Global)], |
594 } |
595 } |
595 |
596 |
|
597 |
596 class LlvmMirLexer(RegexLexer): |
598 class LlvmMirLexer(RegexLexer): |
597 """ |
599 """ |
598 Lexer for the overall LLVM MIR document format |
600 Lexer for the overall LLVM MIR document format. |
599 |
601 |
600 MIR is a human readable serialization format that's used to represent LLVM's |
602 MIR is a human readable serialization format that's used to represent LLVM's |
601 machine specific intermediate representation. It allows LLVM's developers to |
603 machine specific intermediate representation. It allows LLVM's developers to |
602 see the state of the compilation process at various points, as well as test |
604 see the state of the compilation process at various points, as well as test |
603 individual pieces of the compiler. |
605 individual pieces of the compiler. |
647 (r'body: *\|', Keyword, 'llvm_mir_body'), |
649 (r'body: *\|', Keyword, 'llvm_mir_body'), |
648 # Consume everything else |
650 # Consume everything else |
649 (r'.+', Text), |
651 (r'.+', Text), |
650 (r'\n', Text), |
652 (r'\n', Text), |
651 ], |
653 ], |
652 'name': [ (r'[^\n]+', Name), default('#pop') ], |
654 'name': [ |
653 'boolean': [ (r' *(true|false)', Name.Builtin), default('#pop') ], |
655 (r'[^\n]+', Name), |
654 'number': [ (r' *[0-9]+', Number), default('#pop') ], |
656 default('#pop'), |
|
657 ], |
|
658 'boolean': [ |
|
659 (r' *(true|false)', Name.Builtin), |
|
660 default('#pop'), |
|
661 ], |
|
662 'number': [ |
|
663 (r' *[0-9]+', Number), |
|
664 default('#pop'), |
|
665 ], |
655 'llvm_mir_body': [ |
666 'llvm_mir_body': [ |
656 # Documents end with '...' or '---'. |
667 # Documents end with '...' or '---'. |
657 # We have to pop llvm_mir_body and llvm_mir |
668 # We have to pop llvm_mir_body and llvm_mir |
658 (r'(\.\.\.|(?=---))', Keyword, '#pop:2'), |
669 (r'(\.\.\.|(?=---))', Keyword, '#pop:2'), |
659 # Delegate the body block to the LlvmMirBodyLexer |
670 # Delegate the body block to the LlvmMirBodyLexer |
660 (r'((?:.|\n)+?)(?=\.\.\.|---)', bygroups(using(LlvmMirBodyLexer))), |
671 (r'((?:.|\n)+?)(?=\.\.\.|---)', bygroups(using(LlvmMirBodyLexer))), |
661 # The '...' is optional. If we didn't already find it then it isn't |
672 # The '...' is optional. If we didn't already find it then it isn't |
662 # there. There might be a '---' instead though. |
673 # there. There might be a '---' instead though. |
663 (r'(?!\.\.\.|---)((.|\n)+)', bygroups(using(LlvmMirBodyLexer), Keyword)), |
674 (r'(?!\.\.\.|---)((?:.|\n)+)', bygroups(using(LlvmMirBodyLexer))), |
664 ], |
675 ], |
665 } |
676 } |
666 |
677 |
667 |
678 |
668 class NasmLexer(RegexLexer): |
679 class NasmLexer(RegexLexer): |
684 binn = r'[01]+b' |
695 binn = r'[01]+b' |
685 decn = r'[0-9]+' |
696 decn = r'[0-9]+' |
686 floatn = decn + r'\.e?' + decn |
697 floatn = decn + r'\.e?' + decn |
687 string = r'"(\\"|[^"\n])*"|' + r"'(\\'|[^'\n])*'|" + r"`(\\`|[^`\n])*`" |
698 string = r'"(\\"|[^"\n])*"|' + r"'(\\'|[^'\n])*'|" + r"`(\\`|[^`\n])*`" |
688 declkw = r'(?:res|d)[bwdqt]|times' |
699 declkw = r'(?:res|d)[bwdqt]|times' |
689 register = (r'r[0-9][0-5]?[bwd]|' |
700 register = (r'r[0-9][0-5]?[bwd]?|' |
690 r'[a-d][lh]|[er]?[a-d]x|[er]?[sb]p|[er]?[sd]i|[c-gs]s|st[0-7]|' |
701 r'[a-d][lh]|[er]?[a-d]x|[er]?[sb]p|[er]?[sd]i|[c-gs]s|st[0-7]|' |
691 r'mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]') |
702 r'mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]') |
692 wordop = r'seg|wrt|strict' |
703 wordop = r'seg|wrt|strict' |
693 type = r'byte|[dq]?word' |
704 type = r'byte|[dq]?word' |
694 # Directives must be followed by whitespace, otherwise CPU will match |
705 # Directives must be followed by whitespace, otherwise CPU will match |