U
    a`q                     @   s   d Z ddlZddlmZmZmZmZmZ ddlm	Z	m
Z
mZmZmZmZmZmZmZmZ ddlmZ dddd	gZG d
d deZedZG dd deZG dd deZG dd	 d	eZdS )z
    pygments.lexers.matlab
    ~~~~~~~~~~~~~~~~~~~~~~

    Lexers for Matlab and related languages.

    :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    N)Lexer
RegexLexerbygroupswordsdo_insertions)
TextCommentOperatorKeywordNameStringNumberPunctuationGeneric
Whitespace)_scilab_builtinsMatlabLexerMatlabSessionLexerOctaveLexerScilabLexerc                   @   s6  e Zd ZdZdZdgZdgZdgZdZdZ	dZ
d	ejfd
ejdfdefdedfedddefddee	 e
  d ejfdefdefdefdefdefdefdejfdejfdejfdedfd efd!efgd"ed#fgd$ejd#fd%ejfd!ejfgd&eeeeeeejeeee
d#fd'eeejd#fgd(Zd)d* Zd+S ),r   z=
    For Matlab source code.

    .. versionadded:: 0.10
    ZMatlabZmatlab*.mztext/matlab)CsinsindsinhasinasindasinhcoscosdcoshacosacosdacoshtantandtanhatanatandZatan2atanhsecsecdsechasecasecdasechcsccscdcschacscacscdacschcotcotdcothacotacotdacothhypotexpZexpm1logZlog1pZlog10Zlog2Zpow2realpowreallogrealsqrtsqrtnthrootZnextpow2absanglecomplexconjimagrealunwrapisrealcplxpairfixfloorceilroundmodremsign)'airybesseljbesselybesselhbesselibesselkbetabetaincbetalnZellipjZellipkeerferfcerfcxerfinvZexpintgammagammaincgammalnZpsilegendrecrossdotfactorisprimeprimesgcdlcmratratspermsnchoosek	factorialZcart2sphZcart2polZpol2cartZsph2cartZhsv2rgbZrgb2hsv)CzerosoneseyerepmatrandrandnlinspacelogspaceZ	freqspacemeshgrid
accumarraysizelengthndimsnumeldispisemptyisequalisequalwithequalnanscatreshapediagblkdiagtriltriufliplrflipudflipdimZrot90findendZsub2indZind2subbsxfunndgridpermuteipermuteshiftdim	circshiftsqueezeisscalarisvectorZansepsrealmaxrealminpiiinfnanisnanisinfisfinitejZwhycompanZgalleryhadamardhankelhilbinvhilbmagicpascalrossertoeplitzvander	wilkinsonz^!.*z%\{\s*\nblockcommentz%.*$^\s*functiondeffunc)breakcasecatchclassdefcontinueelseelseifr   Z
enumeratedeventsforfunctionglobalifmethods	otherwiseZparfor
persistent
propertiesreturnZspmdswitchtrywhile\bsuffix(|z)\bz	\.\.\..*$-|==|~=|<|>|<=|>=|&&|&|~|\|\|?\.\*|\*|\+|\.\^|\.\\|\.\/|\/|\\z\[|\]|\(|\)|\{|\}|:|@|\.|,=|:|;(?<=[\w)\].])\'+&(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?\d+[eEf][+-]?[0-9]+\d+(?<![\w)\].])\'string[a-zA-Z_]\w*.z[^\']*\'#popz^\s*%\}z^.*\n1(\s*)(?:(\S+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)(\s*)([a-zA-Z_]\w*))rootr   r   r   c                 C   s,   t d| t jrdS t d| t jr(dS d S )Nz^\s*%g?z^!\w+)rematchM)text r   8/usr/lib/python3/dist-packages/pygments/lexers/matlab.pyanalyse_text   s    zMatlabLexer.analyse_textN)__name__
__module____qualname____doc__namealiases	filenames	mimetypesZelfunZspecfunZelmatr   ZOtherr   Z	Multiliner
   r   joinr   Builtinr	   r   r   FloatIntegerr   r   r   Functiontokensr   r   r   r   r   r      sh   
+

    =z.*?
c                   @   s"   e Zd ZdZdZdgZdd ZdS )r   z
    For Matlab sessions.  Modeled after PythonConsoleLexer.
    Contributed by Ken Schutte <kschutte@csail.mit.edu>.

    .. versionadded:: 0.10
    zMatlab sessionZmatlabsessionc           
   	   c   s@  t f | j}d}g }t|D ]}| }|drj|t|dtj	|d d fgf ||dd  7 }q|dr|t|dtj	|d d fgf ||dd  7 }q|drt|}dtj
|f}|||gf q|rt|||D ]
}	|	V  qd}g }| tj|fV  q|r<t|||D ]}	|	V  q.d S )N z>> r      z>>   z???)r   Zoptionsline_refinditergroup
startswithappendlenr   ZPrompt	Tracebackr   get_tokens_unprocessedstartZOutput)
selfr   ZmlexerZcurcodeZ
insertionsr   lineidxtokenitemr   r   r   r      sD    




  z)MatlabSessionLexer.get_tokens_unprocessedN)r   r   r   r   r   r   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Z	dZ
d	Zd
ZdZdefdedfedddefeee	 e
 e e ddejfeeddejfdefdefdefdefdefdefdefdejfdejfdejfdefdedfdefd efgd!ed"fgd#eeeeeeejeeee
d"fd$eeejd"fgd%Zd&S )'r   z@
    For GNU Octave source code.

    .. versionadded:: 1.5
    ZOctaveZoctaver   ztext/octave(=  ZaddlistenerZaddpathZaddpropertyallandanyZargnamesargvZassigninatexitZautoloadZavailable_graphics_toolkitsZbeep_on_errorZbitandZbitmaxZbitorZbitshiftZbitxorr   ZcellZcellstrcharclassZclccolumnsZcommand_line_pathZcompletion_append_charZcompletion_matchesrE   Zconfirm_recursive_rmdirZcputimeZcrash_dumps_octave_coreZ
ctransposeZcumprodZcumsumZdebug_on_errorZdebug_on_interruptZdebug_on_warningZdefault_save_optionsZdellistenerr   Zdiffr~   Zdoc_cache_fileZdo_string_escapesZdoubleZdrawnoweZecho_executing_commandsr   eqerrnoZ
errno_listerrorevalZevalinexecZexistexitrr   ZfalseZfclearZfcloseZfcntlZfdispZfeofZferrorZfevalZfflushZfgetlZfgetsZ
fieldnamesZfile_in_loadpathZfile_in_pathZ
filemarkerZfilesepZfind_dir_in_pathZfixed_point_formatZfnmatchZfopenforkZformulaZfprintfZfputsZfreadZfreportZfrewindZfscanfZfseekZfskiplZftellZ	functionsZfwritegeZgenpathgetgetegidgetenvgeteuidgetgidgetpgrpgetpidgetppidgetuidglobgtZgui_modeZhistory_controlZhistory_fileZhistory_sizeZhistory_timestamp_format_stringhomeZhorzcatr;   ZifelseZignore_function_time_stampZ
inferiortoZ	info_fileZinfo_programZinlineinputZintmaxZintminr   Zis_absolute_filenameZisargoutZisboolZiscellZ	iscellstrZischarZ	iscomplexr   ZisfieldZisfloatZisglobalZishandleZisieeeZisindexZ	isintegerZ	islogicalZismatrixZismethodZisnull	isnumericZisobjectrJ   Zis_rooted_relative_filenameZissortedZisstructZ	isvarnameZkbhitZkeyboardkillZlasterrZ	lasterrorZlastwarnZldivideler{   linkrv   ZlogicallstatltZmake_absolute_filenameZmakeinfo_programZmax_recursion_depthmerger   Z	mfilenameZminusZ	mislockedmkdirmkfifoZmkstempZmldivideZmlockZmouse_wheel_zoomZmpowerZmrdivideZmtimesZmunlockZnarginZnargoutZnative_float_formatr|   neZnfieldsZnnzZnormnotr}   ZnzmaxZoctave_config_infoZoctave_core_file_limitZoctave_core_file_nameZoctave_core_file_optionsrq   orZoutput_max_field_widthZoutput_precisionZpage_output_immediatelyZpage_screen_outputpathpathseppauseZpcloser   r   pipeZpluspopenZpowerZprint_empty_dimensionsZprintfZprint_struct_array_contentsZprodZprogram_invocation_nameZprogram_nameputenvZputspwdquitrl   ZrdivideZreaddirreadlinkZread_readline_init_filer   r   ZrehashrenameZrepelemsZre_read_readline_init_fileresetr   ZresizeZrestoredefaultpathZrethrowrmdirZrmfieldZrmpathZrowsZsave_header_format_stringZsave_precisionZsaving_historyZscanfsetZsetenvZ	shell_cmdZsighup_dumps_octave_coreZsigterm_dumps_octave_coreZsilent_functionsZsinglerz   Z
size_equalZsizemaxZsizeofsleepsourceZsparse_auto_mutateZsplit_long_rowsZsprintfr   ZsscanfstatstderrstdinstdoutZstrcmpZstrcmpiZstring_fill_charZstrncmpZstrncmpiZstructZstruct_levels_to_printZstrvcatZsubsasgnZsubsrefsumZsumsqZ
superiortoZsuppress_verbose_help_messagesymlinksystemZticZtilde_expandtimesZtmpfileZtmpnamZtocZtoupperZ	transposetrueZtypeinfoumaskZuminusunameZundo_string_escapesunlinkZuplusupperZusageZusleepZvecZ	vectorizeZvertcatwaitpidZwarningZwarrantyZwhos_line_formatZ	yes_or_norp   r   ZInfr   ZNaN)closeloadZwhoZwhos(h  ry   Zaccumdimr!   r9   r3   Z	addtodateZallchildZancestorZanovaZarch_fitZarch_rndZ	arch_testZareaZarma_rndZarrayfunasciiasctimer-   r   assertr'   Zautoreg_matrixZautumnZaxesZaxisZbarZbarhZbartlettZbartlett_testZbeepZbetacdfZbetainvZbetapdfZbetarndZbicgstabZbicubicbinaryZbinocdfZbinoinvZbinopdfZbinorndZbitcmpZbitgetZbitsetZblackmanZblanksr   ZboneZboxZbrightenZcalendarcastZ
cauchy_cdfZ
cauchy_invZ
cauchy_pdfZ
cauchy_rndZcaxisZcelldispcenterZcgsZchisquare_test_homogeneityZchisquare_test_independencer   ZclaZclabelZclfZclockZcloglogZclosereqZcolonZcolorbarZcolormapZcolpermZcometZcommon_sizeZcommutation_matrixr   Zcompare_versionsZcompassZcomputerZcondZcondestZcontourZcontourcZcontourfZcontrastZconvZconvhullZcoolZcopperZcopyfileZcorZcorrcoefZcor_testr   r6   ZcovrK   rd   r0   ZcstrcatZcsvreadZcsvwritectimeZcumtrapzZcurlZcutZcylinderdateZdatenumZdatestrZdatetickZdatevecZdblquadZdealZdeblankZdeconvZdelaunayZ	delaunayndeleteZdemoZdetrendZdiffparaZdiffusedirZdiscrete_cdfZdiscrete_invZdiscrete_pdfZdiscrete_rndZdisplayZ
divergenceZdlmwriteZdosZdsearchZdsearchnZduplication_matrixZdurbinlevinsonZ	ellipsoidZempirical_cdfZempirical_invZempirical_pdfZempirical_rndZeomdayZerrorbarZetimeZ	etreeplotZexampleZexpcdfZexpinvZexpmZexppdfZexprndZ	ezcontourZ
ezcontourfZezmeshZezmeshcZezplotZezpolarZezsurfZezsurfcrf   ro   ZfailZfcdfZfeatherZfftconvZfftfiltZfftshiftZfigureZ
fileattribZ	filepartsZfillfindallZfindobjZfindstrZfinvflagr   r   r   ZfpdfZfplotZ	fractdiffZfreqzZ
freqz_plotZfrndZfsolveZf_test_regressionZftpZfullfileZfzeroZgamcdfZgaminvZgampdfZgamrndZgcaZgcbfZgcboZgcfZ
genvarnameZgeocdfZgeoinvZgeopdfZgeorndZgetfieldZginputZglpkZglsZgplotZgradientZgraphics_toolkitZgrayZgridZgriddataZ	griddatanZgtextZgunzipZgzipr   Zhammingr   ZhanningZhggroupZhiddenr   ZhistZhistcZholdZhotZhotelling_testZhoushZhsvZhurstZhygecdfZhygeinvZhygepdfZhygerndZidivideZ	ifftshiftZimageZimagescZimfinfoZimreadZimshowZimwriteindexinfoZ	inpolygonZ	inputnameZinterpftZinterpnZ	intersectr   ZiqrZisaZ
isdefiniteisdirZis_duplicate_entryr   r   ZisfigureZishermitianZ
ishghandleZis_leap_yearZisletterZismacZismemberZispcrg   Zispropr   ZissquareZ	isstrpropZissymmetricZisunixZis_valid_file_idr   ZjetZkendallZkolmogorov_smirnov_cdfZkolmogorov_smirnov_testZkruskal_wallis_testZkrylovZkurtosisZlaplace_cdfZlaplace_invZlaplace_pdfZlaplace_rndZlegendrc   licenser   ZlinkpropZlist_primesZ	loadaudioZloadobjZlogistic_cdfZlogistic_invZlogistic_pdfZlogistic_rndZlogitZloglogZ	loglogerrZlogmZlogncdfZlogninvZlognpdfZlognrndrw   ZlookforZ
ls_commandZ	lsqnonnegr   ZmahalanobisZmanovaZ
matlabrootZmcnemar_testZmeanZmeansqZmedianZmenuZmeshZmeshcrx   ZmeshzZmexextZmgetZmkppmodeZmomentZmovefileZmpolesZmputZnamelengthmaxZnargchkZ
nargoutchkZnbincdfZnbininvZnbinpdfZnbinrndrn   r   ZnewplotZnewsZnonzerosZnormcdfZnormestZnorminvZnormpdfZnormrndZnowrB   ZnullZoceanZolsZ
onenormestZoptimgetZoptimsetZorderfieldsZorientZorthZpackZparetoZparseparamsr   ZpatchZpathdefZpcgZpchipZpcolorZpcrZpeaksZperiodogramZperlrm   ZpieZpinkZplanerotZ	playaudioZplotZ
plotmatrixZplotyyZpoisscdfZpoissinvZpoisspdfZpoissrndZpolarZpolyZ
polyaffineZpolyareaZ	polyderivZpolyfitZpolygcdZpolyintZpolyoutZ
polyreduceZpolyvalZpolyvalmZpostpadZpowersetZppderZppintZppjumpsZppplotZppvalZ	pqpnonnegZprepadrh   printZprint_usageZprismZprobitZqpZqqplotZquadccZquadgkZquadlZquadvZquiverZqzhessZrainbowZrandirangeZrankZranksrk   r?   r>   r@   recordZrectangle_lwZrectangle_swZrectintZrefreshZrefreshdataZregexptranslaters   ZresidueZribbonrindexrootsZroser   ZrotdimZrrefrunZ	run_countZrundemosZrun_testZruntestsZsaveasZ	saveaudioZsaveobjZsavepathZscatterr*   ZsemilogxZsemilogxerrZsemilogyZsemilogyerrZsetaudioZsetdiffZsetfieldZsetxorZshadingshiftr   Z	sign_testZsincr   ZsinetoneZsinewaveZskewnesssliceZsombreroZsortrowsZ	spaugmentZ	spconvertZspdiagsZspearmanZspectral_adfZspectral_xdfZspecularZspeedZspencerZspeyeZspfunZsphereZspinmapZsplineZsponesZsprandZsprandnZ	sprandsymZspringZspstatsZspyZsqpZstairsZ
statisticsZstdZstdnormal_cdfZstdnormal_invZstdnormal_pdfZstdnormal_rndZstemZstftZstrcatZstrchrZstrjustZstrmatchZstrreadZstrsplitZstrtokZstrtrimZstrtruncZ	structfunZ
studentizeZsubplotZ	subsindexZsubspaceZsubstrZ	substructZsummerZsurfZsurfaceZsurfcZsurflZsurfnormZsvdsZ	swapbytesZsylvester_matrixZsymvarZ	synthesistabler$   ZtarZtcdfZtempdirZtempnameZtestr   ZtextreadZtextscanZtinvtitler   ZtpdfZtraceZtrapzZ
treelayoutZtreeplotZtriangle_lwZtriangle_swr   ZtrimeshZ
triplequadZtriplotZtrisurfr   ZtrndZtsearchnZt_testZt_test_regressiontypeZunidcdfZunidinvZunidpdfZunidrndZunifcdfZunifinvZunifpdfZunifrndunionuniqueZunixZunmkppZunpackZuntabifyZuntarrI   ZunzipZu_testZvalidatestringr   varZvar_testZvechZverversionZviewZvoronoiZvoronoinZwaitforbuttonpressZwavreadZwavwriteZwblcdfZwblinvZwblpdfZwblrndZweekdayZ
welch_testZwhatZwhiteZwhitebgZwienrndZwilcoxon_testr   ZwinterZxlabelZxlimZylabelZ
yulewalkerzipZzlabelZz_test)rS   ZamdZbalancerV   rW   rT   rX   rU   Zbitpackr   ZbuiltinZccolamdZcellfunZ
cellslicesZcholZ
choldeleteZ
cholinsertZcholinvZ	cholshiftZ
cholupdateZcolamdZcollocZ	convhullnZconvnZcsymamdZcummaxZcumminZdaspkZdaspk_optionsZdasrtZdasrt_optionsZdasslZdassl_optionsZdbclearZdbdownZdbstackZdbstatusZdbstopZdbtypeZdbupZdbwhereZdetZdlmreadZdmpermre   ZeigZeigsZendgrentZendpwentZetreeZfftZfftnZfftwfilterr   Zfullri   ZgetgrentZgetgrgidZgetgrnamZgetpwentgetpwnamgetpwuidZ	getrusageZgivensgmtimeZgnuplot_binaryZhessZifftZifftninvZisdebugmodeZissparseZkron	localtimelookupZlsodeZlsode_optionsZluZluincZluupdateZmatrix_typemaxminmktimeZpinvZqrZqrdeleteZqrinsertZqrshiftZqrupdateZquadZquad_optionsZqzrt   ZrandeZrandgru   ZrandpZrandpermZrcondZregexpZregexpiZ	regexprepZschurZsetgrentZsetpwentsortZspallocZsparseZspparmsZsprankZsqrtmZstrfindstrftimestrptimeZstrrepZsvdZ
svd_driverZsylZsymamdZsymbfactZsymrcmtimeZtsearchZtypecastZurlreadZurlwrite)MrC   r    r"   r8   r:   r2   r4   rD   argr,   r.   r   r   r&   r(   rY   rZ   r[   ZbincoeffZcbrtrN   rF   r   r   r5   r7   r/   r1   r\   r]   r^   r_   r<   ZfiniterL   rM   Zfmodr`   ra   rb   rG   isalnumisalphaisasciiZiscntrlisdigitr   Zisgraphr   islowerZisnar   ZisprintZispunctisspaceisupperZisxdigitrj   Zlgammar=   lowerrP   rH   rQ   rO   Zroundbr)   r+   rR   r   r   rA   r#   r%   Ztoasciitolowerxor)ZEDITORZ	EXEC_PATHIZ
IMAGE_PATHZNAZOCTAVE_HOMEZOCTAVE_VERSIONZPAGERZPAGER_FLAGSSEEK_CURSEEK_ENDSEEK_SETZSIGS_ISBLKS_ISCHRS_ISDIRS_ISFIFOS_ISLNKS_ISREGS_ISSOCKZ	WCONTINUE	WCOREDUMPWEXITSTATUSWIFCONTINUED	WIFEXITEDWIFSIGNALED
WIFSTOPPEDWNOHANGWSTOPSIGWTERMSIG	WUNTRACEDz[%#].*$r   r   )Z__FILE__Z__LINE__r   r   r   r   r   Zdor   r   r   Zend_try_catchZend_unwind_protectZendclassdefZ	endeventsZendforZendfunctionZendifZ
endmethodsZendpropertiesZ	endswitchZendwhiler   r   r   r  r   r   r   r   r   r   r   r3  Zstaticr   r   ZuntilZunwind_protectZunwind_protect_cleanupr   r   r   z-=|!=|!|/=|--r   z$\*=|\+=|\^=|\/=|\\=|\*\*|\+\+|\.\*\*r   z[\[\](){}:@.,]r   "[^"]*"r   r   r   r   r   r   r   r   [^']*'r   r   r   r   r   r   N)r   r   r   r   r   r   r   r   Z
builtin_kwZ
command_kwZfunction_kwZloadable_kwZ
mapping_kwZbuiltin_constsr   r
   r   r   r   Constantr	   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      sp   Z 	1
    c                   @   s  e Zd ZdZdZdgZdddgZdgZdej	fd	e
d
feddde
feejej ej ddejfeejddejfdefdefdefdefdefdedfdejfdejfdejfdefdefgdedfdedfgdeeeeeeejeeee
dfdeeejdfgdZdS ) r   z<
    For Scilab source code.

    .. versionadded:: 1.5
    ZScilabZscilabz*.sciz*.scez*.tstztext/scilabz//.*?$r   r   r  r   r   r   r   z[\[\](){}@.,=:;]r  r   r   r   r   r   r   r   r   r  r   r   r   r  N)r   r   r   r   r   r   r   r   r   Singler
   r   r   Zfunctions_kwZcommands_kwZ	macros_kwr   r   Zvariables_kwr  r	   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   V  sf   
	*
    )r   r   Zpygments.lexerr   r   r   r   r   Zpygments.tokenr   r   r	   r
   r   r   r   r   r   r   Zpygments.lexersr   __all__r   compiler   r   r   r   r   r   r   r   <module>   s   
0x
6   