U
    G
\c                     @   sJ  d Z ddlZddlmZmZmZmZmZmZ ddl	m
Z
mZ ddlmZ ddlmZmZmZmZmZmZmZmZmZ ddd	d
dddddddgZG dd deZdd ZG dd deZG dd	 d	eZG dd
 d
eZG dd deZG dd deZG dd deZ G dd deZ!G dd deZ"G dd deZ#G dd deZ$dS )z
    pygments.lexers.asm
    ~~~~~~~~~~~~~~~~~~~

    Lexers for assembly languages.

    :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    N)
RegexLexerincludebygroupsusingwordsDelegatingLexer)CppLexerCLexer)DLexer)	TextNameNumberStringCommentPunctuationOtherKeywordOperatorGasLexerObjdumpLexerDObjdumpLexerCppObjdumpLexerCObjdumpLexer
HsailLexer	LlvmLexer	NasmLexerNasmObjdumpLexer	TasmLexer	Ca65Lexerc                   @   s  e Zd ZdZdZddgZddgZdgZdZd	Z	d
e	 d e	 d Z
dZede
d ejfde
 ejdfdejfe
ejdfdefge
ejfeefde
 ejfeejfdedfdedfededgde
 d eejeeejefde
 d e d eejeeejeejefe
ejfeejfde
 ejfde ejfdejfdedfdedfededgdefd efdefgd!efgd"Zd#d$ Zd%S )&r   z'
    For Gas (AT&T) assembly code.
    ZGASZgasasm*.sz*.Sz
text/x-gasz"(\\"|[^"])*"z[\w$.@-]z(?:[a-zA-Z$_]z*|\.z+)z(?:0[xX][a-zA-Z0-9]+|\d+)
whitespace:z\.directive-argszlock|rep(n?z)?|data\d+instruction-args[\r\n]+@#popz	[;#].*?\npunctuationz([a-z0-9]+)( )(<)(z)(>)z)([-+])(%$z
$'(.|\\')'\n\s+z[-*,.()\[\]!:]+)rootr#   r$   r!   r(   c                 C   s,   t d| t jrdS t d| t jr(dS d S )Nz^\.(text|data|section)Tz^\.\w+g?)rematchM)text r2   5/usr/lib/python3/dist-packages/pygments/lexers/asm.pyanalyse_text_   s    zGasLexer.analyse_textN)__name__
__module____qualname____doc__namealiases	filenames	mimetypesstringchar
identifierZnumberr   r   LabelZ	AttributeFunctionr   Constantr   r   Integerr   r   Hexr   VariableChartokensr4   r2   r2   r2   r3   r      sn   
	
  6c                 C   sR  d}ddt tjtttfdt ttjtfd| d t tjtttjttjtfd| d t tjtttjtfd| d	 | | d
 t ttjttjtt	| fd| d	 | | d t ttjttjttfd| d	 | | d t ttjttjfdtfd| d | d t ttjttj
ttjttjfd| d t ttjttj
ttjfdtfgiS )z;
    Common objdump lexer tokens to wrap an ASM lexer.
    z[0-9A-Za-z]r-   z(.*?)(:)( +file format )(.*?)$z"(Disassembly of section )(.*?)(:)$(z++)( )(<)(.*?)([-+])(0[xX][A-Za-z0-9]+)(>:)$z+)( )(<)(.*?)(>:)$z( *)(z+:)(\t)((?:z )+)( *	)([a-zA-Z].*?)$z )+)( *)(.*?)$z )+)$z	\t\.\.\.$z	(\t\t\t)(z +:)( )([^\t]+)(\t)(.*?)([-+])(0xz+)$z+:)( )([^\t]+)(\t)(.*?)$z[^\n]+\n)r   r   r@   r   r   r   r   rD   rA   r   ZPropertyrB   r   )Z	asm_lexerZhex_rer2   r2   r3   _objdump_lexer_tokensf   s^    
  
  
rI   c                   @   s.   e Zd ZdZdZdgZdgZdgZee	Z
dS )r   z)
    For the output of 'objdump -dr'
    Zobjdumpz	*.objdumpztext/x-objdumpN)r5   r6   r7   r8   r9   r:   r;   r<   rI   r   rG   r2   r2   r2   r3   r      s   c                       s6   e Zd ZdZdZdgZdgZdgZ fddZ  Z	S )r   z=
    For the output of 'objdump -Sr on compiled D files'
    z	d-objdumpz*.d-objdumpztext/x-d-objdumpc                    s   t t| jttf| d S N)superr   __init__r
   r   selfZoptions	__class__r2   r3   rL      s    zDObjdumpLexer.__init__
