B
    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asmz*.sz*.Sz
text/x-gasz"(\\"|[^"])*"z[\w$.@-]z(?:[a-zA-Z$_]z*|\.z+)z(?:0[xX][a-zA-Z0-9]+|\d+)
whitespace:z\.zdirective-argszlock|rep(n?z)?|data\d+zinstruction-argsz[\r\n]+@z#popz	[;#].*?\npunctuationz([a-z0-9]+)( )(<)(z)(>)z)([-+])(%$z
$'(.|\\')'z\nz\s+z[-*,.()\[\]!:]+)rootzdirective-argszinstruction-argsr    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 r+   2lib/python3.7/site-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tokensr-   r+   r+   r+   r,   r      sV   

c             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   r9   r   r   r   r   r=   r:   r   ZPropertyr;   r   )Z	asm_lexerZhex_rer+   r+   r,   _objdump_lexer_tokensf   s6    



rB   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)r.   r/   r0   r1   r2   r3   r4   r5   rB   r   r@   r+   r+   r+   r,   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   )selfoptions)	__class__r+   r,   rD      s    zDObjdumpLexer.__init__)
r.   r/   r0   r1   r2   r3   r4   r5   rD   __classcell__r+   r+   )rG   r,   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 )N)rC   r   rD   r   r   )rE   rF   )rG   r+   r,   rD      s    zCppObjdumpLexer.__init__)
r.   r/   r0   r1   r2   r3   r4   r5   rD   rH   r+   r+   )rG   r,   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 )N)rC   r   rD   r	   r   )rE   rF   )rG   r+   r,   rD      s    zCObjdumpLexer.__init__)
r.   r/   r0   r1   r2   r3   r4   r5   rD   rH   r+   r+   )rG   r,   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-hsailz"[^"]*?"z[a-zA-Z_][\w.]*z[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$   z0[xX][a-fA-F0-9]+z\d+z[=<>{}\[\]()*.,:;!]|x\bz(\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requirenopartialworkgroupsz\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	_readonlyrR   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_satz	i[1-9]\d*)r&   r    rJ   rK   N)(r.   r/   r0   r1   r2   r3   r4   r5   r6   r8   Zregister_numberregisterZ	alignQualZ	widthQualZ	allocQualZroundingModZdatatypeModfloatZhexfloatZ	ieeefloatr   r   r   r9   r>   	AnonymousGlobalr   r=   Floatr<   r   r   r   Z	MultilineSingler   Typer   r@   r+   r+   r+   r,   r      s`   


$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-llvmz"[^"]*?"z([-a-zA-Z$._][\w\-$.]*|rI   r    z\s*:rK   r$   r"   z%\d+z@\d+z#\d+!z!\d+zc?z0[xX][a-fA-F0-9]+z,-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?z[=<>{}\[\]()*.,!]|x\bz(\n|\s)+z;.*?\n(  ZbeginendtrueZfalseZdeclareZdefineri   Zconstantrj   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aliasrM   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readnonerh   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
alignstackrc   ZcatchZcleanupfilterZinteldialectr]   r^   Z	monotonicZnandZpersonalityreleaseZseq_cstZsinglethreadZumaxZuminZ	unorderedZxchgrW   ZfaddrX   Zfsubr_   ZfmulZudivZsdivZfdivZuremZsremZfremrY   ZlshrZashrrZ   r[   r\   ZicmpZfcmpZphirf   rV   ZzextZsextZfptruncZfpextZuitofpZsitofpZfptouiZfptosiZinttoptrZptrtointZbitcastZaddrspacecastZselectZva_argrd   re   ZswitchZinvokeZunwindZunreachableZ
indirectbrZ
landingpadZresumeZmallocrg   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_vectorcallccz\b)rP   )
ZvoidZhalfrn   ZdoubleZx86_fp80Zfp128Z	ppc_fp128ZlabelZmetadatatokenz	i[1-9]\d*)r&   r    rK   N)r.   r/   r0   r1   r2   r3   r4   r5   r6   r8   r   r   r9   r>   rp   ro   r   r   r   r   r   r   r   rs   r@   r+   r+   r+   r,   r   Q  s:   




0
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nasmz*.asmz*.ASMztext/x-nasmz[a-z$._?][\w$.?#@~]*z,(?:0x[0-9a-f]+|$0[0-9a-f]*|[0-9]+[0-9a-f]*h)z[0-7]+qz[01]+bz[0-9]+z\.e?z/"(\\"|[^"\n])*"|'(\\'|[^'\n])*'|`(\\`|[^`\n])*`z(?:res|d)[bwdqt]|timeszor[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]zseg|wrt|strictzbyte|[dq]?wordzBITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|ORG|ALIGN|STRUC|ENDSTRUC|COMMON|CPU|GROUP|UPPERCASE|IMPORT|EXPORT|LIBRARY|MODULEz^\s*%preprocr    r!   z(%s)(\s+)(equ)zinstruction-argsz[\r\n]+r#   z#popz[^;\n]+z;.*?\nz\nz[ \t]+z;.*z[,():\[\]]+z[&|^<>+*/%~-]+z[$]+)r&   zinstruction-argsr   r    r#   N)2r.   r/   r0   r1   r2   r3   r4   r5   r8   hexnoctnbinndecnfloatnr6   declkwrm   wordopr   
directivesr'   
IGNORECASE	MULTILINEflagsr   Preprocr   r   r9   r   r;   r   Declarationr:   r   r   r   r=   OctBinrq   r<   Builtinr>   rr   r   r   Wordrs   r@   r+   r+   r+   r,   r     sd   




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)r.   r/   r0   r1   r2   r3   r4   r5   rB   r   r@   r+   r+   r+   r,   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tasmz*.asmz*.ASMz*.tasmztext/x-tasmz[@a-z$._?][\w$.?#@~]*z,(?:0x[0-9a-f]+|$0[0-9a-f]*|[0-9]+[0-9a-f]*h)z[0-7]+qz[01]+bz[0-9]+z\.e?z/"(\\"|[^"\n])*"|'(\\'|[^'\n])*'|`(\\`|[^`\n])*`z(?:res|d)[bwdqt]|timeszor[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]zseg|wrt|strictzbyte|[dq]?wordzBITS|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]+z^\s*%r   r    r!   zinstruction-argsz(%s)(\s+)(%s)z[\r\n]+r#   z(\\\s*)(;.*)([\r\n])z#popz[^;\n]+z;.*?\nz\nz[\n\r]z\\[\n\r]z[ \t]+z;.*z[,():\[\]]+z[&|^<>+*=/%~-]+z[$]+)r&   zinstruction-argsr   r    r#   N)3r.   r/   r0   r1   r2   r3   r4   r5   r8   r   r   r   r   r   r6   r   rm   r   r   r   Zdatatyper'   r   r   r   r   r   r   r   r9   r   r   r;   r   r:   r   r   r   r=   r   r   rq   r<   r   r>   rr   r   r   r   rs   r@   r+   r+   r+   r,   r     sj   






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ca65z*.sr&   z;.*z\s+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\bz\d+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   )rE   r*   r+   r+   r,   r-     s    zCa65Lexer.analyse_textN)r.   r/   r0   r1   r2   r3   r4   r'   r   r   r   rr   r   r   r9   r   ZPseudor   r   r?   r   r=   r<   r   r   r@   r-   r+   r+   r+   r,   r   _  s*   )%r1   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   rB   r   r   r   r   r   r   r   r   r   r   r+   r+   r+   r,   <module>
   s*    ,
L1 gIP