Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
freefem.py894 linesDownload Raw Back to lexers
1"""2    pygments.lexers.freefem3    ~~~~~~~~~~~~~~~~~~~~~~~4 5    Lexer for FreeFem++ language.6 7    :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.8    :license: BSD, see LICENSE for details.9"""10 11from pygments.token import Comment, Operator, Keyword, Name12 13from pygments.lexers.c_cpp import CppLexer14 15__all__ = ['FreeFemLexer']16 17 18class FreeFemLexer(CppLexer):19    """20    For FreeFem++ source.21 22    This is an extension of the CppLexer, as the FreeFem Language is a superset23    of C++.24    """25 26    name = 'Freefem'27    url = 'https://freefem.org/'28    aliases = ['freefem']29    filenames = ['*.edp']30    mimetypes = ['text/x-freefem']31    version_added = '2.4'32 33    # Language operators34    operators = {'+', '-', '*', '.*', '/', './', '%', '^', '^-1', ':', '\''}35 36    # types37    types = {'bool', 'border', 'complex', 'dmatrix', 'fespace', 'func', 'gslspline',38             'ifstream', 'int', 'macro', 'matrix', 'mesh', 'mesh3', 'mpiComm',39             'mpiGroup', 'mpiRequest', 'NewMacro', 'EndMacro', 'ofstream', 'Pmmap',40             'problem', 'Psemaphore', 'real', 'solve', 'string', 'varf'}41 42    # finite element spaces43    fespaces = {'BDM1', 'BDM1Ortho', 'Edge03d', 'Edge13d', 'Edge23d', 'FEQF', 'HCT',44                'P0', 'P03d', 'P0Edge', 'P1', 'P13d', 'P1b', 'P1b3d', 'P1bl', 'P1bl3d',45                'P1dc', 'P1Edge', 'P1nc', 'P2', 'P23d', 'P2b', 'P2BR', 'P2dc', 'P2Edge',46                'P2h', 'P2Morley', 'P2pnc', 'P3', 'P3dc', 'P3Edge', 'P4', 'P4dc',47                'P4Edge', 'P5Edge', 'RT0', 'RT03d', 'RT0Ortho', 'RT1', 'RT1Ortho',48                'RT2', 'RT2Ortho'}49 50    # preprocessor51    preprocessor = {'ENDIFMACRO', 'include', 'IFMACRO', 'load'}52 53    # Language keywords54    keywords = {55                'adj',56                'append',57                'area',58                'ARGV',59                'be',60                'binary',61                'BoundaryEdge',62                'bordermeasure',63                'CG',64                'Cholesky',65                'cin',66                'cout',67                'Crout',68                'default',69                'diag',70                'edgeOrientation',71                'endl',72                'false',73                'ffind',74                'FILE',75                'find',76                'fixed',77                'flush',78                'GMRES',79                'good',80                'hTriangle',81                'im',82                'imax',83                'imin',84                'InternalEdge',85                'l1',86                'l2',87                'label',88                'lenEdge',89                'length',90                'LINE',91                'linfty',92                'LU',93                'm',94                'max',95                'measure',96                'min',97                'mpiAnySource',98                'mpiBAND',99                'mpiBXOR',100                'mpiCommWorld',101                'mpiLAND',102                'mpiLOR',103                'mpiLXOR',104                'mpiMAX',105                'mpiMIN',106                'mpiPROD',107                'mpirank',108                'mpisize',109                'mpiSUM',110                'mpiUndefined',111                'n',112                'N',113                'nbe',114                'ndof',115                'ndofK',116                'noshowbase',117                'noshowpos',118                'notaregion',119                'nt',120                'nTonEdge',121                'nuEdge',122                'nuTriangle',123                'nv',124                'P',125                'pi',126                'precision',127                'qf1pE',128                'qf1pElump',129                'qf1pT',130                'qf1pTlump',131                'qfV1',132                'qfV1lump',133                'qf2pE',134                'qf2pT',135                'qf2pT4P1',136                'qfV2',137                'qf3pE',138                'qf4pE',139                'qf5pE',140                'qf5pT',141                'qfV5',142                'qf7pT',143                'qf9pT',144                'qfnbpE',145                'quantile',146                're',147                'region',148                'rfind',149                'scientific',150                'searchMethod',151                'setw',152                'showbase',153                'showpos',154                'sparsesolver',155                'sum',156                'tellp',157                'true',158                'UMFPACK',159                'unused',160                'whoinElement',161                'verbosity',162                'version',163                'volume',164                'x',165                'y',166                'z'167    }168 169    # Language shipped functions and class ( )170    functions = {171                'abs',172                'acos',173                'acosh',174                'adaptmesh',175                'adj',176                'AffineCG',177                'AffineGMRES',178                'arg',179                'asin',180                'asinh',181                'assert',182                'atan',183                'atan2',184                'atanh',185                'atof',186                'atoi',187                'BFGS',188                'broadcast',189                'buildlayers',190                'buildmesh',191                'ceil',192                'chi',193                'complexEigenValue',194                'copysign',195                'change',196                'checkmovemesh',197                'clock',198                'cmaes',199                'conj',200                'convect',201                'cos',202                'cosh',203                'cube',204                'd',205                'dd',206                'dfft',207                'diffnp',208                'diffpos',209                'dimKrylov',210                'dist',211                'dumptable',212                'dx',213                'dxx',214                'dxy',215                'dxz',216                'dy',217                'dyx',218                'dyy',219                'dyz',220                'dz',221                'dzx',222                'dzy',223                'dzz',224                'EigenValue',225                'emptymesh',226                'erf',227                'erfc',228                'exec',229                'exit',230                'exp',231                'fdim',232                'floor',233                'fmax',234                'fmin',235                'fmod',236                'freeyams',237                'getARGV',238                'getline',239                'gmshload',240                'gmshload3',241                'gslcdfugaussianP',242                'gslcdfugaussianQ',243                'gslcdfugaussianPinv',244                'gslcdfugaussianQinv',245                'gslcdfgaussianP',246                'gslcdfgaussianQ',247                'gslcdfgaussianPinv',248                'gslcdfgaussianQinv',249                'gslcdfgammaP',250                'gslcdfgammaQ',251                'gslcdfgammaPinv',252                'gslcdfgammaQinv',253                'gslcdfcauchyP',254                'gslcdfcauchyQ',255                'gslcdfcauchyPinv',256                'gslcdfcauchyQinv',257                'gslcdflaplaceP',258                'gslcdflaplaceQ',259                'gslcdflaplacePinv',260                'gslcdflaplaceQinv',261                'gslcdfrayleighP',262                'gslcdfrayleighQ',263                'gslcdfrayleighPinv',264                'gslcdfrayleighQinv',265                'gslcdfchisqP',266                'gslcdfchisqQ',267                'gslcdfchisqPinv',268                'gslcdfchisqQinv',269                'gslcdfexponentialP',270                'gslcdfexponentialQ',271                'gslcdfexponentialPinv',272                'gslcdfexponentialQinv',273                'gslcdfexppowP',274                'gslcdfexppowQ',275                'gslcdftdistP',276                'gslcdftdistQ',277                'gslcdftdistPinv',278                'gslcdftdistQinv',279                'gslcdffdistP',280                'gslcdffdistQ',281                'gslcdffdistPinv',282                'gslcdffdistQinv',283                'gslcdfbetaP',284                'gslcdfbetaQ',285                'gslcdfbetaPinv',286                'gslcdfbetaQinv',287                'gslcdfflatP',288                'gslcdfflatQ',289                'gslcdfflatPinv',290                'gslcdfflatQinv',291                'gslcdflognormalP',292                'gslcdflognormalQ',293                'gslcdflognormalPinv',294                'gslcdflognormalQinv',295                'gslcdfgumbel1P',296                'gslcdfgumbel1Q',297                'gslcdfgumbel1Pinv',298                'gslcdfgumbel1Qinv',299                'gslcdfgumbel2P',300                'gslcdfgumbel2Q',301                'gslcdfgumbel2Pinv',302                'gslcdfgumbel2Qinv',303                'gslcdfweibullP',304                'gslcdfweibullQ',305                'gslcdfweibullPinv',306                'gslcdfweibullQinv',307                'gslcdfparetoP',308                'gslcdfparetoQ',309                'gslcdfparetoPinv',310                'gslcdfparetoQinv',311                'gslcdflogisticP',312                'gslcdflogisticQ',313                'gslcdflogisticPinv',314                'gslcdflogisticQinv',315                'gslcdfbinomialP',316                'gslcdfbinomialQ',317                'gslcdfpoissonP',318                'gslcdfpoissonQ',319                'gslcdfgeometricP',320                'gslcdfgeometricQ',321                'gslcdfnegativebinomialP',322                'gslcdfnegativebinomialQ',323                'gslcdfpascalP',324                'gslcdfpascalQ',325                'gslinterpakima',326                'gslinterpakimaperiodic',327                'gslinterpcsplineperiodic',328                'gslinterpcspline',329                'gslinterpsteffen',330                'gslinterplinear',331                'gslinterppolynomial',332                'gslranbernoullipdf',333                'gslranbeta',334                'gslranbetapdf',335                'gslranbinomialpdf',336                'gslranexponential',337                'gslranexponentialpdf',338                'gslranexppow',339                'gslranexppowpdf',340                'gslrancauchy',341                'gslrancauchypdf',342                'gslranchisq',343                'gslranchisqpdf',344                'gslranerlang',345                'gslranerlangpdf',346                'gslranfdist',347                'gslranfdistpdf',348                'gslranflat',349                'gslranflatpdf',350                'gslrangamma',351                'gslrangammaint',352                'gslrangammapdf',353                'gslrangammamt',354                'gslrangammaknuth',355                'gslrangaussian',356                'gslrangaussianratiomethod',357                'gslrangaussianziggurat',358                'gslrangaussianpdf',359                'gslranugaussian',360                'gslranugaussianratiomethod',361                'gslranugaussianpdf',362                'gslrangaussiantail',363                'gslrangaussiantailpdf',364                'gslranugaussiantail',365                'gslranugaussiantailpdf',366                'gslranlandau',367                'gslranlandaupdf',368                'gslrangeometricpdf',369                'gslrangumbel1',370                'gslrangumbel1pdf',371                'gslrangumbel2',372                'gslrangumbel2pdf',373                'gslranlogistic',374                'gslranlogisticpdf',375                'gslranlognormal',376                'gslranlognormalpdf',377                'gslranlogarithmicpdf',378                'gslrannegativebinomialpdf',379                'gslranpascalpdf',380                'gslranpareto',381                'gslranparetopdf',382                'gslranpoissonpdf',383                'gslranrayleigh',384                'gslranrayleighpdf',385                'gslranrayleightail',386                'gslranrayleightailpdf',387                'gslrantdist',388                'gslrantdistpdf',389                'gslranlaplace',390                'gslranlaplacepdf',391                'gslranlevy',392                'gslranweibull',393                'gslranweibullpdf',394                'gslsfairyAi',395                'gslsfairyBi',396                'gslsfairyAiscaled',397                'gslsfairyBiscaled',398                'gslsfairyAideriv',399                'gslsfairyBideriv',400                'gslsfairyAiderivscaled',401                'gslsfairyBiderivscaled',402                'gslsfairyzeroAi',403                'gslsfairyzeroBi',404                'gslsfairyzeroAideriv',405                'gslsfairyzeroBideriv',406                'gslsfbesselJ0',407                'gslsfbesselJ1',408                'gslsfbesselJn',409                'gslsfbesselY0',410                'gslsfbesselY1',411                'gslsfbesselYn',412                'gslsfbesselI0',413                'gslsfbesselI1',414                'gslsfbesselIn',415                'gslsfbesselI0scaled',416                'gslsfbesselI1scaled',417                'gslsfbesselInscaled',418                'gslsfbesselK0',419                'gslsfbesselK1',420                'gslsfbesselKn',421                'gslsfbesselK0scaled',422                'gslsfbesselK1scaled',423                'gslsfbesselKnscaled',424                'gslsfbesselj0',425                'gslsfbesselj1',426                'gslsfbesselj2',427                'gslsfbesseljl',428                'gslsfbessely0',429                'gslsfbessely1',430                'gslsfbessely2',431                'gslsfbesselyl',432                'gslsfbesseli0scaled',433                'gslsfbesseli1scaled',434                'gslsfbesseli2scaled',435                'gslsfbesselilscaled',436                'gslsfbesselk0scaled',437                'gslsfbesselk1scaled',438                'gslsfbesselk2scaled',439                'gslsfbesselklscaled',440                'gslsfbesselJnu',441                'gslsfbesselYnu',442                'gslsfbesselInuscaled',443                'gslsfbesselInu',444                'gslsfbesselKnuscaled',445                'gslsfbesselKnu',446                'gslsfbessellnKnu',447                'gslsfbesselzeroJ0',448                'gslsfbesselzeroJ1',449                'gslsfbesselzeroJnu',450                'gslsfclausen',451                'gslsfhydrogenicR1',452                'gslsfdawson',453                'gslsfdebye1',454                'gslsfdebye2',455                'gslsfdebye3',456                'gslsfdebye4',457                'gslsfdebye5',458                'gslsfdebye6',459                'gslsfdilog',460                'gslsfmultiply',461                'gslsfellintKcomp',462                'gslsfellintEcomp',463                'gslsfellintPcomp',464                'gslsfellintDcomp',465                'gslsfellintF',466                'gslsfellintE',467                'gslsfellintRC',468                'gslsferfc',469                'gslsflogerfc',470                'gslsferf',471                'gslsferfZ',472                'gslsferfQ',473                'gslsfhazard',474                'gslsfexp',475                'gslsfexpmult',476                'gslsfexpm1',477                'gslsfexprel',478                'gslsfexprel2',479                'gslsfexpreln',480                'gslsfexpintE1',481                'gslsfexpintE2',482                'gslsfexpintEn',483                'gslsfexpintE1scaled',484                'gslsfexpintE2scaled',485                'gslsfexpintEnscaled',486                'gslsfexpintEi',487                'gslsfexpintEiscaled',488                'gslsfShi',489                'gslsfChi',490                'gslsfexpint3',491                'gslsfSi',492                'gslsfCi',493                'gslsfatanint',494                'gslsffermidiracm1',495                'gslsffermidirac0',496                'gslsffermidirac1',497                'gslsffermidirac2',498                'gslsffermidiracint',499                'gslsffermidiracmhalf',500                'gslsffermidirachalf',501                'gslsffermidirac3half',502                'gslsffermidiracinc0',503                'gslsflngamma',504                'gslsfgamma',505                'gslsfgammastar',506                'gslsfgammainv',507                'gslsftaylorcoeff',508                'gslsffact',509                'gslsfdoublefact',510                'gslsflnfact',511                'gslsflndoublefact',512                'gslsflnchoose',513                'gslsfchoose',514                'gslsflnpoch',515                'gslsfpoch',516                'gslsfpochrel',517                'gslsfgammaincQ',518                'gslsfgammaincP',519                'gslsfgammainc',520                'gslsflnbeta',521                'gslsfbeta',522                'gslsfbetainc',523                'gslsfgegenpoly1',524                'gslsfgegenpoly2',525                'gslsfgegenpoly3',526                'gslsfgegenpolyn',527                'gslsfhyperg0F1',528                'gslsfhyperg1F1int',529                'gslsfhyperg1F1',530                'gslsfhypergUint',531                'gslsfhypergU',532                'gslsfhyperg2F0',533                'gslsflaguerre1',534                'gslsflaguerre2',535                'gslsflaguerre3',536                'gslsflaguerren',537                'gslsflambertW0',538                'gslsflambertWm1',539                'gslsflegendrePl',540                'gslsflegendreP1',541                'gslsflegendreP2',542                'gslsflegendreP3',543                'gslsflegendreQ0',544                'gslsflegendreQ1',545                'gslsflegendreQl',546                'gslsflegendrePlm',547                'gslsflegendresphPlm',548                'gslsflegendrearraysize',549                'gslsfconicalPhalf',550                'gslsfconicalPmhalf',551                'gslsfconicalP0',552                'gslsfconicalP1',553                'gslsfconicalPsphreg',554                'gslsfconicalPcylreg',555                'gslsflegendreH3d0',556                'gslsflegendreH3d1',557                'gslsflegendreH3d',558                'gslsflog',559                'gslsflogabs',560                'gslsflog1plusx',561                'gslsflog1plusxmx',562                'gslsfpowint',563                'gslsfpsiint',564                'gslsfpsi',565                'gslsfpsi1piy',566                'gslsfpsi1int',567                'gslsfpsi1',568                'gslsfpsin',569                'gslsfsynchrotron1',570                'gslsfsynchrotron2',571                'gslsftransport2',572                'gslsftransport3',573                'gslsftransport4',574                'gslsftransport5',575                'gslsfsin',576                'gslsfcos',577                'gslsfhypot',578                'gslsfsinc',579                'gslsflnsinh',580                'gslsflncosh',581                'gslsfanglerestrictsymm',582                'gslsfanglerestrictpos',583                'gslsfzetaint',584                'gslsfzeta',585                'gslsfzetam1',586                'gslsfzetam1int',587                'gslsfhzeta',588                'gslsfetaint',589                'gslsfeta',590                'imag',591                'int1d',592                'int2d',593                'int3d',594                'intalledges',595                'intallfaces',596                'interpolate',597                'invdiff',598                'invdiffnp',599                'invdiffpos',600                'Isend',601                'isInf',602                'isNaN',603                'isoline',604                'Irecv',605                'j0',606                'j1',607                'jn',608                'jump',609                'lgamma',610                'LinearCG',611                'LinearGMRES',612                'log',613                'log10',614                'lrint',615                'lround',616                'max',617                'mean',618                'medit',619                'min',620                'mmg3d',621                'movemesh',622                'movemesh23',623                'mpiAlltoall',624                'mpiAlltoallv',625                'mpiAllgather',626                'mpiAllgatherv',627                'mpiAllReduce',628                'mpiBarrier',629                'mpiGather',630                'mpiGatherv',631                'mpiRank',632                'mpiReduce',633                'mpiScatter',634                'mpiScatterv',635                'mpiSize',636                'mpiWait',637                'mpiWaitAny',638                'mpiWtick',639                'mpiWtime',640                'mshmet',641                'NaN',642                'NLCG',643                'on',644                'plot',645                'polar',646                'Post',647                'pow',648                'processor',649                'processorblock',650                'projection',651                'randinit',652                'randint31',653                'randint32',654                'random',655                'randreal1',656                'randreal2',657                'randreal3',658                'randres53',659                'Read',660                'readmesh',661                'readmesh3',662                'Recv',663                'rint',664                'round',665                'savemesh',666                'savesol',667                'savevtk',668                'seekg',669                'Sent',670                'set',671                'sign',672                'signbit',673                'sin',674                'sinh',675                'sort',676                'splitComm',677                'splitmesh',678                'sqrt',679                'square',680                'srandom',681                'srandomdev',682                'Stringification',683                'swap',684                'system',685                'tan',686                'tanh',687                'tellg',688                'tetg',689                'tetgconvexhull',690                'tetgreconstruction',691                'tetgtransfo',692                'tgamma',693                'triangulate',694                'trunc',695                'Wait',696                'Write',697                'y0',698                'y1',699                'yn'700    }701 702    # function parameters703    parameters = {704                'A',705                'A1',706                'abserror',707                'absolute',708                'aniso',709                'aspectratio',710                'B',711                'B1',712                'bb',713                'beginend',714                'bin',715                'boundary',716                'bw',717                'close',718                'cmm',719                'coef',720                'composante',721                'cutoff',722                'datafilename',723                'dataname',724                'dim',725                'distmax',726                'displacement',727                'doptions',728                'dparams',729                'eps',730                'err',731                'errg',732                'facemerge',733                'facetcl',734                'factorize',735                'file',736                'fill',737                'fixedborder',738                'flabel',739                'flags',740                'floatmesh',741                'floatsol',742                'fregion',743                'gradation',744                'grey',745                'hmax',746                'hmin',747                'holelist',748                'hsv',749                'init',750                'inquire',751                'inside',752                'IsMetric',753                'iso',754                'ivalue',755                'keepbackvertices',756                'label',757                'labeldown',758                'labelmid',759                'labelup',760                'levelset',761                'loptions',762                'lparams',763                'maxit',764                'maxsubdiv',765                'meditff',766                'mem',767                'memory',768                'metric',769                'mode',770                'nbarrow',771                'nbiso',772                'nbiter',773                'nbjacoby',774                'nboffacetcl',775                'nbofholes',776                'nbofregions',777                'nbregul',778                'nbsmooth',779                'nbvx',780                'ncv',781                'nev',782                'nomeshgeneration',783                'normalization',784                'omega',785                'op',786                'optimize',787                'option',788                'options',789                'order',790                'orientation',791                'periodic',792                'power',793                'precon',794                'prev',795                'ps',796                'ptmerge',797                'qfe',798                'qforder',799                'qft',800                'qfV',801                'ratio',802                'rawvector',803                'reffacelow',804                'reffacemid',805                'reffaceup',806                'refnum',807                'reftet',808                'reftri',809                'region',810                'regionlist',811                'renumv',812                'rescaling',813                'ridgeangle',814                'save',815                'sigma',816                'sizeofvolume',817                'smoothing',818                'solver',819                'sparams',820                'split',821                'splitin2',822                'splitpbedge',823                'stop',824                'strategy',825                'swap',826                'switch',827                'sym',828                't',829                'tgv',830                'thetamax',831                'tol',832                'tolpivot',833                'tolpivotsym',834                'transfo',835                'U2Vc',836                'value',837                'varrow',838                'vector',839                'veps',840                'viso',841                'wait',842                'width',843                'withsurfacemesh',844                'WindowIndex',845                'which',846                'zbound'847    }848 849    # deprecated850    deprecated = {'fixeborder'}851 852    # do not highlight853    suppress_highlight = {854                'alignof',855                'asm',856                'constexpr',857                'decltype',858                'div',859                'double',860                'grad',861                'mutable',862                'namespace',863                'noexcept',864                'restrict',865                'static_assert',866                'template',867                'this',868                'thread_local',869                'typeid',870                'typename',871                'using'872    }873 874    def get_tokens_unprocessed(self, text, stack=('root',)):875        for index, token, value in CppLexer.get_tokens_unprocessed(self, text, stack):876            if value in self.operators:877                yield index, Operator, value878            elif value in self.types:879                yield index, Keyword.Type, value880            elif value in self.fespaces:881                yield index, Name.Class, value882            elif value in self.preprocessor:883                yield index, Comment.Preproc, value884            elif value in self.keywords:885                yield index, Keyword.Reserved, value886            elif value in self.functions:887                yield index, Name.Function, value888            elif value in self.parameters:889                yield index, Keyword.Pseudo, value890            elif value in self.suppress_highlight:891                yield index, Name, value892            else:893                yield index, token, value894 
codekingpro/portable-devtools · Team Ai