r5   r6   r7   r8   r9   r:   r;   r<   rL   __classcell__r2   r2   rO   r3   r      s   c                       s>   e Zd ZdZdZdddgZdddgZdgZ fd	d
Z  Z	S )r   z?
    For the output of 'objdump -Sr on compiled C++ files'
    zcpp-objdumpzc++-objdumbzcxx-objdumpz*.cpp-objdumpz*.c++-objdumpz*.cxx-objdumpztext/x-cpp-objdumpc                    s   t t| jttf| d S rJ   )rK   r   rL   r   r   rM   rO   r2   r3   rL      s    zCppObjdumpLexer.__init__rQ   r2   r2   rO   r3   r      s   

c                       s6   e Zd ZdZdZdgZdgZdgZ fddZ  Z	S )r   z=
    For the output of 'objdump -Sr on compiled C files'
    z	c-objdumpz*.c-objdumpztext/x-c-objdumpc                    s   t t| jttf| d S rJ   )rK   r   rL   r	   r   rM   rO   r2   r3   rL      s    zCObjdumpLexer.__init__rQ   r2   r2   rO   r3   r      s   c                   @   s\  e Zd ZdZdZddgZdgZdgZdZdZ	d	Z
d
e
 d ZdZdZdZdZdZdZdZdZededeefde	 d ejfeejjfedde	 ejjfde	 ejfeejfdejfeejfeejfdejfdefgde fgde!j"fd e!j#fgd!e e$j%fd"e$fe&d#d$d%e$fee$fee$fd&e d' e d e$fd(e$fd)e$fe&d*e$fd+e$fg
d,Z'd-S ).r   z=
    For HSAIL assembly code.

    .. versionadded:: 2.2
    ZHSAILZhsailZhsaz*.hsailztext/x-hsail"[^"]*?"z[a-zA-Z_][\w.]*[0-9]+z(\$(c|s|d|q))z(align\(\d+\))z(width\((\d+|all)\))z(alloc\(agent\))z ((_ftz)?(_up|_down|_zero|_near))z_(u8x4|s8x4|u16x2|s16x2|u8x8|s8x8|u16x4|s16x4|u32x2|s32x2|u8x16|s8x16|u16x8|s16x8|u32x4|s32x4|u64x2|s64x2|f16x2|f16x4|f16x8|f32x2|f32x4|f64x2|u8|s8|u16|s16|u32|s32|u64|s64|b128|b8|b16|b32|b64|b1|f16|f32|f64|roimg|woimg|rwimg|samp|sig32|sig64)z ((\d+\.)|(\d*\.\d+))[eE][+-]?\d+zL0[xX](([0-9a-fA-F]+\.[0-9a-fA-F]*)|([0-9a-fA-F]*\.[0-9a-fA-F]+))[pP][+-]?\d+z?0((h|H)[0-9a-fA-F]{4}|(f|F)[0-9a-fA-F]{8}|(d|D)[0-9a-fA-F]{16})r!   commentsr&   z:?keyword&r)   0[xX][a-fA-F0-9]+\d+z[=<>{}\[\]()*.,:;!]|x\b(\n|\s)+z	/\*.*?\*/z//.*?\nZkernargz+\$(full|base|small|large|default|zero|near))module	extensionZpragmaprogZindirectZ	signatureZdeclZkernelZfunctionZenablebreakexceptionsZenabledetectexceptionsZmaxdynamicgroupsizeZmaxflatgridsizeZmaxflatworkgroupsizeZrequireddimZrequiredgridsizeZrequiredworkgroupsizeZrequirenopartialworkgroups\bsuffixz_(|_kernargz(nop|imagefence)\b)ZcleardetectexceptZclockZcuidZ	debugtrapZdimZgetdetectexceptZgroupbaseptrZkernargbaseptrZlaneidZmaxcuidZ	maxwaveidZpacketidZsetdetectexceptZwaveidZworkitemflatabsidZworkitemflatidZnullptrabsZbitrevZcurrentworkgroupsizeZcurrentworkitemflatidZfractZncosnegZnexp2Znlog2ZnrcpZnrsqrtZnsinZnsqrtZ
gridgroupsZgridsizenotZsqrtZworkgroupidZworkgroupsizeZworkitemabsidZ
workitemidZceilZfloorZrinttruncaddZbitmaskZborrowZcarryZcopysignZdivZremsubshlZshrandorxorZunpackhiZunpacklomaxminZfmaZmadZ
bitextractZ	bitselectZshuffleZcmovZbitalignZ	bytealignZlerpZnfmamulZmulhiZmul24hiZmul24Zmad24Zmad24hiZ	bitinsertZcombineexpandZldaZmovZpackZunpackZpackcvtZ	unpackcvtZsadZsementpZftosZstofZcmpZldst_eqZ_neZ_ltZ_leZ_gtZ_geZ_equZ_neuZ_ltuZ_leuZ_gtuZ_geuZ_numZ_nanZ_seqZ_sneZ_sltZ_sleZ_sgtZ_sgeZ_snumZ_snanZ_sequZ_sneuZ_sltuZ_sleuZ_sgtuZ_sgeuatomicZ_ldZ_stZ_casZ_addZ_andZ_exchZ_maxZ_minZ_orZ_subZ_wrapdecZ_wrapincZ_xorretZcvtZ	_readonlyrc   Z_globalbrZcbrZsbrZ_scacqZ_screlZ_scarZ_rlxZ_waveZ_wgZ_agentZ_systemZldimageZstimageZ_v2Z_v3Z_v4Z_1dZ_2dZ_3dZ_1daZ_2daZ_1dbZ_2ddepthZ	_2dadepthZ_widthZ_heightZ_depthZ_arrayZ_channelorderZ_channeltypeZquerysamplerZ_coordZ_filterZ_addressingZbarrierZwavebarrierZinitfbarZjoinfbarZwaitfbarZ
arrivefbarZ	leavefbarZreleasefbarZldfZactivelaneidZactivelanecountZactivelanemaskZactivelanepermutecallZscallZicallallocaZpacketcompletionsigZaddqueuewriteindexZcasqueuewriteindexZldqueuereadindexZstqueuereadindexreadonlyglobalprivategroupZspillargZ_upiZ_downiZ_zeroiZ_neariZ_upi_satZ
_downi_satZ
_zeroi_satZ
_neari_satZ_supiZ_sdowniZ_szeroiZ_sneariZ	_supi_satZ_sdowni_satZ_szeroi_satZ_sneari_satZ_ppZ_psZ_spZ_ssZ_sZ_pZ_pp_satZ_ps_satZ_sp_satZ_ss_satZ_s_satZ_p_sat	i[1-9]\d*)r-   r!   rV   rW   N)(r5   r6   r7   r8   r9   r:   r;   r<   r=   r?   Zregister_numberregisterZ	alignQualZ	widthQualZ	allocQualZroundingModZdatatypeModfloatZhexfloatZ	ieeefloatr   r   r   r@   rE   	AnonymousGlobalr   rD   FloatrC   r   r   r   Z	MultilineSingler   Typer   rG   r2   r2   r2   r3   r      sn   
	%(c                   @   s   e Zd ZdZdZdgZdgZdgZdZde d Z	e
d	e	d
 ejfe
dde	 ejfde	 ejjfdejjfdejjfdejjfde	 ejfdejjfde efdefdefdefgdefdefgedddefedejfdefgdZdS ) r   z!
    For LLVM assembly code.
    ZLLVMZllvmz*.llztext/x-llvmrS   z([-a-zA-Z$._][\w\-$.]*|rU   r!   z\s*:rW   r)   r&   z%\d+z@\d+z#\d+!z!\d+zc?rY   z,-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?z[=<>{}\[\]()*.,!]|x\br[   ;.*?\n(  ZbeginendtrueZfalseZdeclareZdefinerz   Zconstantr{   Zlinker_privateZinternalZavailable_externallyZlinkonceZlinkonce_odrZweakZweak_odrZ	appendingZ	dllimportZ	dllexportcommondefaultZhiddenZ	protectedZextern_weakZexternalZthread_localZzeroinitializerZundefZnulltotailtargetZtripleZ
datalayoutZvolatileZnuwZnswZnnanZninfZnszZarcpZfastexactZinboundsZalignZ	addrspaceZsectionaliasr\   r   Z
sideeffectgcZdbgZlinker_private_weakZ
attributesZblockaddressZinitialexecZlocaldynamicZ	localexecprefixZunnamed_addrZcccZfastccZcoldccZx86_stdcallccZx86_fastcallccZ
arm_apcsccZarm_aapcsccZarm_aapcs_vfpccZ
ptx_deviceZ
ptx_kernelZintel_ocl_biccZmsp430_intrccZ	spir_funcZspir_kernelZx86_64_sysvccZx86_64_win64ccZx86_thiscallccZcccZsignextZzeroextZinregZsretZnounwindZnoreturnZnoaliasZ	nocaptureZbyvalZnestZreadnonery   Z
inlinehintZnoinlineZalwaysinlineZoptsizeZsspZsspreqZ	noredzoneZnoimplicitfloatZnakedZbuiltinZcoldZ	nobuiltinZnoduplicateZnonlazybindZoptnoneZreturns_twiceZsanitize_addressZsanitize_memoryZsanitize_threadZ	sspstrongZuwtableZreturnedtypeZopaqueeqneZsltZsgtZsleZsgeZultZugtZuleZugeZoeqZoneZoltZogtZoleZogeordZunoZueqZunexZacq_relacquireZ
alignstackrt   ZcatchZcleanupfilterZinteldialectrn   ro   	monotonicZnandZpersonalityreleaseZseq_cstZsinglethreadZumaxZuminZ	unorderedZxchgrh   Zfaddri   Zfsubrp   ZfmulZudivZsdivZfdivZuremZsremZfremrj   ZlshrZashrrk   rl   rm   ZicmpZfcmpZphirw   rg   ZzextZsextZfptruncZfpextZuitofpZsitofpZfptouiZfptosiZinttoptrZptrtointZbitcastZaddrspacecastZselectZva_argru   rv   ZswitchZinvokeZunwindZunreachableZ
indirectbrZ
landingpadZresumeZmallocrx   ZfreeloadZstoreZgetelementptrZextractelementZinsertelementZshufflevectorZ	getresultZextractvalueZinsertvalueZ	atomicrmwZcmpxchgZfenceZ	allocsizeZ	amdgpu_csZ	amdgpu_gsZamdgpu_kernelZ	amdgpu_psZ	amdgpu_vsanyZanyregccZ
argmemonlyZ
avr_intrccZavr_signalccZcallerZcatchpadZcatchretZcatchswitchZ
cleanuppadZ
cleanupretZcomdatZ
convergentZcxx_fast_tlsccZdeplibsZdereferenceableZdereferenceable_or_nullZdistinctZ
exactmatchZexternally_initializedfromZghcccZhhvm_cccZhhvmccZifuncZinaccessiblemem_or_argmemonlyZinaccessiblememonlyZinallocaZ	jumptableZlargestZlocal_unnamed_addrZminsizeZmusttailZnoduplicatesZnoneZnonnullZ	norecurseZnotailZpreserve_allccZpreserve_mostccZprologueZ	safestackZsamesizeZsource_filenameZswiftccZ
swifterrorZ	swiftselfZwebkit_jsccZwithinZ	writeonlyZ
x86_intrccZx86_vectorcallccr_   r`   )
ZvoidZhalfr   ZdoubleZx86_fp80Zfp128Z	ppc_fp128ZlabelZmetadatatokenr~   )r-   r!   rW   N)r5   r6   r7   r8   r9   r:   r;   r<   r=   r?   r   r   r@   rE   r   r   r   r   r   r   r   r   r   r   rG   r2   r2   r2   r3   r   Q  sH   




114c                   @   sz  e Zd ZdZdZdgZddgZdgZdZdZ	d	Z
d
ZdZed e ZdZdZdZdZdZdZejejB Zdejdfeded ejfde eejej ej dfeedfeej dfeej!dfde"fgee#fe	e$j%fe
e$j&fee$j'fee$j(fee$j)fedeej*feej+fde"dfedgdejfdej,dfdejdfgde"fde"fd ej,fgd!e-fd"e.fd#ejfee.j/feej0fgd$Z1d%S )&r   z)
    For Nasm (Intel) assembly code.
    ZNASMZnasm*.asm*.ASMztext/x-nasmz[a-z$._?][\w$.?#@~]*,(?:0x[0-9a-f]+|$0[0-9a-f]*|[0-9]+[0-9a-f]*h)[0-7]+q[01]+brT   \.e?/"(\\"|[^"\n])*"|'(\\'|[^'\n])*'|`(\\`|[^`\n])*`(?:res|d)[bwdqt]|timesor[0-9][0-5]?[bwd]|[a-d][lh]|[er]?[a-d]x|[er]?[sb]p|[er]?[sd]i|[c-gs]s|st[0-7]|mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]seg|wrt|strictbyte|[dq]?wordzBITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|ORG|ALIGN|STRUC|ENDSTRUC|COMMON|CPU|GROUP|UPPERCASE|IMPORT|EXPORT|LIBRARY|MODULE^\s*%preprocr!   r"   z(%s)(\s+)(equ)r$   r%   r(   r'   [^;\n]+r   r+   [ \t]+;.*[,():\[\]]+z[&|^<>+*/%~-]+[$]+r-   r$   r   r!   r(   N)2r5   r6   r7   r8   r9   r:   r;   r<   r?   hexnoctnbinndecnfloatnr=   declkwr   wordopr   
directivesr.   
IGNORECASE	MULTILINEflagsr   Preprocr   r   r@   r   rB   r   DeclarationrA   r   r   r   rD   OctBinr   rC   BuiltinrE   r   r   r   Wordr   rG   r2   r2   r2   r3   r     sr   




c                   @   s.   e Zd ZdZdZdgZdgZdgZee	Z
dS )r   zM
    For the output of 'objdump -d -M intel'.

    .. versionadded:: 2.0
    zobjdump-nasmz*.objdump-intelztext/x-nasm-objdumpN)r5   r6   r7   r8   r9   r:   r;   r<   rI   r   rG   r2   r2   r2   r3   r     s   c                   @   s  e Zd ZdZdZdgZdddgZdgZdZd	Z	d
Z
dZdZed e ZdZdZdZdZdZdZdZejejB Zdejdfeded ejfeedfdeef eej ej!ej!dfeej!dfeej"dfde#fgee$fe	e%j&fe
e%j'fee%j(fee%j)fee%j*fedeej+feej,fdee#ej-e#fde#dfedgdejfd ej-dfd!ejdfgd"e#fd#e#fd$e#fd%ej-fgd&e.fd'e/fd(ej fee/j0feej1fgd)Z2d*S )+r   z3
    For Tasm (Turbo Assembler) assembly code.
    ZTASMZtasmr   r   z*.tasmztext/x-tasmz[@a-z$._?][\w$.?#@~]*r   r   r   rT   r   r   r   r   r   r   zBITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|ORG|ALIGN|STRUC|ENDSTRUC|ENDS|COMMON|CPU|GROUP|UPPERCASE|INCLUDE|EXPORT|LIBRARY|MODULE|PROC|ENDP|USES|ARG|DATASEG|UDATASEG|END|IDEAL|P386|MODEL|ASSUME|CODESEG|SIZEzdb|dd|dw|T[A-Z][a-z]+r   r   r!   r"   r$   z(%s)(\s+)(%s)r%   r(   z(\\\s*)(;.*)([\r\n])r'   r   r   r+   z[\n\r]z\\[\n\r]r   r   r   z[&|^<>+*=/%~-]+r   r   N)3r5   r6   r7   r8   r9   r:   r;   r<   r?   r   r   r   r   r   r=   r   r   r   r   r   Zdatatyper.   r   r   r   r   r   r   r   r@   r   r   rB   r   rA   r   r   r   rD   r   r   r   rC   r   rE   r   r   r   r   r   rG   r2   r2   r2   r3   r     sx   






c                   @   s   e Zd ZdZdZdgZdgZejZ	dde
jfdefdejfd	efd
ejfdefdefdejfdejfdejfdejfdefdefgiZdd ZdS )r   z@
    For ca65 assembler sources.

    .. versionadded:: 1.6
    zca65 assemblerZca65r    r-   r   r,   z[a-z_.@$][\w.@$]*:z((ld|st)[axy]|(in|de)[cxy]|asl|lsr|ro[lr]|adc|sbc|cmp|cp[xy]|cl[cvdi]|se[cdi]|jmp|jsr|bne|beq|bpl|bmi|bvc|bvs|bcc|bcs|p[lh][ap]|rt[is]|brk|nop|ta[xy]|t[xy]a|txs|tsx|and|ora|eor|bit)\bz\.\w+z[-+~*/^&|!<>=]z	"[^"\n]*.z	'[^'\n]*.z\$[0-9a-f]+|[0-9a-f]+h\brZ   z%[01]+z[#,.:()=\[\]]z[a-z_.@$][\w.@$]*c                 C   s   t d|t jrdS d S )Nz^\s*;g?)r.   r/   r   )rN   r1   r2   r2   r3   r4     s    zCa65Lexer.analyse_textN)r5   r6   r7   r8   r9   r:   r;   r.   r   r   r   r   r   r   r@   r   ZPseudor   r   rF   r   rD   rC   r   r   rG   r4   r2   r2   r2   r3   r   _  s0   )%r8   r.   Zpygments.lexerr   r   r   r   r   r   Zpygments.lexers.c_cppr   r	   Zpygments.lexers.dr
   Zpygments.tokenr   r   r   r   r   r   r   r   r   __all__r   rI   r   r   r   r   r   r   r   r   r   r   r2   r2   r2   r3   <module>   s6   
 ,     L1 gIP