Add files using upload-large-folder tool
Browse filesFiles changed (23)
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/lisp.pyAdded
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/macaulay2.pyAdded+1847
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/make.pyAdded+212
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/maple.pyAdded+291
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/markup.pyAdded+1659
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/math.pyAdded+21
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/matlab.pyAdded
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/maxima.pyAdded+84
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/meson.pyAdded+139
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/mime.pyAdded+210
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/minecraft.pyAdded+392
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/mips.pyAdded+130
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/ml.pyAdded+958
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/modeling.pyAdded+368
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/modula2.pyAdded+1579
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/mojo.pyAdded+707
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/monte.pyAdded+203
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/mosel.pyAdded+447
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/ncl.pyAdded+894
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/nimrod.pyAdded+199
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/nit.pyAdded+63
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/nix.pyAdded+144
- .cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/numbair.pyAdded+63
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847""" pygments.lexers.macaulay2 ~~~~~~~~~~~~~~~~~~~~~~~~~
Lexer for Macaulay2.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, wordsfrom pygments.token import Comment, Keyword, Name, String, Text
__all__ = ['Macaulay2Lexer']
# Auto-generated for Macaulay2-1.25.11. Do not modify this file manually.
M2KEYWORDS = ( "SPACE", "TEST", "and", "break", "breakpoint", "catch", "continue", "do", "elapsedTime", "elapsedTiming", "else", "for", "from", "global", "if", "in", "list", "local", "new", "not", "of", "or", "profile", "return", "shield", "step", "symbol", "then", "threadLocal", "threadVariable", "throw", "time", "timing", "to", "try", "when", "while", "xor" )
M2DATATYPES = ( "ANCHOR", "Adjacent", "AffineVariety", "Analyzer", "AngleBarList", "Array", "AssociativeExpression", "AtomicInt", "BLOCKQUOTE", "BODY", "BOLD", "BR", "BUTTON", "Bag", "BasicList", "BettiTally", "BinaryOperation", "Boolean", "CC", "CDATA", "CODE", "COMMENT", "CacheTable", "ChainComplex", "ChainComplexMap", "CoherentSheaf", "Command", "CompiledFunction", "CompiledFunctionBody", "CompiledFunctionClosure", "ComplexField", "Constant", "DD", "DIV", "DL", "DT", "Database", "Descent", "Describe", "Dictionary", "DirectSum", "Divide", "DocumentTag", "EM", "Eliminate", "EngineRing", "Equation", "ExampleItem", "Expression", "File", "FilePosition", "FractionField", "Function", "FunctionApplication", "FunctionBody", "FunctionClosure", "GaloisField", "GeneralOrderedMonoid", "GlobalDictionary", "GradedModule", "GradedModuleMap", "GroebnerBasis", "GroebnerBasisOptions", "HEAD", "HEADER1", "HEADER2", "HEADER3", "HEADER4", "HEADER5", "HEADER6", "HR", "HREF", "HTML", "HashTable", "HeaderType", "Holder", "Hybrid", "Hypertext", "HypertextContainer", "HypertextParagraph", "HypertextVoid", "IFRAME", "IMG", "INDENT", "INPUT", "ITALIC", "Ideal", "ImmutableType", "IndeterminateNumber", "IndexedVariable", "IndexedVariableTable", "InexactField", "InexactFieldFamily", "InexactNumber", "InfiniteNumber", "IntermediateMarkUpType", "Iterator", "KBD", "Keyword", "LABEL", "LATER", "LI", "LINK", "LITERAL", "List", "LocalDictionary", "LowerBound", "MENU", "META", "Manipulator", "MapExpression", "MarkUpType", "Matrix", "MatrixExpression", "MethodFunction", "MethodFunctionBinary", "MethodFunctionSingle", "MethodFunctionWithOptions", "Minus", "Module", "Monoid", "MonoidElement", "MonomialIdeal", "MultigradedBettiTally", "MutableHashTable", "MutableList", "MutableMatrix", "Net", "NetFile", "Nothing", "Number", "NumberedVerticalList", "OL", "OneExpression", "Option", "OptionTable", "OrderedMonoid", "PARA", "PRE", "Package", "Parenthesize", "Parser", "Partition", "PolynomialRing", "Power", "Product", "ProductOrder", "Program", "ProgramRun", "ProjectiveHilbertPolynomial", "ProjectiveVariety", "Pseudocode", "PseudocodeClosure", "QQ", "QuotientRing", "RR", "RRi", "RealField", "Resolution", "Ring", "RingElement", "RingFamily", "RingMap", "RowExpression", "SAMP", "SCRIPT", "SMALL", "SPAN", "STRONG", "STYLE", "SUB", "SUBSECTION", "SUP", "ScriptedFunctor", "SelfInitializingType", "Sequence", "Set", "SheafExpression", "SheafMap", "SheafOfRings", "SparseMonomialVectorExpression", "SparseVectorExpression", "String", "Subscript", "Sum", "SumOfTwists", "Superscript", "Symbol", "SymbolBody", "TABLE", "TD", "TEX", "TH", "TITLE", "TO", "TO2", "TOH", "TR", "TT", "Table", "Tally", "Task", "TensorProduct", "TestInput", "Thing", "Time", "Type", "UL", "URL", "VAR", "Variety", "Vector", "VectorExpression", "VerticalList", "VirtualTally", "VisibleList", "WrapperType", "ZZ", "ZeroExpression" )
M2FUNCTIONS = ( "BesselJ", "BesselY", "Beta", "Digamma", "EXAMPLE", "End", "Fano", "GCstats", "GF", "Gamma", "Grassmannian", "Hom", "LLL", "LUdecomposition", "M2CODE", "NNParser", "Proj", "QQParser", "QRDecomposition", "SVD", "SYNOPSIS", "Schubert", "Spec", "ZZParser", "about", "abs", "accumulate", "acos", "acosh", "acot", "acoth", "addCancelTask", "addDependencyTask", "addEndFunction", "addHook", "addStartTask", "adjoint", "agm", "alarm", "all", "ambient", "analyticSpread", "ancestor", "ancestors", "andP", "ann", "annihilator", "antipode", "any", "append", "applicationDirectory", "apply", "applyKeys", "applyPairs", "applyTable", "applyValues", "apropos", "arXiv", "ascii", "asin", "asinh", "ass", "assert", "associatedGradedRing", "associatedPrimes", "atEndOfFile", "atan", "atan2", "atanh", "autoload", "baseFilename", "baseName", "baseRing", "basis", "beginDocumentation", "benchmark", "betti", "between", "binomial", "borel", "cacheValue", "cancelTask", "canonicalBundle", "capture", "ceiling", "centerString", "chainComplex", "changeBase", "changeDirectory", "char", "charAnalyzer", "characters", "check", "checkDegrees", "chi", "class", "clean", "clearEcho", "code", "codim", "coefficient", "coefficientRing", "coefficients", "cohomology", "coimage", "coker", "cokernel", "collectGarbage", "columnAdd", "columnMult", "columnPermute", "columnRankProfile", "columnSwap", "columnate", "combine", "commandInterpreter", "commonRing", "commonest", "comodule", "compareExchange", "complement", "complete", "components", "compose", "compositions", "compress", "concatenate", "conductor", "cone", "conjugate", "connectionCount", "constParser", "content", "contract", "conwayPolynomial", "copy", "copyDirectory", "copyFile", "cos", "cosh", "cot", "cotangentSheaf", "coth", "cover", "coverMap", "cpuTime", "createTask", "csc", "csch", "currentColumnNumber", "currentDirectory", "currentPosition", "currentRowNumber", "currentTime", "deadParser", "debug", "debugError", "decompose", "deepSplice", "default", "degree", "degreeGroup", "degreeLength", "degrees", "degreesMonoid", "degreesRing", "delete", "demark", "denominator", "depth", "describe", "det", "determinant", "diagonalMatrix", "diameter", "dictionary", "diff", "difference", "dim", "directProduct", "directSum", "disassemble", "discriminant", "dismiss", "distinguished", "divideByVariable", "doc", "document", "drop", "dual", "eagonNorthcott", "echoOff", "echoOn", "eigenvalues", "eigenvectors", "eint", "elements", "eliminate", "endPackage", "entries", "erase", "erf", "erfc", "error", "euler", "eulers", "even", "examples", "exchange", "exec", "exp", "expectedReesIdeal", "expm1", "exponents", "export", "exportFrom", "exportMutable", "expression", "extend", "exteriorPower", "factor", "fileExecutable", "fileExists", "fileLength", "fileMode", "fileReadable", "fileTime", "fileWritable", "fillMatrix", "findFiles", "findHeft", "findProgram", "findSynonyms", "first", "firstkey", "fittingIdeal", "flagLookup", "flatten", "flattenRing", "flip", "floor", "fold", "forceGB", "fork", "format", "formation", "frac", "fraction", "frames", "fromDividedPowers", "fromDual", "functionBody", "futureParser", "gb", "gbRemove", "gbSnapshot", "gcd", "gcdCoefficients", "gcdLLL", "genera", "generateAssertions", "generator", "generators", "genericMatrix", "genericSkewMatrix", "genericSymmetricMatrix", "gens", "genus", "get", "getChangeMatrix", "getGlobalSymbol", "getIOThreadMode", "getNetFile", "getNonUnit", "getPrimeWithRootOfUnity", "getSymbol", "getWWW", "getc", "getenv", "globalAssign", "globalAssignFunction", "globalAssignment", "globalReleaseFunction", "gradedModule", "gradedModuleMap", "gramm", "graphIdeal", "graphRing", "groebnerBasis", "groupID", "hash", "hashTable", "headlines", "heft", "height", "hermite", "hilbertFunction", "hilbertPolynomial", "hilbertSeries", "hold", "homogenize", "homology", "homomorphism", "hooks", "horizontalJoin", "html", "httpHeaders", "hypertext", "icFracP", "icFractions", "icMap", "icPIdeal", "ideal", "idealSheaf", "idealizer", "identity", "image", "imaginaryPart", "importFrom", "independentSets", "index", "indices", "inducedMap", "inducesWellDefinedMap", "info", "input", "insert", "installAssignmentMethod", "installHilbertFunction", "installMethod", "installMinprimes", "installPackage", "installedPackages", "instance", "instances", "integralClosure", "integrate", "intersect", "intersectInP", "intersection", "interval", "inverse", "inverseErf", "inversePermutation", "inverseRegularizedBeta", "inverseRegularizedGamma", "inverseSystem", "irreducibleCharacteristicSeries", "irreducibleDecomposition", "isANumber", "isAffineRing", "isBorel", "isCanceled", "isCommutative", "isConstant", "isDirectSum", "isDirectory", "isEmpty", "isExact", "isField", "isFinite", "isFinitePrimeField", "isFreeModule", "isGlobalSymbol", "isHomogeneous", "isIdeal", "isInfinite", "isInjective", "isInputFile", "isIsomorphic", "isIsomorphism", "isLLL", "isLinearType", "isListener", "isLocallyFree", "isMember", "isModule", "isMonomialIdeal", "isMutable", "isNormal", "isOpen", "isOutputFile", "isPolynomialRing", "isPrimary", "isPrime", "isPrimitive", "isProjective", "isPseudoprime", "isQuotientModule", "isQuotientOf", "isQuotientRing", "isReady", "isReal", "isReduction", "isRegularFile", "isRing", "isSkewCommutative", "isSmooth", "isSorted", "isSquareFree", "isStandardGradedPolynomialRing", "isSubmodule", "isSubquotient", "isSubset", "isSupportedInZeroLocus", "isSurjective", "isTable", "isUnit", "isVeryAmple", "isWellDefined", "isWeylAlgebra", "isc", "isomorphism", "iterator", "jacobian", "jacobianDual", "join", "ker", "kernel", "kernelLLL", "kernelOfLocalization", "keys", "kill", "koszul", "last", "lcm", "leadCoefficient", "leadComponent", "leadMonomial", "leadTerm", "left", "length", "letterParser", "lift", "liftable", "limitFiles", "limitProcesses", "lines", "linkFile", "listForm", "listSymbols", "lngamma", "load", "loadPackage", "localDictionaries", "localize", "locate", "log", "log1p", "lookup", "lookupCount", "makeDirectory", "makeDocumentTag", "makePackageIndex", "makeS2", "map", "markedGB", "match", "mathML", "matrix", "max", "maxPosition", "member", "memoize", "memoizeClear", "memoizeValues", "merge", "mergePairs", "method", "methodOptions", "methods", "midpoint", "min", "minPosition", "minPres", "mingens", "mingle", "minimalBetti", "minimalPresentation", "minimalPrimes", "minimalReduction", "minimize", "minimizeFilename", "minors", "minprimes", "minus", "mkdir", "mod", "module", "modulo", "monoid", "monomialCurveIdeal", "monomialIdeal", "monomialSubideal", "monomials", "moveFile", "multidegree", "multidoc", "multigraded", "multiplicity", "mutable", "mutableIdentity", "mutableMatrix", "nanosleep", "needs", "needsPackage", "net", "netList", "newClass", "newCoordinateSystem", "newNetFile", "newPackage", "newRing", "next", "nextPrime", "nextkey", "nonspaceAnalyzer", "norm", "normalCone", "notImplemented", "nullParser", "nullSpace", "nullhomotopy", "numColumns", "numRows", "number", "numcols", "numerator", "numeric", "numericInterval", "numgens", "numrows", "odd", "oeis", "ofClass", "on", "openDatabase", "openDatabaseOut", "openFiles", "openIn", "openInOut", "openListener", "openOut", "openOutAppend", "optP", "optionalSignParser", "options", "orP", "override", "pack", "package", "packageTemplate", "pad", "pager", "pairs", "parallelApply", "parent", "part", "partition", "partitions", "parts", "pdim", "peek", "permanents", "permutations", "pfaffian", "pfaffians", "pivots", "plus", "poincare", "poincareN", "polarize", "poly", "position", "positions", "power", "powermod", "precision", "preimage", "prepend", "presentation", "pretty", "primaryComponent", "primaryDecomposition", "print", "printString", "printerr", "processID", "product", "projectiveHilbertPolynomial", "promote", "protect", "prune", "pseudoRemainder", "pseudocode", "pullback", "pushForward", "pushout", "quotient", "quotientRemainder", "radical", "radicalContainment", "random", "randomKRationalPoint", "randomMutableMatrix", "randomSubset", "rank", "rays", "read", "readDirectory", "readPackage", "readlink", "realPart", "realpath", "recursionDepth", "reduceHilbert", "reducedRowEchelonForm", "reductionNumber", "reesAlgebra", "reesAlgebraIdeal", "reesIdeal", "regSeqInIdeal", "regex", "regexQuote", "registerFinalizer", "regularity", "regularizedBeta", "regularizedGamma", "relations", "relativizeFilename", "remainder", "remove", "removeDirectory", "removeFile", "removeLowestDimension", "reorganize", "replace", "res", "reshape", "resolution", "resultant", "reverse", "right", "ring", "ringFromFractions", "roots", "rotate", "round", "rowAdd", "rowMult", "rowPermute", "rowRankProfile", "rowSwap", "rsort", "run", "runHooks", "runLengthEncode", "runProgram", "same", "saturate", "scan", "scanKeys", "scanLines", "scanPairs", "scanValues", "schedule", "schreyerOrder", "searchPath", "sec", "sech", "seeParsing", "select", "selectInSubring", "selectKeys", "selectPairs", "selectValues", "selectVariables", "separate", "separateRegexp", "sequence", "serialNumber", "set", "setEcho", "setGroupID", "setIOExclusive", "setIOSynchronized", "setIOUnSynchronized", "setRandomSeed", "setup", "setupEmacs", "setupLift", "setupPromote", "sheaf", "sheafHom", "sheafMap", "show", "showHtml", "showTex", "sign", "simpleDocFrob", "sin", "singularLocus", "sinh", "size", "size2", "sleep", "smithNormalForm", "solve", "someTerms", "sort", "sortColumns", "source", "span", "specialFiber", "specialFiberIdeal", "splice", "splitWWW", "sqrt", "stack", "stacksProject", "stacktrace", "standardForm", "standardPairs", "stashValue", "status", "store", "style", "sub", "sublists", "submatrix", "submatrixByDegrees", "subquotient", "subsets", "substitute", "substring", "subtable", "sum", "super", "support", "switch", "sylvesterMatrix", "symbolBody", "symlinkDirectory", "symlinkFile", "symmetricAlgebra", "symmetricAlgebraIdeal", "symmetricKernel", "symmetricPower", "synonym", "syz", "syzygyScheme", "table", "take", "tally", "tan", "tangentCone", "tangentSheaf", "tanh", "target", "taskResult", "temporaryFileName", "tensor", "tensorAssociativity", "terminalParser", "terms", "testHunekeQuestion", "tests", "tex", "texMath", "times", "toAbsolutePath", "toCC", "toDividedPowers", "toDual", "toExternalString", "toField", "toList", "toLower", "toRR", "toRRi", "toSequence", "toString", "toUpper", "top", "topCoefficients", "topComponents", "trace", "transpose", "trim", "truncate", "truncateOutput", "tutorial", "ultimate", "unbag", "uncurry", "undocumented", "uniform", "uninstallAllPackages", "uninstallPackage", "union", "unique", "uniquePermutations", "unsequence", "unstack", "urlEncode", "use", "userSymbols", "utf8", "utf8check", "utf8substring", "validate", "value", "values", "variety", "vars", "vector", "versalEmbedding", "wait", "wedgeProduct", "weightRange", "whichGm", "width", "wikipedia", "wrap", "youngest", "zero", "zeta" )
M2CONSTANTS = ( "A1BrouwerDegrees", "AbstractSimplicialComplexes", "AbstractToricVarieties", "Acknowledgement", "AdditionalPaths", "AdjointIdeal", "AdjunctionForSurfaces", "AfterEval", "AfterNoPrint", "AfterPrint", "AInfinity", "AlgebraicSplines", "Algorithm", "Alignment", "AllCodimensions", "AllMarkovBases", "allowableThreads", "AnalyzeSheafOnP1", "applicationDirectorySuffix", "argument", "Ascending", "AssociativeAlgebras", "Authors", "AuxiliaryFiles", "backtrace", "Bareiss", "Base", "BaseFunction", "baseRings", "BaseRow", "BasisElementLimit", "Bayer", "BeforePrint", "BeginningMacaulay2", "Benchmark", "BernsteinSato", "Bertini", "BettiCharacters", "BGG", "BIBasis", "Binary", "Binomial", "BinomialEdgeIdeals", "Binomials", "BKZ", "blockMatrixForm", "Body", "BoijSoederberg", "Book3264Examples", "BooleanGB", "Boxes", "Brackets", "Browse", "Bruns", "cache", "CacheExampleOutput", "CallLimit", "CannedExample", "CatalanConstant", "Caveat", "CellularResolutions", "Center", "Certification", "ChainComplexExtras", "ChainComplexOperations", "ChangeMatrix", "CharacteristicClasses", "CheckDocumentation", "Chordal", "Citation", "cite", "Classic", "clearAll", "clearOutput", "close", "closeIn", "closeOut", "ClosestFit", "Code", "CodimensionLimit", "CodingTheory", "CoefficientRing", "Cofactor", "CohenEngine", "CohenTopLevel", "CohomCalg", "CoincidentRootLoci", "commandLine", "compactMatrixForm", "Complement", "CompleteIntersection", "CompleteIntersectionResolutions", "Complexes", "ConductorElement", "Configuration", "ConformalBlocks", "ConnectionMatrices", "Consequences", "Constants", "Contributors", "ConvexInterface", "ConwayPolynomials", "copyright", "Core", "CorrespondenceScrolls", "CotangentSchubert", "cotangentSurjection", "coverageSummary", "CpMackeyFunctors", "Cremona", "currentFileDirectory", "currentFileName", "currentLayout", "currentPackage", "Cyclotomic", "Date", "dd", "DebuggingMode", "debuggingMode", "debugLevel", "DecomposableSparseSystems", "Decompose", "Default", "defaultPrecision", "Degree", "DegreeGroup", "DegreeLift", "DegreeLimit", "DegreeMap", "DegreeOrder", "DegreeRank", "Degrees", "Dense", "Density", "Depth", "Descending", "Description", "DeterminantalRepresentations", "DGAlgebras", "dictionaryPath", "DiffAlg", "Dispatch", "DivideConquer", "DividedPowers", "Dmodules", "docExample", "docTemplate", "Down", "Dynamic", "EagonResolution", "EdgeIdeals", "edit", "EigenSolver", "EisenbudHunekeVasconcelos", "Elimination", "EliminationMatrices", "EllipticCurves", "EllipticIntegrals", "Email", "embeddedToAbstract", "end", "endl", "Engine", "engineDebugLevel", "EngineTests", "EnumerationCurves", "environment", "EquivariantGB", "errorDepth", "EulerConstant", "eulerSequence", "Example", "ExampleFiles", "ExampleSystems", "Exclude", "exit", "Ext", "ExteriorExtensions", "ExteriorIdeals", "ExteriorModules", "ExtLongExactSequence", "false", "FastMinors", "FastNonminimal", "FGLM", "fileDictionaries", "fileExitHooks", "FileName", "FindOne", "FiniteFittingIdeals", "First", "FirstPackage", "FlatMonoid", "Flexible", "flush", "FollowLinks", "ForeignFunctions", "FormalGroupLaws", "Format", "FourierMotzkin", "FourTiTwo", "fpLLL", "FrobeniusThresholds", "FunctionFieldDesingularization", "GameTheory", "GBDegrees", "gbTrace", "GenerateAssertions", "Generic", "GenericInitialIdeal", "GeometricDecomposability", "gfanInterface", "Givens", "GKMVarieties", "GLex", "Global", "GlobalAssignHook", "globalAssignmentHooks", "GlobalHookStore", "GlobalReleaseHook", "GlobalSectionLimit", "Gorenstein", "GradedLieAlgebras", "GraphicalModels", "GraphicalModelsMLE", "Graphics", "Graphs", "GRevLex", "GroebnerStrata", "GroebnerWalk", "GroupLex", "GroupRevLex", "GTZ", "Hadamard", "handleInterrupts", "HardDegreeLimit", "Heading", "Headline", "Heft", "Height", "help", "Hermite", "Hermitian", "HH", "hh", "HigherCIOperators", "HighestWeights", "Hilbert", "HodgeIntegrals", "HolonomicSystems", "homeDirectory", "HomePage", "Homogeneous", "Homogeneous2", "HomologicalAlgebraPackage", "HomotopyLieAlgebra", "HorizontalSpace", "HyperplaneArrangements", "id", "idealSheafSequence", "IgnoreExampleErrors", "ii", "IncidenceCorrespondenceCohomology", "incomparable", "Increment", "indeterminate", "Index", "indexComponents", "infinity", "InfoDirSection", "infoHelp", "Inhomogeneous", "Inputs", "InstallPrefix", "IntegerProgramming", "IntegralClosure", "interpreterDepth", "Intersection", "InvariantRing", "InverseMethod", "Inverses", "InverseSystems", "Invertible", "InvolutiveBases", "Isomorphism", "Item", "Iterate", "Jacobian", "Jets", "Join", "JSON", "JSONRPC", "K3Carpets", "K3Surfaces", "Keep", "KeepFiles", "KeepZeroes", "Key", "Keywords", "Kronecker", "KustinMiller", "lastMatch", "LatticePolytopes", "Layout", "Left", "LengthLimit", "Lex", "LexIdeals", "LieAlgebraRepresentations", "Limit", "Linear", "LinearAlgebra", "LinearTruncations", "lineNumber", "listLocalSymbols", "listUserSymbols", "LLLBases", "loadDepth", "LoadDocumentation", "loadedFiles", "loadedPackages", "Local", "LocalRings", "LongPolynomial", "M0nbar", "Macaulay2Doc", "Maintainer", "MakeDocumentation", "MakeHTML", "MakeInfo", "MakePDF", "MapleInterface", "Markov", "MatchingFields", "MatrixFactorizations", "MatrixSchubert", "Matroids", "maxAllowableThreads", "maxExponent", "MaximalRank", "MaxReductionCount", "MCMApproximations", "MergeTeX", "minExponent", "MinimalGenerators", "MinimalMatrix", "minimalPresentationMap", "minimalPresentationMapInv", "MinimalPrimes", "Minimize", "MinimumVersion", "Miura", "MixedMultiplicity", "ModuleDeformations", "MonodromySolver", "Monomial", "MonomialAlgebras", "MonomialIntegerPrograms", "MonomialOrbits", "MonomialOrder", "Monomials", "MonomialSize", "Msolve", "MultigradedBGG", "MultigradedImplicitization", "MultiGradedRationalMap", "MultiplicitySequence", "MultiplierIdeals", "MultiplierIdealsDim2", "MultiprojectiveVarieties", "NAGtypes", "Name", "Nauty", "NautyGraphs", "NCAlgebra", "NCLex", "NewFromMethod", "newline", "NewMethod", "NewOfFromMethod", "NewOfMethod", "nil", "Node", "NoetherianOperators", "NoetherNormalization", "NonminimalComplexes", "NonPrincipalTestIdeals", "NoPrint", "Normaliz", "NormalToricVarieties", "NotANumber", "notify", "NTL", "null", "nullaryMethods", "NumericalAlgebraicGeometry", "NumericalCertification", "NumericalImplicitization", "NumericalLinearAlgebra", "NumericalSchubertCalculus", "NumericalSemigroups", "NumericSolutions", "numTBBThreads", "OIGroebnerBases", "OldChainComplexes", "OldPolyhedra", "OldToricVectorBundles", "OnlineLookup", "OO", "oo", "ooo", "oooo", "OpenMath", "operatorAttributes", "OptionalComponentsPresent", "Options", "Order", "order", "Oscillators", "OutputDictionary", "Outputs", "PackageCitations", "PackageDictionary", "PackageExports", "PackageImports", "PackageTemplate", "PairLimit", "PairsRemaining", "ParallelF4", "ParallelizeByDegree", "Parametrization", "Parsing", "path", "PathSignatures", "PencilsOfQuadrics", "Permanents", "Permutations", "PHCpack", "PhylogeneticTrees", "pi", "PieriMaps", "PlaneCurveLinearSeries", "PlaneCurveSingularities", "Points", "Polyhedra", "Polymake", "PolyominoIdeals", "Posets", "Position", "PositivityToricBundles", "POSIX", "Postfix", "Pre", "Precision", "Prefix", "prefixDirectory", "prefixPath", "PrimaryDecomposition", "PrimaryTag", "PrimitiveElement", "Print", "printingAccuracy", "printingLeadLimit", "printingPrecision", "printingSeparator", "printingTimeLimit", "printingTrailLimit", "printWidth", "Probability", "profileSummary", "programPaths", "Projective", "Prune", "PruneComplex", "pruningMap", "PseudomonomialPrimaryDecomposition", "Pullback", "pullbackMaps", "PushForward", "pushoutMaps", "Python", "QthPower", "QuadraticIdealExamplesByRoos", "Quasidegrees", "QuaternaryQuartics", "QuillenSuslin", "quit", "Quotient", "Radical", "RadicalCodim1", "RaiseError", "RandomCanonicalCurves", "RandomComplexes", "RandomCurves", "RandomCurvesOverVerySmallFiniteFields", "RandomGenus14Curves", "RandomIdeals", "RandomMonomialIdeals", "RandomObjects", "RandomPlaneCurves", "RandomPoints", "RandomSpaceCurves", "Range", "RationalMaps", "RationalPoints", "RationalPoints2", "ReactionNetworks", "RealFP", "RealQP", "RealQP1", "RealRoots", "RealRR", "RealXD", "recursionLimit", "Reduce", "ReesAlgebra", "References", "ReflexivePolytopesDB", "Regularity", "RelativeCanonicalResolution", "Reload", "RemakeAllDocumentation", "RerunExamples", "ResidualIntersections", "ResLengthThree", "ResolutionsOfStanleyReisnerRings", "restart", "Result", "Resultants", "returnCode", "Reverse", "RevLex", "RHom", "Right", "RInterface", "rootPath", "rootURI", "RunDirectory", "RunExamples", "RunExternalM2", "SagbiGbDetection", "Saturation", "SaturationMap", "Schubert2", "SchurComplexes", "SchurFunctors", "SchurRings", "SchurVeronese", "SCMAlgebras", "scriptCommandLine", "SCSCP", "SectionRing", "SeeAlso", "SegreClasses", "SemidefiniteProgramming", "Seminormalization", "SeparateExec", "Serialization", "sheafExt", "ShimoyamaYokoyama", "showClassStructure", "showStructure", "showUserStructure", "SimpleDoc", "SimplicialComplexes", "SimplicialDecomposability", "SimplicialPosets", "SimplifyFractions", "SizeLimit", "SkewCommutative", "SlackIdeals", "SLnEquivariantMatrices", "SLPexpressions", "Sort", "SortStrategy", "SourceCode", "SourceRing", "SpaceCurves", "SparseResultants", "SpechtModule", "SpecialFanoFourfolds", "SpectralSequences", "SRdeformations", "Standard", "StartWithOneMinor", "StatePolytope", "StatGraphs", "stderr", "stdio", "StopBeforeComputation", "stopIfError", "StopIteration", "StopWithMinimalGenerators", "Strategy", "Strict", "StronglyStableIdeals", "Style", "SubalgebraBases", "Subnodes", "SubringLimit", "subscript", "Sugarless", "SumsOfSquares", "SuperLinearAlgebra", "superscript", "SVDComplexes", "SwitchingFields", "SymbolicPowers", "SymmetricPolynomials", "Synopsis", "Syzygies", "SyzygyLimit", "SyzygyMatrix", "SyzygyRows", "Tableaux", "TangentCone", "TateOnProducts", "TensorComplexes", "TerraciniLoci", "Test", "testExample", "TestIdeals", "TeXmacs", "Text", "ThinSincereQuivers", "ThreadedGB", "Threads", "Threshold", "Topcom", "topLevelMode", "Tor", "TorAlgebra", "Toric", "ToricHigherDirectImages", "ToricInvariants", "ToricTopology", "ToricVectorBundles", "Torsion", "TorsionFree", "TotalPairs", "Tree", "TriangularSets", "Triangulations", "Tries", "Trim", "Triplets", "Tropical", "TropicalToric", "true", "Truncate", "Truncations", "TSpreadIdeals", "TypicalValue", "typicalValues", "Undo", "Unique", "Units", "Unmixed", "Up", "UpdateOnly", "UpperTriangular", "Usage", "UseCachedExampleOutput", "UseHilbertFunction", "UserMode", "UseSyzygies", "Valuations", "Variable", "VariableBaseName", "Variables", "Varieties", "Vasconcelos", "VectorFields", "VectorGraphics", "Verbose", "Verbosity", "Verify", "VersalDeformations", "Version", "version", "VerticalSpace", "viewHelp", "VirtualResolutions", "Visualize", "VNumber", "WebApp", "Weights", "WeilDivisors", "WeylAlgebra", "WeylAlgebras", "WeylGroups", "WhitneyStratifications", "Wrap", "XML", "yonedaSheafExtension" )
class Macaulay2Lexer(RegexLexer): """Lexer for Macaulay2, a software system for research in algebraic geometry."""
name = 'Macaulay2' url = 'https://macaulay2.com/' aliases = ['macaulay2'] filenames = ['*.m2'] version_added = '2.12'
tokens = { 'root': [ (r'--.*$', Comment.Single), (r'-\*', Comment.Multiline, 'block comment'), (r'"', String, 'quote string'), (r'///', String, 'slash string'), (words(M2KEYWORDS, prefix=r'\b', suffix=r'\b'), Keyword), (words(M2DATATYPES, prefix=r'\b', suffix=r'\b'), Name.Builtin), (words(M2FUNCTIONS, prefix=r'\b', suffix=r'\b'), Name.Function), (words(M2CONSTANTS, prefix=r'\b', suffix=r'\b'), Name.Constant), (r'\s+', Text.Whitespace), (r'.', Text) ], 'block comment' : [ (r'[^*-]+', Comment.Multiline), (r'\*-', Comment.Multiline, '#pop'), (r'[*-]', Comment.Multiline) ], 'quote string' : [ (r'[^\\"]+', String), (r'"', String, '#pop'), (r'\\"?', String), ], 'slash string' : [ (r'[^/]+', String), (r'(//)+(?!/)', String), (r'/(//)+(?!/)', String, '#pop'), (r'/', String) ] }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212""" pygments.lexers.make ~~~~~~~~~~~~~~~~~~~~
Lexers for Makefiles and similar.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import Lexer, RegexLexer, include, bygroups, \ do_insertions, usingfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Punctuation, Whitespacefrom pygments.lexers.shell import BashLexer
__all__ = ['MakefileLexer', 'BaseMakefileLexer', 'CMakeLexer']
class MakefileLexer(Lexer): """ Lexer for BSD and GNU make extensions (lenient enough to handle both in the same file even).
*Rewritten in Pygments 0.10.* """
name = 'Makefile' aliases = ['make', 'makefile', 'mf', 'bsdmake'] filenames = ['*.mak', '*.mk', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile'] mimetypes = ['text/x-makefile'] url = 'https://en.wikipedia.org/wiki/Make_(software)' version_added = ''
r_special = re.compile( r'^(?:' # BSD Make r'\.\s*(include|undef|error|warning|if|else|elif|endif|for|endfor)|' # GNU Make r'\s*(ifeq|ifneq|ifdef|ifndef|else|endif|-?include|define|endef|:|vpath)|' # GNU Automake r'\s*(if|else|endif))(?=\s)') r_comment = re.compile(r'^\s*@?#')
def get_tokens_unprocessed(self, text): ins = [] lines = text.splitlines(keepends=True) done = '' lex = BaseMakefileLexer(**self.options) backslashflag = False for line in lines: if self.r_special.match(line) or backslashflag: ins.append((len(done), [(0, Comment.Preproc, line)])) backslashflag = line.strip().endswith('\\') elif self.r_comment.match(line): ins.append((len(done), [(0, Comment, line)])) else: done += line yield from do_insertions(ins, lex.get_tokens_unprocessed(done))
def analyse_text(text): # Many makefiles have $(BIG_CAPS) style variables if re.search(r'\$\([A-Z_]+\)', text): return 0.1
class BaseMakefileLexer(RegexLexer): """ Lexer for simple Makefiles (no preprocessing). """
name = 'Base Makefile' aliases = ['basemake'] filenames = [] mimetypes = [] url = 'https://en.wikipedia.org/wiki/Make_(software)' version_added = '0.10'
tokens = { 'root': [ # recipes (need to allow spaces because of expandtabs) (r'^(?:[\t ]+.*\n|\n)+', using(BashLexer)), # special variables (r'\$[<@$+%?|*]', Keyword), (r'\s+', Whitespace), (r'#.*?\n', Comment), (r'((?:un)?export)(\s+)(?=[\w${}\t -]+\n)', bygroups(Keyword, Whitespace), 'export'), (r'(?:un)?export\s+', Keyword), # assignment (r'([\w${}().-]+)(\s*)([!?:+]?=)([ \t]*)((?:.*\\\n)+|.*\n)', bygroups( Name.Variable, Whitespace, Operator, Whitespace, using(BashLexer))), # strings (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double), (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single), # targets (r'([^\n:]+)(:+)([ \t]*)', bygroups( Name.Function, Operator, Whitespace), 'block-header'), # expansions (r'\$\(', Keyword, 'expansion'), ], 'expansion': [ (r'[^\w$().-]+', Text), (r'[\w.-]+', Name.Variable), (r'\$', Keyword), (r'\(', Keyword, '#push'), (r'\)', Keyword, '#pop'), ], 'export': [ (r'[\w${}-]+', Name.Variable), (r'\n', Text, '#pop'), (r'\s+', Whitespace), ], 'block-header': [ (r'[,|]', Punctuation), (r'#.*?\n', Comment, '#pop'), (r'\\\n', Text), # line continuation (r'\$\(', Keyword, 'expansion'), (r'[a-zA-Z_]+', Name), (r'\n', Whitespace, '#pop'), (r'.', Text), ], }
class CMakeLexer(RegexLexer): """ Lexer for CMake files. """ name = 'CMake' url = 'https://cmake.org/documentation/' aliases = ['cmake'] filenames = ['*.cmake', 'CMakeLists.txt'] mimetypes = ['text/x-cmake'] version_added = '1.2'
tokens = { 'root': [ # (r'(ADD_CUSTOM_COMMAND|ADD_CUSTOM_TARGET|ADD_DEFINITIONS|' # r'ADD_DEPENDENCIES|ADD_EXECUTABLE|ADD_LIBRARY|ADD_SUBDIRECTORY|' # r'ADD_TEST|AUX_SOURCE_DIRECTORY|BUILD_COMMAND|BUILD_NAME|' # r'CMAKE_MINIMUM_REQUIRED|CONFIGURE_FILE|CREATE_TEST_SOURCELIST|' # r'ELSE|ELSEIF|ENABLE_LANGUAGE|ENABLE_TESTING|ENDFOREACH|' # r'ENDFUNCTION|ENDIF|ENDMACRO|ENDWHILE|EXEC_PROGRAM|' # r'EXECUTE_PROCESS|EXPORT_LIBRARY_DEPENDENCIES|FILE|FIND_FILE|' # r'FIND_LIBRARY|FIND_PACKAGE|FIND_PATH|FIND_PROGRAM|FLTK_WRAP_UI|' # r'FOREACH|FUNCTION|GET_CMAKE_PROPERTY|GET_DIRECTORY_PROPERTY|' # r'GET_FILENAME_COMPONENT|GET_SOURCE_FILE_PROPERTY|' # r'GET_TARGET_PROPERTY|GET_TEST_PROPERTY|IF|INCLUDE|' # r'INCLUDE_DIRECTORIES|INCLUDE_EXTERNAL_MSPROJECT|' # r'INCLUDE_REGULAR_EXPRESSION|INSTALL|INSTALL_FILES|' # r'INSTALL_PROGRAMS|INSTALL_TARGETS|LINK_DIRECTORIES|' # r'LINK_LIBRARIES|LIST|LOAD_CACHE|LOAD_COMMAND|MACRO|' # r'MAKE_DIRECTORY|MARK_AS_ADVANCED|MATH|MESSAGE|OPTION|' # r'OUTPUT_REQUIRED_FILES|PROJECT|QT_WRAP_CPP|QT_WRAP_UI|REMOVE|' # r'REMOVE_DEFINITIONS|SEPARATE_ARGUMENTS|SET|' # r'SET_DIRECTORY_PROPERTIES|SET_SOURCE_FILES_PROPERTIES|' # r'SET_TARGET_PROPERTIES|SET_TESTS_PROPERTIES|SITE_NAME|' # r'SOURCE_GROUP|STRING|SUBDIR_DEPENDS|SUBDIRS|' # r'TARGET_LINK_LIBRARIES|TRY_COMPILE|TRY_RUN|UNSET|' # r'USE_MANGLED_MESA|UTILITY_SOURCE|VARIABLE_REQUIRES|' # r'VTK_MAKE_INSTANTIATOR|VTK_WRAP_JAVA|VTK_WRAP_PYTHON|' # r'VTK_WRAP_TCL|WHILE|WRITE_FILE|' # r'COUNTARGS)\b', Name.Builtin, 'args'), (r'\b(\w+)([ \t]*)(\()', bygroups(Name.Builtin, Whitespace, Punctuation), 'args'), include('keywords'), include('ws') ], 'args': [ (r'\(', Punctuation, '#push'), (r'\)', Punctuation, '#pop'), (r'(\$\{)(.+?)(\})', bygroups(Operator, Name.Variable, Operator)), (r'(\$ENV\{)(.+?)(\})', bygroups(Operator, Name.Variable, Operator)), (r'(\$<)(.+?)(>)', bygroups(Operator, Name.Variable, Operator)), (r'(?s)".*?"', String.Double), (r'\\\S+', String), (r'\[(?P<level>=*)\[[\w\W]*?\](?P=level)\]', String.Multiline), (r'[^)$"# \t\n]+', String), (r'\n', Whitespace), # explicitly legal include('keywords'), include('ws') ], 'string': [
], 'keywords': [ (r'\b(WIN32|UNIX|APPLE|CYGWIN|BORLAND|MINGW|MSVC|MSVC_IDE|MSVC60|' r'MSVC70|MSVC71|MSVC80|MSVC90)\b', Keyword), ], 'ws': [ (r'[ \t]+', Whitespace), (r'#\[(?P<level>=*)\[[\w\W]*?\](?P=level)\]', Comment), (r'#.*\n', Comment), ] }
def analyse_text(text): exp = ( r'^[ \t]*CMAKE_MINIMUM_REQUIRED[ \t]*' r'\([ \t]*VERSION[ \t]*\d+(\.\d+)*[ \t]*' r'([ \t]FATAL_ERROR)?[ \t]*\)[ \t]*' r'(#[^\n]*)?$' ) if re.search(exp, text, flags=re.MULTILINE | re.IGNORECASE): return 0.8 return 0.0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291""" pygments.lexers.maple ~~~~~~~~~~~~~~~~~~~~~
Lexers for Maple.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import words, bygroups, ExtendedRegexLexerfrom pygments.token import Comment, Name, String, Whitespace, Operator, Punctuation, Number, Keyword
__all__ = ['MapleLexer']
class MapleLexer(ExtendedRegexLexer): """ Lexer for Maple. """
name = 'Maple' aliases = ['maple'] filenames = ['*.mpl', '*.mi', '*.mm'] mimetypes = ['text/x-maple'] url = 'https://www.maplesoft.com/products/Maple/' version_added = '2.19'
keywords = ('and', 'assuming', 'break', 'by', 'catch', 'description', 'do', 'done', 'elif', 'else', 'end', 'error', 'export', 'fi', 'finally', 'for', 'from', 'global', 'if', 'implies', 'in', 'intersect', 'local', 'minus', 'mod', 'module', 'next', 'not', 'od', 'option', 'options', 'or', 'proc', 'quit', 'read', 'return', 'save', 'stop', 'subset', 'then', 'to', 'try', 'union', 'use', 'uses', 'while', 'xor')
builtins = ('abs', 'add', 'addressof', 'anames', 'and', 'andmap', 'andseq', 'appendto', 'Array', 'array', 'ArrayOptions', 'assemble', 'ASSERT', 'assign', 'assigned', 'attributes', 'cat', 'ceil', 'coeff', 'coeffs', 'conjugate', 'convert', 'CopySign', 'DEBUG', 'debugopts', 'Default0', 'DefaultOverflow', 'DefaultUnderflow', 'degree', 'denom', 'diff', 'disassemble', 'divide', 'done', 'entries', 'EqualEntries', 'eval', 'evalb', 'evalf', 'evalhf', 'evalindets', 'evaln', 'expand', 'exports', 'factorial', 'floor', 'frac', 'frem', 'FromInert', 'frontend', 'gc', 'genpoly', 'has', 'hastype', 'hfarray', 'icontent', 'igcd', 'ilcm', 'ilog10', 'Im', 'implies', 'indets', 'indices', 'intersect', 'iolib', 'iquo', 'irem', 'iroot', 'iroot', 'isqrt', 'kernelopts', 'lcoeff', 'ldegree', 'length', 'lexorder', 'lhs', 'lowerbound', 'lprint', 'macro', 'map', 'max', 'maxnorm', 'member', 'membertype', 'min', 'minus', 'mod', 'modp', 'modp1', 'modp2', 'mods', 'mul', 'NextAfter', 'nops', 'normal', 'not', 'numboccur', 'numelems', 'numer', 'NumericClass', 'NumericEvent', 'NumericEventHandler', 'NumericStatus', 'op', 'or', 'order', 'OrderedNE', 'ormap', 'orseq', 'parse', 'piecewise', 'pointto', 'print', 'quit', 'Re', 'readlib', 'Record', 'remove', 'rhs', 'round', 'rtable', 'rtable_elems', 'rtable_eval', 'rtable_indfns', 'rtable_num_elems', 'rtable_options', 'rtable_redim', 'rtable_scanblock', 'rtable_set_indfn', 'rtable_split_unit', 'savelib', 'Scale10', 'Scale2', 'SDMPolynom', 'searchtext', 'SearchText', 'select', 'selectremove', 'seq', 'series', 'setattribute', 'SFloatExponent', 'SFloatMantissa', 'sign', 'sort', 'ssystem', 'stop', 'String', 'subs', 'subset', 'subsindets', 'subsop', 'substring', 'system', 'table', 'taylor', 'tcoeff', 'time', 'timelimit', 'ToInert', 'traperror', 'trunc', 'type', 'typematch', 'unames', 'unassign', 'union', 'Unordered', 'upperbound', 'userinfo', 'writeto', 'xor', 'xormap', 'xorseq')
def delayed_callback(self, match, ctx): yield match.start(1), Punctuation, match.group(1) # quote
ctx.pos = match.start(2) orig_end = ctx.end ctx.end = match.end(2)
yield from self.get_tokens_unprocessed(context=ctx) yield match.end(2), Punctuation, match.group(1) # quote
ctx.pos = match.end() ctx.end = orig_end
tokens = { 'root': [ (r'#.*\n', Comment.Single), (r'\(\*', Comment.Multiline, 'comment'), (r'"(\\.|.|\s)*?"', String), (r"('+)((.|\n)*?)\1", delayed_callback), (r'`(\\`|.)*?`', Name), (words(keywords, prefix=r'\b', suffix=r'\b'), Keyword), (words(builtins, prefix=r'\b', suffix=r'\b'), Name.Builtin), (r'[a-zA-Z_][a-zA-Z0-9_]*', Name), (r'(:=|\*\*|@@|<=|>=|<>|->|::|\.\.|&\+|[\+\-\*\.\^\$/@&,:=<>%~])', Operator), (r'[;^!@$\(\)\[\]{}|_\\#?]+', Punctuation), (r'(\d+)(\.\.)', bygroups(Number.Integer, Punctuation)), (r'(\d*\.\d+|\d+\.\d*)([eE][+-]?\d+)?', Number.Float), (r'\d+', Number.Integer), (r'\s+', Whitespace), ], 'comment': [ (r'.*\(\*', Comment.Multiline, '#push'), (r'.*\*\)', Comment.Multiline, '#pop'), (r'.*\n', Comment.Multiline), ] }
def analyse_text(text): if ':=' in text: return 0.1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659""" pygments.lexers.markup ~~~~~~~~~~~~~~~~~~~~~~
Lexers for non-HTML markup languages.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexers.html import XmlLexerfrom pygments.lexers.javascript import JavascriptLexerfrom pygments.lexers.css import CssLexerfrom pygments.lexers.lilypond import LilyPondLexerfrom pygments.lexers.data import JsonLexer
from pygments.lexer import RegexLexer, DelegatingLexer, include, bygroups, \ using, this, do_insertions, default, wordsfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Generic, Other, Whitespace, Literalfrom pygments.util import get_bool_opt, ClassNotFound
__all__ = ['BBCodeLexer', 'MoinWikiLexer', 'RstLexer', 'TexLexer', 'GroffLexer', 'MozPreprocHashLexer', 'MozPreprocPercentLexer', 'MozPreprocXulLexer', 'MozPreprocJavascriptLexer', 'MozPreprocCssLexer', 'MarkdownLexer', 'OrgLexer', 'TiddlyWiki5Lexer', 'WikitextLexer']
class BBCodeLexer(RegexLexer): """ A lexer that highlights BBCode(-like) syntax. """
name = 'BBCode' aliases = ['bbcode'] mimetypes = ['text/x-bbcode'] url = 'https://www.bbcode.org/' version_added = '0.6'
tokens = { 'root': [ (r'[^[]+', Text), # tag/end tag begin (r'\[/?\w+', Keyword, 'tag'), # stray bracket (r'\[', Text), ], 'tag': [ (r'\s+', Text), # attribute with value (r'(\w+)(=)("?[^\s"\]]+"?)', bygroups(Name.Attribute, Operator, String)), # tag argument (a la [color=green]) (r'(=)("?[^\s"\]]+"?)', bygroups(Operator, String)), # tag end (r'\]', Keyword, '#pop'), ], }
class MoinWikiLexer(RegexLexer): """ For MoinMoin (and Trac) Wiki markup. """
name = 'MoinMoin/Trac Wiki markup' aliases = ['trac-wiki', 'moin'] filenames = [] mimetypes = ['text/x-trac-wiki'] url = 'https://moinmo.in' version_added = '0.7'
flags = re.MULTILINE | re.IGNORECASE
tokens = { 'root': [ (r'^#.*$', Comment), (r'(!)(\S+)', bygroups(Keyword, Text)), # Ignore-next # Titles (r'^(=+)([^=]+)(=+)(\s*#.+)?$', bygroups(Generic.Heading, using(this), Generic.Heading, String)), # Literal code blocks, with optional shebang (r'(\{\{\{)(\n#!.+)?', bygroups(Name.Builtin, Name.Namespace), 'codeblock'), (r'(\'\'\'?|\|\||`|__|~~|\^|,,|::)', Comment), # Formatting # Lists (r'^( +)([.*-])( )', bygroups(Text, Name.Builtin, Text)), (r'^( +)([a-z]{1,5}\.)( )', bygroups(Text, Name.Builtin, Text)), # Other Formatting (r'\[\[\w+.*?\]\]', Keyword), # Macro (r'(\[[^\s\]]+)(\s+[^\]]+?)?(\])', bygroups(Keyword, String, Keyword)), # Link (r'^----+$', Keyword), # Horizontal rules (r'[^\n\'\[{!_~^,|]+', Text), (r'\n', Text), (r'.', Text), ], 'codeblock': [ (r'\}\}\}', Name.Builtin, '#pop'), # these blocks are allowed to be nested in Trac, but not MoinMoin (r'\{\{\{', Text, '#push'), (r'[^{}]+', Comment.Preproc), # slurp boring text (r'.', Comment.Preproc), # allow loose { or } ], }
class RstLexer(RegexLexer): """ For reStructuredText markup.
Additional options accepted:
`handlecodeblocks` Highlight the contents of ``.. sourcecode:: language``, ``.. code:: language`` and ``.. code-block:: language`` directives with a lexer for the given language (default: ``True``).
.. versionadded:: 0.8 """ name = 'reStructuredText' url = 'https://docutils.sourceforge.io/rst.html' aliases = ['restructuredtext', 'rst', 'rest'] filenames = ['*.rst', '*.rest'] mimetypes = ["text/x-rst", "text/prs.fallenstein.rst"] version_added = '0.7' flags = re.MULTILINE
def _handle_sourcecode(self, match): from pygments.lexers import get_lexer_by_name
# section header yield match.start(1), Punctuation, match.group(1) yield match.start(2), Text, match.group(2) yield match.start(3), Operator.Word, match.group(3) yield match.start(4), Punctuation, match.group(4) yield match.start(5), Text, match.group(5) yield match.start(6), Keyword, match.group(6) yield match.start(7), Text, match.group(7)
# lookup lexer if wanted and existing lexer = None if self.handlecodeblocks: try: lexer = get_lexer_by_name(match.group(6).strip()) except ClassNotFound: pass indention = match.group(8) indention_size = len(indention) code = (indention + match.group(9) + match.group(10) + match.group(11))
# no lexer for this language. handle it like it was a code block if lexer is None: yield match.start(8), String, code return
# highlight the lines with the lexer. ins = [] codelines = code.splitlines(True) code = '' for line in codelines: if len(line) > indention_size: ins.append((len(code), [(0, Text, line[:indention_size])])) code += line[indention_size:] else: code += line yield from do_insertions(ins, lexer.get_tokens_unprocessed(code))
# from docutils.parsers.rst.states closers = '\'")]}>\u2019\u201d\xbb!?' unicode_delimiters = '\u2010\u2011\u2012\u2013\u2014\u00a0' end_string_suffix = (rf'((?=$)|(?=[-/:.,; \n\x00{re.escape(unicode_delimiters)}{re.escape(closers)}]))')
tokens = { 'root': [ # Heading with overline (r'^(=+|-+|`+|:+|\.+|\'+|"+|~+|\^+|_+|\*+|\++|#+)([ \t]*\n)' r'(.+)(\n)(\1)(\n)', bygroups(Generic.Heading, Text, Generic.Heading, Text, Generic.Heading, Text)), # Plain heading (r'^(\S.*)(\n)(={3,}|-{3,}|`{3,}|:{3,}|\.{3,}|\'{3,}|"{3,}|' r'~{3,}|\^{3,}|_{3,}|\*{3,}|\+{3,}|#{3,})(\n)', bygroups(Generic.Heading, Text, Generic.Heading, Text)), # Bulleted lists (r'^(\s*)([-*+])( .+\n(?:\1 .+\n)*)', bygroups(Text, Number, using(this, state='inline'))), # Numbered lists (r'^(\s*)([0-9#ivxlcmIVXLCM]+\.)( .+\n(?:\1 .+\n)*)', bygroups(Text, Number, using(this, state='inline'))), (r'^(\s*)(\(?[0-9#ivxlcmIVXLCM]+\))( .+\n(?:\1 .+\n)*)', bygroups(Text, Number, using(this, state='inline'))), # Numbered, but keep words at BOL from becoming lists (r'^(\s*)([A-Z]+\.)( .+\n(?:\1 .+\n)+)', bygroups(Text, Number, using(this, state='inline'))), (r'^(\s*)(\(?[A-Za-z]+\))( .+\n(?:\1 .+\n)+)', bygroups(Text, Number, using(this, state='inline'))), # Line blocks (r'^(\s*)(\|)( .+\n(?:\| .+\n)*)', bygroups(Text, Operator, using(this, state='inline'))), # Sourcecode directives (r'^( *\.\.)(\s*)((?:source)?code(?:-block)?)(::)([ \t]*)([^\n]+)' r'(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\8.*)?\n)+)', _handle_sourcecode), # A directive (r'^( *\.\.)(\s*)([\w:-]+?)(::)(?:([ \t]*)(.*))', bygroups(Punctuation, Text, Operator.Word, Punctuation, Text, using(this, state='inline'))), # A reference target (r'^( *\.\.)(\s*)(_(?:[^:\\]|\\.)+:)(.*?)$', bygroups(Punctuation, Text, Name.Tag, using(this, state='inline'))), # A footnote/citation target (r'^( *\.\.)(\s*)(\[.+\])(.*?)$', bygroups(Punctuation, Text, Name.Tag, using(this, state='inline'))), # A substitution def (r'^( *\.\.)(\s*)(\|.+\|)(\s*)([\w:-]+?)(::)(?:([ \t]*)(.*))', bygroups(Punctuation, Text, Name.Tag, Text, Operator.Word, Punctuation, Text, using(this, state='inline'))), # Comments (r'^ *\.\..*(\n( +.*\n|\n)+)?', Comment), # Field list marker (r'^( *)(:(?:\\\\|\\:|[^:\n])+:(?=\s))([ \t]*)', bygroups(Text, Name.Class, Text)), # Definition list (r'^(\S.*(?<!::)\n)((?:(?: +.*)\n)+)', bygroups(using(this, state='inline'), using(this, state='inline'))), # Code blocks (r'(::)(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\3.*)?\n)+)', bygroups(String.Escape, Text, String, String, Text, String)), include('inline'), ], 'inline': [ (r'\\.', Text), # escape (r'``', String, 'literal'), # code (r'(`.+?)(<.+?>)(`__?)', # reference with inline target bygroups(String, String.Interpol, String)), (r'`.+?`__?', String), # reference (r'(`.+?`)(:[a-zA-Z0-9:-]+?:)?', bygroups(Name.Variable, Name.Attribute)), # role (r'(:[a-zA-Z0-9:-]+?:)(`.+?`)', bygroups(Name.Attribute, Name.Variable)), # role (content first) (r'\*\*.+?\*\*', Generic.Strong), # Strong emphasis (r'\*.+?\*', Generic.Emph), # Emphasis (r'\[.*?\]_', String), # Footnote or citation (r'<.+?>', Name.Tag), # Hyperlink (r'[^\\\n\[*`:]+', Text), (r'.', Text), ], 'literal': [ (r'[^`]+', String), (r'``' + end_string_suffix, String, '#pop'), (r'`', String), ] }
def __init__(self, **options): self.handlecodeblocks = get_bool_opt(options, 'handlecodeblocks', True) RegexLexer.__init__(self, **options)
def analyse_text(text): if text[:2] == '..' and text[2:3] != '.': return 0.3 p1 = text.find("\n") p2 = text.find("\n", p1 + 1) if (p2 > -1 and # has two lines p1 * 2 + 1 == p2 and # they are the same length text[p1+1] in '-=' and # the next line both starts and ends with text[p1+1] == text[p2-1]): # ...a sufficiently high header return 0.5
class TexLexer(RegexLexer): """ Lexer for the TeX and LaTeX typesetting languages. """
name = 'TeX' aliases = ['tex', 'latex'] filenames = ['*.tex', '*.aux', '*.toc'] mimetypes = ['text/x-tex', 'text/x-latex'] url = 'https://tug.org' version_added = ''
tokens = { 'general': [ (r'%.*?\n', Comment), (r'[{}]', Name.Builtin), (r'[&_^]', Name.Builtin), ], 'root': [ (r'\\\[', String.Backtick, 'displaymath'), (r'\\\(', String, 'inlinemath'), (r'\$\$', String.Backtick, 'displaymath'), (r'\$', String, 'inlinemath'), (r'\\([a-zA-Z@_:]+|\S?)', Keyword, 'command'), (r'\\$', Keyword), include('general'), (r'[^\\$%&_^{}]+', Text), ], 'math': [ (r'\\([a-zA-Z]+|\S?)', Name.Variable), include('general'), (r'[0-9]+', Number), (r'[-=!+*/()\[\]]', Operator), (r'[^=!+*/()\[\]\\$%&_^{}0-9-]+', Name.Builtin), ], 'inlinemath': [ (r'\\\)', String, '#pop'), (r'\$', String, '#pop'), include('math'), ], 'displaymath': [ (r'\\\]', String, '#pop'), (r'\$\$', String, '#pop'), (r'\$', Name.Builtin), include('math'), ], 'command': [ (r'\[.*?\]', Name.Attribute), (r'\*', Keyword), default('#pop'), ], }
def analyse_text(text): for start in ("\\documentclass", "\\input", "\\documentstyle", "\\relax"): if text[:len(start)] == start: return True
class GroffLexer(RegexLexer): """ Lexer for the (g)roff typesetting language, supporting groff extensions. Mainly useful for highlighting manpage sources. """
name = 'Groff' aliases = ['groff', 'nroff', 'man'] filenames = ['*.[1-9]', '*.man', '*.1p', '*.3pm'] mimetypes = ['application/x-troff', 'text/troff'] url = 'https://www.gnu.org/software/groff' version_added = '0.6'
tokens = { 'root': [ (r'(\.)(\w+)', bygroups(Text, Keyword), 'request'), (r'\.', Punctuation, 'request'), # Regular characters, slurp till we find a backslash or newline (r'[^\\\n]+', Text, 'textline'), default('textline'), ], 'textline': [ include('escapes'), (r'[^\\\n]+', Text), (r'\n', Text, '#pop'), ], 'escapes': [ # groff has many ways to write escapes. (r'\\"[^\n]*', Comment), (r'\\[fn]\w', String.Escape), (r'\\\(.{2}', String.Escape), (r'\\.\[.*\]', String.Escape), (r'\\.', String.Escape), (r'\\\n', Text, 'request'), ], 'request': [ (r'\n', Text, '#pop'), include('escapes'), (r'"[^\n"]+"', String.Double), (r'\d+', Number), (r'\S+', String), (r'\s+', Text), ], }
def analyse_text(text): if text[:1] != '.': return False if text[:3] == '.\\"': return True if text[:4] == '.TH ': return True if text[1:3].isalnum() and text[3].isspace(): return 0.9
class MozPreprocHashLexer(RegexLexer): """ Lexer for Mozilla Preprocessor files (with '#' as the marker).
Other data is left untouched. """ name = 'mozhashpreproc' aliases = [name] filenames = [] mimetypes = [] url = 'https://firefox-source-docs.mozilla.org/build/buildsystem/preprocessor.html' version_added = '2.0'
tokens = { 'root': [ (r'^#', Comment.Preproc, ('expr', 'exprstart')), (r'.+', Other), ], 'exprstart': [ (r'(literal)(.*)', bygroups(Comment.Preproc, Text), '#pop:2'), (words(( 'define', 'undef', 'if', 'ifdef', 'ifndef', 'else', 'elif', 'elifdef', 'elifndef', 'endif', 'expand', 'filter', 'unfilter', 'include', 'includesubst', 'error')), Comment.Preproc, '#pop'), ], 'expr': [ (words(('!', '!=', '==', '&&', '||')), Operator), (r'(defined)(\()', bygroups(Keyword, Punctuation)), (r'\)', Punctuation), (r'[0-9]+', Number.Decimal), (r'__\w+?__', Name.Variable), (r'@\w+?@', Name.Class), (r'\w+', Name), (r'\n', Text, '#pop'), (r'\s+', Text), (r'\S', Punctuation), ], }
class MozPreprocPercentLexer(MozPreprocHashLexer): """ Lexer for Mozilla Preprocessor files (with '%' as the marker).
Other data is left untouched. """ name = 'mozpercentpreproc' aliases = [name] filenames = [] mimetypes = [] url = 'https://firefox-source-docs.mozilla.org/build/buildsystem/preprocessor.html' version_added = '2.0'
tokens = { 'root': [ (r'^%', Comment.Preproc, ('expr', 'exprstart')), (r'.+', Other), ], }
class MozPreprocXulLexer(DelegatingLexer): """ Subclass of the `MozPreprocHashLexer` that highlights unlexed data with the `XmlLexer`. """ name = "XUL+mozpreproc" aliases = ['xul+mozpreproc'] filenames = ['*.xul.in'] mimetypes = [] url = 'https://firefox-source-docs.mozilla.org/build/buildsystem/preprocessor.html' version_added = '2.0'
def __init__(self, **options): super().__init__(XmlLexer, MozPreprocHashLexer, **options)
class MozPreprocJavascriptLexer(DelegatingLexer): """ Subclass of the `MozPreprocHashLexer` that highlights unlexed data with the `JavascriptLexer`. """ name = "Javascript+mozpreproc" aliases = ['javascript+mozpreproc'] filenames = ['*.js.in'] mimetypes = [] url = 'https://firefox-source-docs.mozilla.org/build/buildsystem/preprocessor.html' version_added = '2.0'
def __init__(self, **options): super().__init__(JavascriptLexer, MozPreprocHashLexer, **options)
class MozPreprocCssLexer(DelegatingLexer): """ Subclass of the `MozPreprocHashLexer` that highlights unlexed data with the `CssLexer`. """ name = "CSS+mozpreproc" aliases = ['css+mozpreproc'] filenames = ['*.css.in'] mimetypes = [] url = 'https://firefox-source-docs.mozilla.org/build/buildsystem/preprocessor.html' version_added = '2.0'
def __init__(self, **options): super().__init__(CssLexer, MozPreprocPercentLexer, **options)
class MarkdownLexer(RegexLexer): """ For Markdown markup. """ name = 'Markdown' url = 'https://daringfireball.net/projects/markdown/' aliases = ['markdown', 'md'] filenames = ['*.md', '*.markdown'] mimetypes = ["text/x-markdown"] version_added = '2.2' flags = re.MULTILINE
def _handle_codeblock(self, match): from pygments.lexers import get_lexer_by_name
yield match.start('initial'), String.Backtick, match.group('initial') yield match.start('lang'), String.Backtick, match.group('lang') if match.group('afterlang') is not None: yield match.start('whitespace'), Whitespace, match.group('whitespace') yield match.start('extra'), Text, match.group('extra') yield match.start('newline'), Whitespace, match.group('newline')
# lookup lexer if wanted and existing lexer = None if self.handlecodeblocks: try: lexer = get_lexer_by_name(match.group('lang').strip()) except ClassNotFound: pass code = match.group('code') # no lexer for this language. handle it like it was a code block if lexer is None: yield match.start('code'), String, code else: # FIXME: aren't the offsets wrong? yield from do_insertions([], lexer.get_tokens_unprocessed(code))
yield match.start('terminator'), String.Backtick, match.group('terminator')
tokens = { 'root': [ # heading with '#' prefix (atx-style) (r'(^#[^#].+)(\n)', bygroups(Generic.Heading, Text)), # subheading with '#' prefix (atx-style) (r'(^#{2,6}[^#].+)(\n)', bygroups(Generic.Subheading, Text)), # heading with '=' underlines (Setext-style) (r'^(.+)(\n)(=+)(\n)', bygroups(Generic.Heading, Text, Generic.Heading, Text)), # subheading with '-' underlines (Setext-style) (r'^(.+)(\n)(-+)(\n)', bygroups(Generic.Subheading, Text, Generic.Subheading, Text)), # task list (r'^(\s*)([*-] )(\[[ xX]\])( .+\n)', bygroups(Whitespace, Keyword, Keyword, using(this, state='inline'))), # bulleted list (r'^(\s*)([*-])(\s)(.+\n)', bygroups(Whitespace, Keyword, Whitespace, using(this, state='inline'))), # numbered list (r'^(\s*)([0-9]+\.)( .+\n)', bygroups(Whitespace, Keyword, using(this, state='inline'))), # quote (r'^(\s*>\s)(.+\n)', bygroups(Keyword, Generic.Emph)), # code block fenced by 3 backticks (r'^(\s*```\n[\w\W]*?^\s*```$\n)', String.Backtick), # code block with language # Some tools include extra stuff after the language name, just # highlight that as text. For example: https://docs.enola.dev/use/execmd (r'''(?x) ^(?P<initial>\s*```) (?P<lang>[\w\-]+) (?P<afterlang> (?P<whitespace>[^\S\n]+) (?P<extra>.*))? (?P<newline>\n) (?P<code>(.|\n)*?) (?P<terminator>^\s*```$\n) ''', _handle_codeblock),
include('inline'), ], 'inline': [ # escape (r'\\.', Text), # inline code (r'([^`]?)(`[^`\n]+`)', bygroups(Text, String.Backtick)), # warning: the following rules eat outer tags. # eg. **foo _bar_ baz** => foo and baz are not recognized as bold # bold fenced by '**' (r'([^\*]?)(\*\*[^* \n][^*\n]*\*\*)', bygroups(Text, Generic.Strong)), # bold fenced by '__' (r'([^_]?)(__[^_ \n][^_\n]*__)', bygroups(Text, Generic.Strong)), # italics fenced by '*' (r'([^\*]?)(\*[^* \n][^*\n]*\*)', bygroups(Text, Generic.Emph)), # italics fenced by '_' (r'([^_]?)(_[^_ \n][^_\n]*_)', bygroups(Text, Generic.Emph)), # strikethrough (r'([^~]?)(~~[^~ \n][^~\n]*~~)', bygroups(Text, Generic.Deleted)), # mentions and topics (twitter and github stuff) (r'[@#][\w/:]+', Name.Entity), # (image?) links eg:  (r'(!?\[)([^]]+)(\])(\()([^)]+)(\))', bygroups(Text, Name.Tag, Text, Text, Name.Attribute, Text)), # reference-style links, e.g.: # [an example][id] # [id]: http://example.com/ (r'(\[)([^]]+)(\])(\[)([^]]*)(\])', bygroups(Text, Name.Tag, Text, Text, Name.Label, Text)), (r'^(\s*\[)([^]]*)(\]:\s*)(.+)', bygroups(Text, Name.Label, Text, Name.Attribute)),
# general text, must come last! (r'[^\\\s]+', Text), (r'.', Text), ], }
def __init__(self, **options): self.handlecodeblocks = get_bool_opt(options, 'handlecodeblocks', True) RegexLexer.__init__(self, **options)
class OrgLexer(RegexLexer): """ For Org Mode markup. """ name = 'Org Mode' url = 'https://orgmode.org' aliases = ['org', 'orgmode', 'org-mode'] filenames = ['*.org'] mimetypes = ["text/org"] version_added = '2.18'
def _inline(start, end): return rf'(?<!\w){start}(.|\n(?!\n))+?{end}(?!\w)'
tokens = { 'root': [ (r'^# .*', Comment.Single),
# Headings (r'^(\* )(COMMENT)( .*)', bygroups(Generic.Heading, Comment.Preproc, Generic.Heading)), (r'^(\*\*+ )(COMMENT)( .*)', bygroups(Generic.Subheading, Comment.Preproc, Generic.Subheading)), (r'^(\* )(DONE)( .*)', bygroups(Generic.Heading, Generic.Deleted, Generic.Heading)), (r'^(\*\*+ )(DONE)( .*)', bygroups(Generic.Subheading, Generic.Deleted, Generic.Subheading)), (r'^(\* )(TODO)( .*)', bygroups(Generic.Heading, Generic.Error, Generic.Heading)), (r'^(\*\*+ )(TODO)( .*)', bygroups(Generic.Subheading, Generic.Error, Generic.Subheading)),
(r'^(\* .+?)( :[a-zA-Z0-9_@:]+:)?$', bygroups(Generic.Heading, Generic.Emph)), (r'^(\*\*+ .+?)( :[a-zA-Z0-9_@:]+:)?$', bygroups(Generic.Subheading, Generic.Emph)),
# Unordered lists items, including TODO items and description items (r'^(?:( *)([+-] )|( +)(\* ))(\[[ X-]\])?(.+ ::)?', bygroups(Whitespace, Keyword, Whitespace, Keyword, Generic.Prompt, Name.Label)),
# Ordered list items (r'^( *)([0-9]+[.)])( \[@[0-9]+\])?', bygroups(Whitespace, Keyword, Generic.Emph)),
# Dynamic blocks (r'(?i)^( *#\+begin: *)((?:.|\n)*?)(^ *#\+end: *$)', bygroups(Operator.Word, using(this), Operator.Word)),
# Comment blocks (r'(?i)^( *#\+begin_comment *\n)((?:.|\n)*?)(^ *#\+end_comment *$)', bygroups(Operator.Word, Comment.Multiline, Operator.Word)),
# Source code blocks # TODO: language-dependent syntax highlighting (see Markdown lexer) (r'(?i)^( *#\+begin_src .*)((?:.|\n)*?)(^ *#\+end_src *$)', bygroups(Operator.Word, Text, Operator.Word)),
# Other blocks (r'(?i)^( *#\+begin_\w+)( *\n)((?:.|\n)*?)(^ *#\+end_\w+)( *$)', bygroups(Operator.Word, Whitespace, Text, Operator.Word, Whitespace)),
# Keywords (r'^(#\+\w+:)(.*)$', bygroups(Name.Namespace, Text)),
# Properties and drawers (r'(?i)^( *:\w+: *\n)((?:.|\n)*?)(^ *:end: *$)', bygroups(Name.Decorator, Comment.Special, Name.Decorator)),
# Line break operator (r'\\\\$', Operator),
(r'^\s*CLOSED:\s+', Generic.Deleted, 'dateline'), (r'^\s*(?:DEADLINE:|SCHEDULED:)\s+', Generic.Error, 'dateline'),
# Bold (_inline(r'\*', r'\*+'), Generic.Strong), # Italic (_inline(r'/', r'/'), Generic.Emph), # Verbatim (_inline(r'=', r'='), String), # TODO token # Code (_inline(r'~', r'~'), String), # Strikethrough (_inline(r'\+', r'\+'), Generic.Deleted), # Underline (_inline(r'_', r'_+'), Generic.EmphStrong),
# Dates (r'<.+?>', Literal.Date), # Macros (r'\{\{\{.+?\}\}\}', Comment.Preproc), # Footnotes (r'(?<!\[)\[fn:.+?\]', Name.Tag), # Links (r'(?s)(\[\[)(.*?)(\]\[)(.*?)(\]\])', bygroups(Punctuation, Name.Attribute, Punctuation, Name.Tag, Punctuation)), (r'(?s)(\[\[)(.+?)(\]\])', bygroups(Punctuation, Name.Attribute, Punctuation)), (r'(<<)(.+?)(>>)', bygroups(Punctuation, Name.Attribute, Punctuation)),
# Tables (r'^( *)(\|[ -].*?[ -]\|)$', bygroups(Whitespace, String)),
# Any other text (r'[^#*+\-0-9:\\/=~_<{\[|\n]+', Text), (r'[#*+\-0-9:\\/=~_<{\[|\n]', Text), ], 'dateline': [ (r'\s*CLOSED:\s+', Generic.Deleted), (r'\s*(?:DEADLINE:|SCHEDULED:)\s+', Generic.Error), (r'\[.+?\]', Literal.Date), (r'<[^>]+?>', Literal.Date), (r'(\s*)$', Text, '#pop'), (r'.', Text), ], }
class TiddlyWiki5Lexer(RegexLexer): """ For TiddlyWiki5 markup. """ name = 'tiddler' url = 'https://tiddlywiki.com/#TiddlerFiles' aliases = ['tid'] filenames = ['*.tid'] mimetypes = ["text/vnd.tiddlywiki"] version_added = '2.7' flags = re.MULTILINE
def _handle_codeblock(self, match): """ match args: 1:backticks, 2:lang_name, 3:newline, 4:code, 5:backticks """ from pygments.lexers import get_lexer_by_name
# section header yield match.start(1), String, match.group(1) yield match.start(2), String, match.group(2) yield match.start(3), Text, match.group(3)
# lookup lexer if wanted and existing lexer = None if self.handlecodeblocks: try: lexer = get_lexer_by_name(match.group(2).strip()) except ClassNotFound: pass code = match.group(4)
# no lexer for this language. handle it like it was a code block if lexer is None: yield match.start(4), String, code return
yield from do_insertions([], lexer.get_tokens_unprocessed(code))
yield match.start(5), String, match.group(5)
def _handle_cssblock(self, match): """ match args: 1:style tag 2:newline, 3:code, 4:closing style tag """ from pygments.lexers import get_lexer_by_name
# section header yield match.start(1), String, match.group(1) yield match.start(2), String, match.group(2)
lexer = None if self.handlecodeblocks: try: lexer = get_lexer_by_name('css') except ClassNotFound: pass code = match.group(3)
# no lexer for this language. handle it like it was a code block if lexer is None: yield match.start(3), String, code return
yield from do_insertions([], lexer.get_tokens_unprocessed(code))
yield match.start(4), String, match.group(4)
tokens = { 'root': [ # title in metadata section (r'^(title)(:\s)(.+\n)', bygroups(Keyword, Text, Generic.Heading)), # headings (r'^(!)([^!].+\n)', bygroups(Generic.Heading, Text)), (r'^(!{2,6})(.+\n)', bygroups(Generic.Subheading, Text)), # bulleted or numbered lists or single-line block quotes # (can be mixed) (r'^(\s*)([*#>]+)(\s*)(.+\n)', bygroups(Text, Keyword, Text, using(this, state='inline'))), # multi-line block quotes (r'^(<<<.*\n)([\w\W]*?)(^<<<.*$)', bygroups(String, Text, String)), # table header (r'^(\|.*?\|h)$', bygroups(Generic.Strong)), # table footer or caption (r'^(\|.*?\|[cf])$', bygroups(Generic.Emph)), # table class (r'^(\|.*?\|k)$', bygroups(Name.Tag)), # definitions (r'^(;.*)$', bygroups(Generic.Strong)), # text block (r'^(```\n)([\w\W]*?)(^```$)', bygroups(String, Text, String)), # code block with language (r'^(```)(\w+)(\n)([\w\W]*?)(^```$)', _handle_codeblock), # CSS style block (r'^(<style>)(\n)([\w\W]*?)(^</style>$)', _handle_cssblock),
include('keywords'), include('inline'), ], 'keywords': [ (words(( '\\define', '\\end', 'caption', 'created', 'modified', 'tags', 'title', 'type'), prefix=r'^', suffix=r'\b'), Keyword), ], 'inline': [ # escape (r'\\.', Text), # created or modified date (r'\d{17}', Number.Integer), # italics (r'(\s)(//[^/]+//)((?=\W|\n))', bygroups(Text, Generic.Emph, Text)), # superscript (r'(\s)(\^\^[^\^]+\^\^)', bygroups(Text, Generic.Emph)), # subscript (r'(\s)(,,[^,]+,,)', bygroups(Text, Generic.Emph)), # underscore (r'(\s)(__[^_]+__)', bygroups(Text, Generic.Strong)), # bold (r"(\s)(''[^']+'')((?=\W|\n))", bygroups(Text, Generic.Strong, Text)), # strikethrough (r'(\s)(~~[^~]+~~)((?=\W|\n))', bygroups(Text, Generic.Deleted, Text)), # TiddlyWiki variables (r'<<[^>]+>>', Name.Tag), (r'\$\$[^$]+\$\$', Name.Tag), (r'\$\([^)]+\)\$', Name.Tag), # TiddlyWiki style or class (r'^@@.*$', Name.Tag), # HTML tags (r'</?[^>]+>', Name.Tag), # inline code (r'`[^`]+`', String.Backtick), # HTML escaped symbols (r'&\S*?;', String.Regex), # Wiki links (r'(\[{2})([^]\|]+)(\]{2})', bygroups(Text, Name.Tag, Text)), # External links (r'(\[{2})([^]\|]+)(\|)([^]\|]+)(\]{2})', bygroups(Text, Name.Tag, Text, Name.Attribute, Text)), # Transclusion (r'(\{{2})([^}]+)(\}{2})', bygroups(Text, Name.Tag, Text)), # URLs (r'(\b.?.?tps?://[^\s"]+)', bygroups(Name.Attribute)),
# general text, must come last! (r'[\w]+', Text), (r'.', Text) ], }
def __init__(self, **options): self.handlecodeblocks = get_bool_opt(options, 'handlecodeblocks', True) RegexLexer.__init__(self, **options)
class WikitextLexer(RegexLexer): """ For MediaWiki Wikitext.
Parsing Wikitext is tricky, and results vary between different MediaWiki installations, so we only highlight common syntaxes (built-in or from popular extensions), and also assume templates produce no unbalanced syntaxes. """ name = 'Wikitext' url = 'https://www.mediawiki.org/wiki/Wikitext' aliases = ['wikitext', 'mediawiki'] filenames = [] mimetypes = ['text/x-wiki'] version_added = '2.15' flags = re.MULTILINE
def nowiki_tag_rules(tag_name): return [ (rf'(?i)(</)({tag_name})(\s*)(>)', bygroups(Punctuation, Name.Tag, Whitespace, Punctuation), '#pop'), include('entity'), include('text'), ]
def plaintext_tag_rules(tag_name): return [ (rf'(?si)(.*?)(</)({tag_name})(\s*)(>)', bygroups(Text, Punctuation, Name.Tag, Whitespace, Punctuation), '#pop'), ]
def delegate_tag_rules(tag_name, lexer, **lexer_kwargs): return [ (rf'(?i)(</)({tag_name})(\s*)(>)', bygroups(Punctuation, Name.Tag, Whitespace, Punctuation), '#pop'), (rf'(?si).+?(?=</{tag_name}\s*>)', using(lexer, **lexer_kwargs)), ]
def text_rules(token): return [ (r'\w+', token), (r'[^\S\n]+', token), (r'(?s).', token), ]
def handle_syntaxhighlight(self, match, ctx): from pygments.lexers import get_lexer_by_name
attr_content = match.group() start = 0 index = 0 while True: index = attr_content.find('>', start) # Exclude comment end (-->) if attr_content[index-2:index] != '--': break start = index + 1
if index == -1: # No tag end yield from self.get_tokens_unprocessed(attr_content, stack=['root', 'attr']) return attr = attr_content[:index] yield from self.get_tokens_unprocessed(attr, stack=['root', 'attr']) yield match.start(3) + index, Punctuation, '>'
lexer = None content = attr_content[index+1:] lang_match = re.findall(r'\blang=("|\'|)(\w+)(\1)', attr)
if len(lang_match) >= 1: # Pick the last match in case of multiple matches lang = lang_match[-1][1] try: lexer = get_lexer_by_name(lang) except ClassNotFound: pass
if lexer is None: yield match.start() + index + 1, Text, content else: yield from lexer.get_tokens_unprocessed(content)
def handle_score(self, match, ctx): attr_content = match.group() start = 0 index = 0 while True: index = attr_content.find('>', start) # Exclude comment end (-->) if attr_content[index-2:index] != '--': break start = index + 1
if index == -1: # No tag end yield from self.get_tokens_unprocessed(attr_content, stack=['root', 'attr']) return attr = attr_content[:index] content = attr_content[index+1:] yield from self.get_tokens_unprocessed(attr, stack=['root', 'attr']) yield match.start(3) + index, Punctuation, '>'
lang_match = re.findall(r'\blang=("|\'|)(\w+)(\1)', attr) # Pick the last match in case of multiple matches lang = lang_match[-1][1] if len(lang_match) >= 1 else 'lilypond'
if lang == 'lilypond': # Case sensitive yield from LilyPondLexer().get_tokens_unprocessed(content) else: # ABC # FIXME: Use ABC lexer in the future yield match.start() + index + 1, Text, content
# a-z removed to prevent linter from complaining, REMEMBER to use (?i) title_char = r' %!"$&\'()*,\-./0-9:;=?@A-Z\\\^_`~+\u0080-\uFFFF' nbsp_char = r'(?:\t| |&\#0*160;|&\#[Xx]0*[Aa]0;|[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000])' link_address = r'(?:[0-9.]+|\[[0-9a-f:.]+\]|[^\x00-\x20"<>\[\]\x7F\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFFFD])' link_char_class = r'[^\x00-\x20"<>\[\]\x7F\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFFFD]' double_slashes_i = { '__FORCETOC__', '__NOCONTENTCONVERT__', '__NOCC__', '__NOEDITSECTION__', '__NOGALLERY__', '__NOTITLECONVERT__', '__NOTC__', '__NOTOC__', '__TOC__', } double_slashes = { '__EXPECTUNUSEDCATEGORY__', '__HIDDENCAT__', '__INDEX__', '__NEWSECTIONLINK__', '__NOINDEX__', '__NONEWSECTIONLINK__', '__STATICREDIRECT__', '__NOGLOBAL__', '__DISAMBIG__', '__EXPECTED_UNCONNECTED_PAGE__', } protocols = { 'bitcoin:', 'ftp://', 'ftps://', 'geo:', 'git://', 'gopher://', 'http://', 'https://', 'irc://', 'ircs://', 'magnet:', 'mailto:', 'mms://', 'news:', 'nntp://', 'redis://', 'sftp://', 'sip:', 'sips:', 'sms:', 'ssh://', 'svn://', 'tel:', 'telnet://', 'urn:', 'worldwind://', 'xmpp:', '//', } non_relative_protocols = protocols - {'//'} html_tags = { 'abbr', 'b', 'bdi', 'bdo', 'big', 'blockquote', 'br', 'caption', 'center', 'cite', 'code', 'data', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em', 'font', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'ins', 'kbd', 'li', 'link', 'mark', 'meta', 'ol', 'p', 'q', 'rb', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'table', 'td', 'th', 'time', 'tr', 'tt', 'u', 'ul', 'var', 'wbr', } parser_tags = { 'graph', 'charinsert', 'rss', 'chem', 'categorytree', 'nowiki', 'inputbox', 'math', 'hiero', 'score', 'pre', 'ref', 'translate', 'imagemap', 'templatestyles', 'languages', 'noinclude', 'mapframe', 'section', 'poem', 'syntaxhighlight', 'includeonly', 'tvar', 'onlyinclude', 'templatedata', 'langconvert', 'timeline', 'dynamicpagelist', 'gallery', 'maplink', 'ce', 'references', } variant_langs = { # ZhConverter.php 'zh', 'zh-hans', 'zh-hant', 'zh-cn', 'zh-hk', 'zh-mo', 'zh-my', 'zh-sg', 'zh-tw', # WuuConverter.php 'wuu', 'wuu-hans', 'wuu-hant', # UzConverter.php 'uz', 'uz-latn', 'uz-cyrl', # TlyConverter.php 'tly', 'tly-cyrl', # TgConverter.php 'tg', 'tg-latn', # SrConverter.php 'sr', 'sr-ec', 'sr-el', # ShiConverter.php 'shi', 'shi-tfng', 'shi-latn', # ShConverter.php 'sh-latn', 'sh-cyrl', # KuConverter.php 'ku', 'ku-arab', 'ku-latn', # IuConverter.php 'iu', 'ike-cans', 'ike-latn', # GanConverter.php 'gan', 'gan-hans', 'gan-hant', # EnConverter.php 'en', 'en-x-piglatin', # CrhConverter.php 'crh', 'crh-cyrl', 'crh-latn', # BanConverter.php 'ban', 'ban-bali', 'ban-x-dharma', 'ban-x-palmleaf', 'ban-x-pku', } magic_vars_i = { 'ARTICLEPATH', 'INT', 'PAGEID', 'SCRIPTPATH', 'SERVER', 'SERVERNAME', 'STYLEPATH', } magic_vars = { '!', '=', 'BASEPAGENAME', 'BASEPAGENAMEE', 'CASCADINGSOURCES', 'CONTENTLANGUAGE', 'CONTENTLANG', 'CURRENTDAY', 'CURRENTDAY2', 'CURRENTDAYNAME', 'CURRENTDOW', 'CURRENTHOUR', 'CURRENTMONTH', 'CURRENTMONTH2', 'CURRENTMONTH1', 'CURRENTMONTHABBREV', 'CURRENTMONTHNAME', 'CURRENTMONTHNAMEGEN', 'CURRENTTIME', 'CURRENTTIMESTAMP', 'CURRENTVERSION', 'CURRENTWEEK', 'CURRENTYEAR', 'DIRECTIONMARK', 'DIRMARK', 'FULLPAGENAME', 'FULLPAGENAMEE', 'LOCALDAY', 'LOCALDAY2', 'LOCALDAYNAME', 'LOCALDOW', 'LOCALHOUR', 'LOCALMONTH', 'LOCALMONTH2', 'LOCALMONTH1', 'LOCALMONTHABBREV', 'LOCALMONTHNAME', 'LOCALMONTHNAMEGEN', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCALWEEK', 'LOCALYEAR', 'NAMESPACE', 'NAMESPACEE', 'NAMESPACENUMBER', 'NUMBEROFACTIVEUSERS', 'NUMBEROFADMINS', 'NUMBEROFARTICLES', 'NUMBEROFEDITS', 'NUMBEROFFILES', 'NUMBEROFPAGES', 'NUMBEROFUSERS', 'PAGELANGUAGE', 'PAGENAME', 'PAGENAMEE', 'REVISIONDAY', 'REVISIONDAY2', 'REVISIONID', 'REVISIONMONTH', 'REVISIONMONTH1', 'REVISIONSIZE', 'REVISIONTIMESTAMP', 'REVISIONUSER', 'REVISIONYEAR', 'ROOTPAGENAME', 'ROOTPAGENAMEE', 'SITENAME', 'SUBJECTPAGENAME', 'ARTICLEPAGENAME', 'SUBJECTPAGENAMEE', 'ARTICLEPAGENAMEE', 'SUBJECTSPACE', 'ARTICLESPACE', 'SUBJECTSPACEE', 'ARTICLESPACEE', 'SUBPAGENAME', 'SUBPAGENAMEE', 'TALKPAGENAME', 'TALKPAGENAMEE', 'TALKSPACE', 'TALKSPACEE', } parser_functions_i = { 'ANCHORENCODE', 'BIDI', 'CANONICALURL', 'CANONICALURLE', 'FILEPATH', 'FORMATNUM', 'FULLURL', 'FULLURLE', 'GENDER', 'GRAMMAR', 'INT', r'\#LANGUAGE', 'LC', 'LCFIRST', 'LOCALURL', 'LOCALURLE', 'NS', 'NSE', 'PADLEFT', 'PADRIGHT', 'PAGEID', 'PLURAL', 'UC', 'UCFIRST', 'URLENCODE', } parser_functions = { 'BASEPAGENAME', 'BASEPAGENAMEE', 'CASCADINGSOURCES', 'DEFAULTSORT', 'DEFAULTSORTKEY', 'DEFAULTCATEGORYSORT', 'FULLPAGENAME', 'FULLPAGENAMEE', 'NAMESPACE', 'NAMESPACEE', 'NAMESPACENUMBER', 'NUMBERINGROUP', 'NUMINGROUP', 'NUMBEROFACTIVEUSERS', 'NUMBEROFADMINS', 'NUMBEROFARTICLES', 'NUMBEROFEDITS', 'NUMBEROFFILES', 'NUMBEROFPAGES', 'NUMBEROFUSERS', 'PAGENAME', 'PAGENAMEE', 'PAGESINCATEGORY', 'PAGESINCAT', 'PAGESIZE', 'PROTECTIONEXPIRY', 'PROTECTIONLEVEL', 'REVISIONDAY', 'REVISIONDAY2', 'REVISIONID', 'REVISIONMONTH', 'REVISIONMONTH1', 'REVISIONTIMESTAMP', 'REVISIONUSER', 'REVISIONYEAR', 'ROOTPAGENAME', 'ROOTPAGENAMEE', 'SUBJECTPAGENAME', 'ARTICLEPAGENAME', 'SUBJECTPAGENAMEE', 'ARTICLEPAGENAMEE', 'SUBJECTSPACE', 'ARTICLESPACE', 'SUBJECTSPACEE', 'ARTICLESPACEE', 'SUBPAGENAME', 'SUBPAGENAMEE', 'TALKPAGENAME', 'TALKPAGENAMEE', 'TALKSPACE', 'TALKSPACEE', 'INT', 'DISPLAYTITLE', 'PAGESINNAMESPACE', 'PAGESINNS', }
tokens = { 'root': [ # Redirects (r"""(?xi) (\A\s*?)(\#REDIRECT:?) # may contain a colon (\s+)(\[\[) (?=[^\]\n]* \]\]$) """, bygroups(Whitespace, Keyword, Whitespace, Punctuation), 'redirect-inner'), # Subheadings (r'^(={2,6})(.+?)(\1)(\s*$\n)', bygroups(Generic.Subheading, Generic.Subheading, Generic.Subheading, Whitespace)), # Headings (r'^(=.+?=)(\s*$\n)', bygroups(Generic.Heading, Whitespace)), # Double-slashed magic words (words(double_slashes_i, prefix=r'(?i)'), Name.Function.Magic), (words(double_slashes), Name.Function.Magic), # Raw URLs (r'(?i)\b(?:{}){}{}*'.format('|'.join(protocols), link_address, link_char_class), Name.Label), # Magic links (rf'\b(?:RFC|PMID){nbsp_char}+[0-9]+\b', Name.Function.Magic), (r"""(?x) \bISBN {nbsp_char} (?: 97[89] {nbsp_dash}? )? (?: [0-9] {nbsp_dash}? ){{9}} # escape format() [0-9Xx]\b """.format(nbsp_char=nbsp_char, nbsp_dash=f'(?:-|{nbsp_char})'), Name.Function.Magic), include('list'), include('inline'), include('text'), ], 'redirect-inner': [ (r'(\]\])(\s*?\n)', bygroups(Punctuation, Whitespace), '#pop'), (r'(\#)([^#]*?)', bygroups(Punctuation, Name.Label)), (rf'(?i)[{title_char}]+', Name.Tag), ], 'list': [ # Description lists (r'^;', Keyword, 'dt'), # Ordered lists, unordered lists and indents (r'^[#:*]+', Keyword), # Horizontal rules (r'^-{4,}', Keyword), ], 'inline': [ # Signatures (r'~{3,5}', Keyword), # Entities include('entity'), # Bold & italic (r"('')(''')(?!')", bygroups(Generic.Emph, Generic.EmphStrong), 'inline-italic-bold'), (r"'''(?!')", Generic.Strong, 'inline-bold'), (r"''(?!')", Generic.Emph, 'inline-italic'), # Comments & parameters & templates include('replaceable'), # Media links ( r"""(?xi) (\[\[) (File|Image) (:) ((?: [{}] | \{{{{2,3}}[^{{}}]*?\}}{{2,3}} | <!--[\s\S]*?--> )*) (?: (\#) ([{}]*?) )? """.format(title_char, f'{title_char}#'), bygroups(Punctuation, Name.Namespace, Punctuation, using(this, state=['wikilink-name']), Punctuation, Name.Label), 'medialink-inner' ), # Wikilinks ( r"""(?xi) (\[\[)(?!{}) # Should not contain URLs (?: ([{}]*) (:))? ((?: [{}] | \{{{{2,3}}[^{{}}]*?\}}{{2,3}} | <!--[\s\S]*?--> )*?) (?: (\#) ([{}]*?) )? (\]\]) """.format('|'.join(protocols), title_char.replace('/', ''), title_char, f'{title_char}#'), bygroups(Punctuation, Name.Namespace, Punctuation, using(this, state=['wikilink-name']), Punctuation, Name.Label, Punctuation) ), ( r"""(?xi) (\[\[)(?!{}) (?: ([{}]*) (:))? ((?: [{}] | \{{{{2,3}}[^{{}}]*?\}}{{2,3}} | <!--[\s\S]*?--> )*?) (?: (\#) ([{}]*?) )? (\|) """.format('|'.join(protocols), title_char.replace('/', ''), title_char, f'{title_char}#'), bygroups(Punctuation, Name.Namespace, Punctuation, using(this, state=['wikilink-name']), Punctuation, Name.Label, Punctuation), 'wikilink-inner' ), # External links ( r"""(?xi) (\[) ((?:{}) {} {}*) (\s*) """.format('|'.join(protocols), link_address, link_char_class), bygroups(Punctuation, Name.Label, Whitespace), 'extlink-inner' ), # Tables (r'^(:*)(\s*?)(\{\|)([^\n]*)$', bygroups(Keyword, Whitespace, Punctuation, using(this, state=['root', 'attr'])), 'table'), # HTML tags (r'(?i)(<)({})\b'.format('|'.join(html_tags)), bygroups(Punctuation, Name.Tag), 'tag-inner-ordinary'), (r'(?i)(</)({})\b(\s*)(>)'.format('|'.join(html_tags)), bygroups(Punctuation, Name.Tag, Whitespace, Punctuation)), # <nowiki> (r'(?i)(<)(nowiki)\b', bygroups(Punctuation, Name.Tag), ('tag-nowiki', 'tag-inner')), # <pre> (r'(?i)(<)(pre)\b', bygroups(Punctuation, Name.Tag), ('tag-pre', 'tag-inner')), # <categorytree> (r'(?i)(<)(categorytree)\b', bygroups( Punctuation, Name.Tag), ('tag-categorytree', 'tag-inner')), # <hiero> (r'(?i)(<)(hiero)\b', bygroups(Punctuation, Name.Tag), ('tag-hiero', 'tag-inner')), # <math> (r'(?i)(<)(math)\b', bygroups(Punctuation, Name.Tag), ('tag-math', 'tag-inner')), # <chem> (r'(?i)(<)(chem)\b', bygroups(Punctuation, Name.Tag), ('tag-chem', 'tag-inner')), # <ce> (r'(?i)(<)(ce)\b', bygroups(Punctuation, Name.Tag), ('tag-ce', 'tag-inner')), # <charinsert> (r'(?i)(<)(charinsert)\b', bygroups( Punctuation, Name.Tag), ('tag-charinsert', 'tag-inner')), # <templatedata> (r'(?i)(<)(templatedata)\b', bygroups( Punctuation, Name.Tag), ('tag-templatedata', 'tag-inner')), # <gallery> (r'(?i)(<)(gallery)\b', bygroups( Punctuation, Name.Tag), ('tag-gallery', 'tag-inner')), # <graph> (r'(?i)(<)(gallery)\b', bygroups( Punctuation, Name.Tag), ('tag-graph', 'tag-inner')), # <dynamicpagelist> (r'(?i)(<)(dynamicpagelist)\b', bygroups( Punctuation, Name.Tag), ('tag-dynamicpagelist', 'tag-inner')), # <inputbox> (r'(?i)(<)(inputbox)\b', bygroups( Punctuation, Name.Tag), ('tag-inputbox', 'tag-inner')), # <rss> (r'(?i)(<)(rss)\b', bygroups( Punctuation, Name.Tag), ('tag-rss', 'tag-inner')), # <imagemap> (r'(?i)(<)(imagemap)\b', bygroups( Punctuation, Name.Tag), ('tag-imagemap', 'tag-inner')), # <syntaxhighlight> (r'(?i)(</)(syntaxhighlight)\b(\s*)(>)', bygroups(Punctuation, Name.Tag, Whitespace, Punctuation)), (r'(?si)(<)(syntaxhighlight)\b([^>]*?(?<!/)>.*?)(?=</\2\s*>)', bygroups(Punctuation, Name.Tag, handle_syntaxhighlight)), # <syntaxhighlight>: Fallback case for self-closing tags (r'(?i)(<)(syntaxhighlight)\b(\s*?)((?:[^>]|-->)*?)(/\s*?(?<!--)>)', bygroups( Punctuation, Name.Tag, Whitespace, using(this, state=['root', 'attr']), Punctuation)), # <source> (r'(?i)(</)(source)\b(\s*)(>)', bygroups(Punctuation, Name.Tag, Whitespace, Punctuation)), (r'(?si)(<)(source)\b([^>]*?(?<!/)>.*?)(?=</\2\s*>)', bygroups(Punctuation, Name.Tag, handle_syntaxhighlight)), # <source>: Fallback case for self-closing tags (r'(?i)(<)(source)\b(\s*?)((?:[^>]|-->)*?)(/\s*?(?<!--)>)', bygroups( Punctuation, Name.Tag, Whitespace, using(this, state=['root', 'attr']), Punctuation)), # <score> (r'(?i)(</)(score)\b(\s*)(>)', bygroups(Punctuation, Name.Tag, Whitespace, Punctuation)), (r'(?si)(<)(score)\b([^>]*?(?<!/)>.*?)(?=</\2\s*>)', bygroups(Punctuation, Name.Tag, handle_score)), # <score>: Fallback case for self-closing tags (r'(?i)(<)(score)\b(\s*?)((?:[^>]|-->)*?)(/\s*?(?<!--)>)', bygroups( Punctuation, Name.Tag, Whitespace, using(this, state=['root', 'attr']), Punctuation)), # Other parser tags (r'(?i)(<)({})\b'.format('|'.join(parser_tags)), bygroups(Punctuation, Name.Tag), 'tag-inner-ordinary'), (r'(?i)(</)({})\b(\s*)(>)'.format('|'.join(parser_tags)), bygroups(Punctuation, Name.Tag, Whitespace, Punctuation)), # LanguageConverter markups ( r"""(?xi) (-\{{) # Use {{ to escape format() ([^|]) (\|) (?: (?: ([^;]*?) (=>))? (\s* (?:{variants}) \s*) (:) )? """.format(variants='|'.join(variant_langs)), bygroups(Punctuation, Keyword, Punctuation, using(this, state=['root', 'lc-raw']), Operator, Name.Label, Punctuation), 'lc-inner' ), # LanguageConverter markups: composite conversion grammar ( r"""(?xi) (-\{) ([a-z\s;-]*?) (\|) """, bygroups(Punctuation, using(this, state=['root', 'lc-flag']), Punctuation), 'lc-raw' ), # LanguageConverter markups: fallbacks ( r"""(?xi) (-\{{) (?!\{{) # Use {{ to escape format() (?: (\s* (?:{variants}) \s*) (:))? """.format(variants='|'.join(variant_langs)), bygroups(Punctuation, Name.Label, Punctuation), 'lc-inner' ), ], 'wikilink-name': [ include('replaceable'), (r'[^{<]+', Name.Tag), (r'(?s).', Name.Tag), ], 'wikilink-inner': [ # Quit in case of another wikilink (r'(?=\[\[)', Punctuation, '#pop'), (r'\]\]', Punctuation, '#pop'), include('inline'), include('text'), ], 'medialink-inner': [ (r'\]\]', Punctuation, '#pop'), (r'(\|)([^\n=|]*)(=)', bygroups(Punctuation, Name.Attribute, Operator)), (r'\|', Punctuation), include('inline'), include('text'), ], 'quote-common': [ # Quit in case of link/template endings (r'(?=\]\]|\{\{|\}\})', Punctuation, '#pop'), (r'\n', Text, '#pop'), ], 'inline-italic': [ include('quote-common'), (r"('')(''')(?!')", bygroups(Generic.Emph, Generic.Strong), ('#pop', 'inline-bold')), (r"'''(?!')", Generic.EmphStrong, ('#pop', 'inline-italic-bold')), (r"''(?!')", Generic.Emph, '#pop'), include('inline'), include('text-italic'), ], 'inline-bold': [ include('quote-common'), (r"(''')('')(?!')", bygroups( Generic.Strong, Generic.Emph), ('#pop', 'inline-italic')), (r"'''(?!')", Generic.Strong, '#pop'), (r"''(?!')", Generic.EmphStrong, ('#pop', 'inline-bold-italic')), include('inline'), include('text-bold'), ], 'inline-bold-italic': [ include('quote-common'), (r"('')(''')(?!')", bygroups(Generic.EmphStrong, Generic.Strong), '#pop'), (r"'''(?!')", Generic.EmphStrong, ('#pop', 'inline-italic')), (r"''(?!')", Generic.EmphStrong, ('#pop', 'inline-bold')), include('inline'), include('text-bold-italic'), ], 'inline-italic-bold': [ include('quote-common'), (r"(''')('')(?!')", bygroups( Generic.EmphStrong, Generic.Emph), '#pop'), (r"'''(?!')", Generic.EmphStrong, ('#pop', 'inline-italic')), (r"''(?!')", Generic.EmphStrong, ('#pop', 'inline-bold')), include('inline'), include('text-bold-italic'), ], 'lc-flag': [ (r'\s+', Whitespace), (r';', Punctuation), *text_rules(Keyword), ], 'lc-inner': [ ( r"""(?xi) (;) (?: ([^;]*?) (=>))? (\s* (?:{variants}) \s*) (:) """.format(variants='|'.join(variant_langs)), bygroups(Punctuation, using(this, state=['root', 'lc-raw']), Operator, Name.Label, Punctuation) ), (r';?\s*?\}-', Punctuation, '#pop'), include('inline'), include('text'), ], 'lc-raw': [ (r'\}-', Punctuation, '#pop'), include('inline'), include('text'), ], 'replaceable': [ # Comments (r'<!--[\s\S]*?(?:-->|\Z)', Comment.Multiline), # Parameters ( r"""(?x) (\{{3}) ([^|]*?) (?=\}{3}|\|) """, bygroups(Punctuation, Name.Variable), 'parameter-inner', ), # Magic variables (r'(?i)(\{{\{{)(\s*)({})(\s*)(\}}\}})'.format('|'.join(magic_vars_i)), bygroups(Punctuation, Whitespace, Name.Function, Whitespace, Punctuation)), (r'(\{{\{{)(\s*)({})(\s*)(\}}\}})'.format('|'.join(magic_vars)), bygroups(Punctuation, Whitespace, Name.Function, Whitespace, Punctuation)), # Parser functions & templates (r'\{\{', Punctuation, 'template-begin-space'), # <tvar> legacy syntax (r'(?i)(<)(tvar)\b(\|)([^>]*?)(>)', bygroups(Punctuation, Name.Tag, Punctuation, String, Punctuation)), (r'</>', Punctuation, '#pop'), # <tvar> (r'(?i)(<)(tvar)\b', bygroups(Punctuation, Name.Tag), 'tag-inner-ordinary'), (r'(?i)(</)(tvar)\b(\s*)(>)', bygroups(Punctuation, Name.Tag, Whitespace, Punctuation)), ], 'parameter-inner': [ (r'\}{3}', Punctuation, '#pop'), (r'\|', Punctuation), include('inline'), include('text'), ], 'template-begin-space': [ # Templates allow line breaks at the beginning, and due to how MediaWiki handles # comments, an extra state is required to handle things like {{\n<!---->\n name}} (r'<!--[\s\S]*?(?:-->|\Z)', Comment.Multiline), (r'\s+', Whitespace), # Parser functions ( r'(?i)(\#[{}]*?|{})(:)'.format(title_char, '|'.join(parser_functions_i)), bygroups(Name.Function, Punctuation), ('#pop', 'template-inner') ), ( r'({})(:)'.format('|'.join(parser_functions)), bygroups(Name.Function, Punctuation), ('#pop', 'template-inner') ), # Templates ( rf'(?i)([{title_char}]*?)(:)', bygroups(Name.Namespace, Punctuation), ('#pop', 'template-name') ), default(('#pop', 'template-name'),), ], 'template-name': [ (r'(\s*?)(\|)', bygroups(Text, Punctuation), ('#pop', 'template-inner')), (r'\}\}', Punctuation, '#pop'), (r'\n', Text, '#pop'), include('replaceable'), *text_rules(Name.Tag), ], 'template-inner': [ (r'\}\}', Punctuation, '#pop'), (r'\|', Punctuation), ( r"""(?x) (?<=\|) ( (?: (?! \{\{ | \}\} )[^=\|<])*? ) # Exclude templates and tags (=) """, bygroups(Name.Label, Operator) ), include('inline'), include('text'), ], 'table': [ # Use [ \t\n\r\0\x0B] instead of \s to follow PHP trim() behavior # Endings (r'^([ \t\n\r\0\x0B]*?)(\|\})', bygroups(Whitespace, Punctuation), '#pop'), # Table rows (r'^([ \t\n\r\0\x0B]*?)(\|-+)(.*)$', bygroups(Whitespace, Punctuation, using(this, state=['root', 'attr']))), # Captions ( r"""(?x) ^([ \t\n\r\0\x0B]*?)(\|\+) # Exclude links, template and tags (?: ( (?: (?! \[\[ | \{\{ )[^|\n<] )*? )(\|) )? (.*?)$ """, bygroups(Whitespace, Punctuation, using(this, state=[ 'root', 'attr']), Punctuation, Generic.Heading), ), # Table data ( r"""(?x) ( ^(?:[ \t\n\r\0\x0B]*?)\| | \|\| ) (?: ( (?: (?! \[\[ | \{\{ )[^|\n<] )*? )(\|)(?!\|) )? """, bygroups(Punctuation, using(this, state=[ 'root', 'attr']), Punctuation), ), # Table headers ( r"""(?x) ( ^(?:[ \t\n\r\0\x0B]*?)! ) (?: ( (?: (?! \[\[ | \{\{ )[^|\n<] )*? )(\|)(?!\|) )? """, bygroups(Punctuation, using(this, state=[ 'root', 'attr']), Punctuation), 'table-header', ), include('list'), include('inline'), include('text'), ], 'table-header': [ # Requires another state for || handling inside headers (r'\n', Text, '#pop'), ( r"""(?x) (!!|\|\|) (?: ( (?: (?! \[\[ | \{\{ )[^|\n<] )*? ) (\|)(?!\|) )? """, bygroups(Punctuation, using(this, state=[ 'root', 'attr']), Punctuation) ), *text_rules(Generic.Subheading), ], 'entity': [ (r'&\S*?;', Name.Entity), ], 'dt': [ (r'\n', Text, '#pop'), include('inline'), (r':', Keyword, '#pop'), include('text'), ], 'extlink-inner': [ (r'\]', Punctuation, '#pop'), include('inline'), include('text'), ], 'nowiki-ish': [ include('entity'), include('text'), ], 'attr': [ include('replaceable'), (r'\s+', Whitespace), (r'(=)(\s*)(")', bygroups(Operator, Whitespace, String.Double), 'attr-val-2'), (r"(=)(\s*)(')", bygroups(Operator, Whitespace, String.Single), 'attr-val-1'), (r'(=)(\s*)', bygroups(Operator, Whitespace), 'attr-val-0'), (r'[\w:-]+', Name.Attribute),
], 'attr-val-0': [ (r'\s', Whitespace, '#pop'), include('replaceable'), *text_rules(String), ], 'attr-val-1': [ (r"'", String.Single, '#pop'), include('replaceable'), *text_rules(String.Single), ], 'attr-val-2': [ (r'"', String.Double, '#pop'), include('replaceable'), *text_rules(String.Double), ], 'tag-inner-ordinary': [ (r'/?\s*>', Punctuation, '#pop'), include('tag-attr'), ], 'tag-inner': [ # Return to root state for self-closing tags (r'/\s*>', Punctuation, '#pop:2'), (r'\s*>', Punctuation, '#pop'), include('tag-attr'), ], # There states below are just like their non-tag variants, the key difference is # they forcibly quit when encountering tag closing markup 'tag-attr': [ include('replaceable'), (r'\s+', Whitespace), (r'(=)(\s*)(")', bygroups(Operator, Whitespace, String.Double), 'tag-attr-val-2'), (r"(=)(\s*)(')", bygroups(Operator, Whitespace, String.Single), 'tag-attr-val-1'), (r'(=)(\s*)', bygroups(Operator, Whitespace), 'tag-attr-val-0'), (r'[\w:-]+', Name.Attribute),
], 'tag-attr-val-0': [ (r'\s', Whitespace, '#pop'), (r'/?>', Punctuation, '#pop:2'), include('replaceable'), *text_rules(String), ], 'tag-attr-val-1': [ (r"'", String.Single, '#pop'), (r'/?>', Punctuation, '#pop:2'), include('replaceable'), *text_rules(String.Single), ], 'tag-attr-val-2': [ (r'"', String.Double, '#pop'), (r'/?>', Punctuation, '#pop:2'), include('replaceable'), *text_rules(String.Double), ], 'tag-nowiki': nowiki_tag_rules('nowiki'), 'tag-pre': nowiki_tag_rules('pre'), 'tag-categorytree': plaintext_tag_rules('categorytree'), 'tag-dynamicpagelist': plaintext_tag_rules('dynamicpagelist'), 'tag-hiero': plaintext_tag_rules('hiero'), 'tag-inputbox': plaintext_tag_rules('inputbox'), 'tag-imagemap': plaintext_tag_rules('imagemap'), 'tag-charinsert': plaintext_tag_rules('charinsert'), 'tag-timeline': plaintext_tag_rules('timeline'), 'tag-gallery': plaintext_tag_rules('gallery'), 'tag-graph': plaintext_tag_rules('graph'), 'tag-rss': plaintext_tag_rules('rss'), 'tag-math': delegate_tag_rules('math', TexLexer, state='math'), 'tag-chem': delegate_tag_rules('chem', TexLexer, state='math'), 'tag-ce': delegate_tag_rules('ce', TexLexer, state='math'), 'tag-templatedata': delegate_tag_rules('templatedata', JsonLexer), 'text-italic': text_rules(Generic.Emph), 'text-bold': text_rules(Generic.Strong), 'text-bold-italic': text_rules(Generic.EmphStrong), 'text': text_rules(Text), }123456789101112131415161718192021""" pygments.lexers.math ~~~~~~~~~~~~~~~~~~~~
Just export lexers that were contained in this module.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
# ruff: noqa: F401from pygments.lexers.python import NumPyLexerfrom pygments.lexers.matlab import MatlabLexer, MatlabSessionLexer, \ OctaveLexer, ScilabLexerfrom pygments.lexers.julia import JuliaLexer, JuliaConsoleLexerfrom pygments.lexers.r import RConsoleLexer, SLexer, RdLexerfrom pygments.lexers.modeling import BugsLexer, JagsLexer, StanLexerfrom pygments.lexers.idl import IDLLexerfrom pygments.lexers.algebra import MuPADLexer
__all__ = []123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384""" pygments.lexers.maxima ~~~~~~~~~~~~~~~~~~~~~~
Lexer for the computer algebra system Maxima.
Derived from pygments/lexers/algebra.py.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, bygroups, wordsfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation
__all__ = ['MaximaLexer']
class MaximaLexer(RegexLexer): """ A Maxima lexer. Derived from pygments.lexers.MuPADLexer. """ name = 'Maxima' url = 'http://maxima.sourceforge.net' aliases = ['maxima', 'macsyma'] filenames = ['*.mac', '*.max'] version_added = '2.11'
keywords = ('if', 'then', 'else', 'elseif', 'do', 'while', 'repeat', 'until', 'for', 'from', 'to', 'downto', 'step', 'thru')
constants = ('%pi', '%e', '%phi', '%gamma', '%i', 'und', 'ind', 'infinity', 'inf', 'minf', 'true', 'false', 'unknown', 'done')
operators = (r'.', r':', r'=', r'#', r'+', r'-', r'*', r'/', r'^', r'@', r'>', r'<', r'|', r'!', r"'")
operator_words = ('and', 'or', 'not')
tokens = { 'root': [ (r'/\*', Comment.Multiline, 'comment'), (r'"(?:[^"\\]|\\.)*"', String), (r'\(|\)|\[|\]|\{|\}', Punctuation), (r'[,;$]', Punctuation), (words (constants), Name.Constant), (words (keywords), Keyword), (words (operators), Operator), (words (operator_words), Operator.Word), (r'''(?x) ((?:[a-zA-Z_#][\w#]*|`[^`]*`) (?:::[a-zA-Z_#][\w#]*|`[^`]*`)*)(\s*)([(])''', bygroups(Name.Function, Text.Whitespace, Punctuation)), (r'''(?x) (?:[a-zA-Z_#%][\w#%]*|`[^`]*`) (?:::[a-zA-Z_#%][\w#%]*|`[^`]*`)*''', Name.Variable), (r'[-+]?(\d*\.\d+([bdefls][-+]?\d+)?|\d+(\.\d*)?[bdefls][-+]?\d+)', Number.Float), (r'[-+]?\d+', Number.Integer), (r'\s+', Text.Whitespace), (r'.', Text) ], 'comment': [ (r'[^*/]+', Comment.Multiline), (r'/\*', Comment.Multiline, '#push'), (r'\*/', Comment.Multiline, '#pop'), (r'[*/]', Comment.Multiline) ] }
def analyse_text (text): strength = 0.0 # Input expression terminator. if re.search (r'\$\s*$', text, re.MULTILINE): strength += 0.05 # Function definition operator. if ':=' in text: strength += 0.02 return strength123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139""" pygments.lexers.meson ~~~~~~~~~~~~~~~~~~~~~
Pygments lexer for the Meson build system
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, words, includefrom pygments.token import Comment, Name, Number, Punctuation, Operator, \ Keyword, String, Whitespace
__all__ = ['MesonLexer']
class MesonLexer(RegexLexer): """Meson language lexer.
The grammar definition use to transcribe the syntax was retrieved from https://mesonbuild.com/Syntax.html#grammar for version 0.58. Some of those definitions are improperly transcribed, so the Meson++ implementation was also checked: https://github.com/dcbaker/meson-plus-plus. """
# TODO String interpolation @VARNAME@ inner matches # TODO keyword_arg: value inner matches
name = 'Meson' url = 'https://mesonbuild.com/' aliases = ['meson', 'meson.build'] filenames = ['meson.build', 'meson.options', 'meson_options.txt'] mimetypes = ['text/x-meson'] version_added = '2.10'
tokens = { 'root': [ (r'#.*?$', Comment), (r"'''.*'''", String.Single), (r'[1-9][0-9]*', Number.Integer), (r'0o[0-7]+', Number.Oct), (r'0x[a-fA-F0-9]+', Number.Hex), include('string'), include('keywords'), include('expr'), (r'[a-zA-Z_][a-zA-Z_0-9]*', Name), (r'\s+', Whitespace), ], 'string': [ (r"[']{3}([']{0,2}([^\\']|\\(.|\n)))*[']{3}", String), (r"'.*?(?<!\\)(\\\\)*?'", String), ], 'keywords': [ (words(( 'if', 'elif', 'else', 'endif', 'foreach', 'endforeach', 'break', 'continue', ), suffix=r'\b'), Keyword), ], 'expr': [ (r'(in|and|or|not)\b', Operator.Word), (r'([\*/%\+-]=?|==|!=|=)', Operator), (r'[\[\]{}:().,?]', Punctuation), (words(('true', 'false'), suffix=r'\b'), Keyword.Constant), include('builtins'), (words(( 'meson', 'build_machine', 'host_machine', 'target_machine', ), suffix=r'\b'), Name.Variable.Magic), ], 'builtins': [ # This list was extracted from the v0.58 reference manual (words(( 'add_global_arguments', 'add_global_link_arguments', 'add_languages', 'add_project_arguments', 'add_project_link_arguments', 'add_test_setup', 'assert', 'benchmark', 'both_libraries', 'build_target', 'configuration_data', 'configure_file', 'custom_target', 'declare_dependency', 'dependency', 'disabler', 'environment', 'error', 'executable', 'files', 'find_library', 'find_program', 'generator', 'get_option', 'get_variable', 'include_directories', 'install_data', 'install_headers', 'install_man', 'install_subdir', 'is_disabler', 'is_variable', 'jar', 'join_paths', 'library', 'message', 'project', 'range', 'run_command', 'set_variable', 'shared_library', 'shared_module', 'static_library', 'subdir', 'subdir_done', 'subproject', 'summary', 'test', 'vcs_tag', 'warning', ), prefix=r'(?<!\.)', suffix=r'\b'), Name.Builtin), (r'(?<!\.)import\b', Name.Namespace), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210""" pygments.lexers.mime ~~~~~~~~~~~~~~~~~~~~
Lexer for Multipurpose Internet Mail Extensions (MIME) data.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, includefrom pygments.lexers import get_lexer_for_mimetypefrom pygments.token import Text, Name, String, Operator, Comment, Otherfrom pygments.util import get_int_opt, ClassNotFound
__all__ = ["MIMELexer"]
class MIMELexer(RegexLexer): """ Lexer for Multipurpose Internet Mail Extensions (MIME) data. This lexer is designed to process nested multipart data.
It assumes that the given data contains both header and body (and is split at an empty line). If no valid header is found, then the entire data will be treated as body.
Additional options accepted:
`MIME-max-level` Max recursion level for nested MIME structure. Any negative number would treated as unlimited. (default: -1)
`Content-Type` Treat the data as a specific content type. Useful when header is missing, or this lexer would try to parse from header. (default: `text/plain`)
`Multipart-Boundary` Set the default multipart boundary delimiter. This option is only used when `Content-Type` is `multipart` and header is missing. This lexer would try to parse from header by default. (default: None)
`Content-Transfer-Encoding` Treat the data as a specific encoding. Or this lexer would try to parse from header by default. (default: None) """
name = "MIME" aliases = ["mime"] mimetypes = ["multipart/mixed", "multipart/related", "multipart/alternative"] url = 'https://en.wikipedia.org/wiki/MIME' version_added = '2.5'
def __init__(self, **options): super().__init__(**options) self.boundary = options.get("Multipart-Boundary") self.content_transfer_encoding = options.get("Content_Transfer_Encoding") self.content_type = options.get("Content_Type", "text/plain") self.max_nested_level = get_int_opt(options, "MIME-max-level", -1)
def get_header_tokens(self, match): field = match.group(1)
if field.lower() in self.attention_headers: yield match.start(1), Name.Tag, field + ":" yield match.start(2), Text.Whitespace, match.group(2)
pos = match.end(2) body = match.group(3) for i, t, v in self.get_tokens_unprocessed(body, ("root", field.lower())): yield pos + i, t, v
else: yield match.start(), Comment, match.group()
def get_body_tokens(self, match): pos_body_start = match.start() entire_body = match.group()
# skip first newline if entire_body[0] == '\n': yield pos_body_start, Text.Whitespace, '\n' pos_body_start = pos_body_start + 1 entire_body = entire_body[1:]
# if it is not a multipart if not self.content_type.startswith("multipart") or not self.boundary: for i, t, v in self.get_bodypart_tokens(entire_body): yield pos_body_start + i, t, v return
# find boundary bdry_pattern = rf"^--{re.escape(self.boundary)}(--)?\n" bdry_matcher = re.compile(bdry_pattern, re.MULTILINE)
# some data has prefix text before first boundary m = bdry_matcher.search(entire_body) if m: pos_part_start = pos_body_start + m.end() pos_iter_start = lpos_end = m.end() yield pos_body_start, Text, entire_body[:m.start()] yield pos_body_start + lpos_end, String.Delimiter, m.group() else: pos_part_start = pos_body_start pos_iter_start = 0
# process tokens of each body part for m in bdry_matcher.finditer(entire_body, pos_iter_start): # bodypart lpos_start = pos_part_start - pos_body_start lpos_end = m.start() part = entire_body[lpos_start:lpos_end] for i, t, v in self.get_bodypart_tokens(part): yield pos_part_start + i, t, v
# boundary yield pos_body_start + lpos_end, String.Delimiter, m.group() pos_part_start = pos_body_start + m.end()
# some data has suffix text after last boundary lpos_start = pos_part_start - pos_body_start if lpos_start != len(entire_body): yield pos_part_start, Text, entire_body[lpos_start:]
def get_bodypart_tokens(self, text): # return if: # * no content # * no content type specific # * content encoding is not readable # * max recurrsion exceed if not text.strip() or not self.content_type: return [(0, Other, text)]
cte = self.content_transfer_encoding if cte and cte not in {"8bit", "7bit", "quoted-printable"}: return [(0, Other, text)]
if self.max_nested_level == 0: return [(0, Other, text)]
# get lexer try: lexer = get_lexer_for_mimetype(self.content_type) except ClassNotFound: return [(0, Other, text)]
if isinstance(lexer, type(self)): lexer.max_nested_level = self.max_nested_level - 1
return lexer.get_tokens_unprocessed(text)
def store_content_type(self, match): self.content_type = match.group(1)
prefix_len = match.start(1) - match.start(0) yield match.start(0), Text.Whitespace, match.group(0)[:prefix_len] yield match.start(1), Name.Label, match.group(2) yield match.end(2), String.Delimiter, '/' yield match.start(3), Name.Label, match.group(3)
def get_content_type_subtokens(self, match): yield match.start(1), Text, match.group(1) yield match.start(2), Text.Whitespace, match.group(2) yield match.start(3), Name.Attribute, match.group(3) yield match.start(4), Operator, match.group(4) yield match.start(5), String, match.group(5)
if match.group(3).lower() == "boundary": boundary = match.group(5).strip() if boundary[0] == '"' and boundary[-1] == '"': boundary = boundary[1:-1] self.boundary = boundary
def store_content_transfer_encoding(self, match): self.content_transfer_encoding = match.group(0).lower() yield match.start(0), Name.Constant, match.group(0)
attention_headers = {"content-type", "content-transfer-encoding"}
tokens = { "root": [ (r"^([\w-]+):( *)([\s\S]*?\n)(?![ \t])", get_header_tokens), (r"^$[\s\S]+", get_body_tokens), ], "header": [ # folding (r"\n[ \t]", Text.Whitespace), (r"\n(?![ \t])", Text.Whitespace, "#pop"), ], "content-type": [ include("header"), ( r"^\s*((multipart|application|audio|font|image|model|text|video" r"|message)/([\w-]+))", store_content_type, ), (r'(;)((?:[ \t]|\n[ \t])*)([\w:-]+)(=)([\s\S]*?)(?=;|\n(?![ \t]))', get_content_type_subtokens), (r';[ \t]*\n(?![ \t])', Text, '#pop'), ], "content-transfer-encoding": [ include("header"), (r"([\w-]+)", store_content_transfer_encoding), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392""" pygments.lexers.minecraft ~~~~~~~~~~~~~~~~~~~~~~~~~
Lexers for Minecraft related languages.
SNBT. A data communication format used in Minecraft. wiki: https://minecraft.wiki/w/NBT_format
MCFunction. The Function file for Minecraft Data packs and Add-ons. official: https://learn.microsoft.com/en-us/minecraft/creator/documents/functionsintroduction wiki: https://minecraft.wiki/w/Function
MCSchema. A kind of data Schema for Minecraft Add-on Development. official: https://learn.microsoft.com/en-us/minecraft/creator/reference/content/schemasreference/ community example: https://www.mcbe-dev.net/addons/data-driven/manifest.html
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, default, include, bygroupsfrom pygments.token import Comment, Keyword, Literal, Name, Number, Operator, \ Punctuation, String, Text, Whitespace
__all__ = ['SNBTLexer', 'MCFunctionLexer', 'MCSchemaLexer']
class SNBTLexer(RegexLexer): """Lexer for stringified NBT, a data format used in Minecraft """
name = "SNBT" url = "https://minecraft.wiki/w/NBT_format" aliases = ["snbt"] filenames = ["*.snbt"] mimetypes = ["text/snbt"] version_added = '2.12'
tokens = { "root": [ # We only look for the open bracket here since square bracket # is only valid in NBT pathing (which is a mcfunction idea). (r"\{", Punctuation, "compound"), (r"[^\{]+", Text), ],
"whitespace": [ (r"\s+", Whitespace), ],
"operators": [ (r"[,:;]", Punctuation), ],
"literals": [ (r"(true|false)", Keyword.Constant), (r"-?\d+[eE]-?\d+", Number.Float), (r"-?\d*\.\d+[fFdD]?", Number.Float), (r"-?\d+[bBsSlLfFdD]?", Number.Integer),
# Separate states for both types of strings so they don't entangle (r'"', String.Double, "literals.string_double"), (r"'", String.Single, "literals.string_single"), ], "literals.string_double": [ (r"\\.", String.Escape), (r'[^\\"\n]+', String.Double), (r'"', String.Double, "#pop"), ], "literals.string_single": [ (r"\\.", String.Escape), (r"[^\\'\n]+", String.Single), (r"'", String.Single, "#pop"), ],
"compound": [ # this handles the unquoted snbt keys # note: stringified keys still work (r"[A-Z_a-z]+", Name.Attribute), include("operators"), include("whitespace"), include("literals"), (r"\{", Punctuation, "#push"), (r"\[", Punctuation, "list"), (r"\}", Punctuation, "#pop"), ],
"list": [ (r"[A-Z_a-z]+", Name.Attribute), include("literals"), include("operators"), include("whitespace"), (r"\[", Punctuation, "#push"), (r"\{", Punctuation, "compound"), (r"\]", Punctuation, "#pop"), ], }
class MCFunctionLexer(RegexLexer): """Lexer for the mcfunction scripting language used in Minecraft.
Modelled somewhat after the `GitHub mcfunction grammar <https://github.com/Arcensoth/language-mcfunction>`_. """
name = "MCFunction" url = "https://minecraft.wiki/w/Commands" aliases = ["mcfunction", "mcf"] filenames = ["*.mcfunction"] mimetypes = ["text/mcfunction"] version_added = '2.12'
# Used to denotate the start of a block comment, borrowed from Github's mcfunction _block_comment_prefix = "[>!]"
tokens = { "root": [ include("names"), include("comments"), include("literals"), include("whitespace"), include("property"), include("operators"), include("selectors"), ],
"names": [ # The start of a command (either beginning of line OR after the run keyword) # We don't encode a list of keywords since mods, plugins, or even pre-processors # may add new commands, so we have a 'close-enough' regex which catches them. (r"^(\s*)([a-z_]+)", bygroups(Whitespace, Name.Builtin)), (r"(?<=run)\s+[a-z_]+", Name.Builtin),
# UUID (r"\b[0-9a-fA-F]+(?:-[0-9a-fA-F]+){4}\b", Name.Variable), include("resource-name"), # normal command names and scoreboards # there's no way to know the differences unfortuntely (r"[A-Za-z_][\w.#%$]+", Keyword.Constant), (r"[#%$][\w.#%$]+", Name.Variable.Magic), ],
"resource-name": [ # resource names have to be lowercase (r"#?[a-z_][a-z_.-]*:[a-z0-9_./-]+", Name.Function), # similar to above except optional `:`` # a `/` must be present "somewhere" (r"#?[a-z0-9_\.\-]+\/[a-z0-9_\.\-\/]+", Name.Function), ],
"whitespace": [ (r"\s+", Whitespace), ],
"comments": [ (rf"^\s*(#{_block_comment_prefix})", Comment.Multiline, ("comments.block", "comments.block.emphasized")), (r"#.*$", Comment.Single), ], "comments.block": [ (rf"^\s*#{_block_comment_prefix}", Comment.Multiline, "comments.block.emphasized"), (r"^\s*#", Comment.Multiline, "comments.block.normal"), default("#pop"), ], "comments.block.normal": [ include("comments.block.special"), (r"\S+", Comment.Multiline), (r"\n", Text, "#pop"), include("whitespace"), ], "comments.block.emphasized": [ include("comments.block.special"), (r"\S+", String.Doc), (r"\n", Text, "#pop"), include("whitespace"), ], "comments.block.special": [ # Params (r"@\S+", Name.Decorator),
include("resource-name"),
# Scoreboard player names (r"[#%$][\w.#%$]+", Name.Variable.Magic), ],
"operators": [ (r"[\-~%^?!+*<>\\/|&=.]", Operator), ],
"literals": [ (r"\.\.", Literal), (r"(true|false)", Keyword.Pseudo),
# these are like unquoted strings and appear in many places (r"[A-Za-z_]+", Name.Variable.Class),
(r"[0-7]b", Number.Byte), (r"[+-]?\d*\.?\d+([eE]?[+-]?\d+)?[df]?\b", Number.Float), (r"[+-]?\d+\b", Number.Integer), (r'"', String.Double, "literals.string-double"), (r"'", String.Single, "literals.string-single"), ], "literals.string-double": [ (r"\\.", String.Escape), (r'[^\\"\n]+', String.Double), (r'"', String.Double, "#pop"), ], "literals.string-single": [ (r"\\.", String.Escape), (r"[^\\'\n]+", String.Single), (r"'", String.Single, "#pop"), ],
"selectors": [ (r"@[a-z]", Name.Variable), ],
## Generic Property Container # There are several, differing instances where the language accepts # specific contained keys or contained key, value pairings. # # Property Maps: # - Starts with either `[` or `{` # - Key separated by `:` or `=` # - Deliminated by `,` # # Property Lists: # - Starts with `[` # - Deliminated by `,` # # For simplicity, these patterns match a generic, nestable structure # which follow a key, value pattern. For normal lists, there's only keys. # This allow some "illegal" structures, but we'll accept those for # sake of simplicity # # Examples: # - `[facing=up, powered=true]` (blockstate) # - `[name="hello world", nbt={key: 1b}]` (selector + nbt) # - `[{"text": "value"}, "literal"]` (json) ## "property": [ # This state gets included in root and also several substates # We do this to shortcut the starting of new properties # within other properties. Lists can have sublists and compounds # and values can start a new property (see the `difficult_1.txt` # snippet). (r"\{", Punctuation, ("property.curly", "property.key")), (r"\[", Punctuation, ("property.square", "property.key")), ], "property.curly": [ include("whitespace"), include("property"), (r"\}", Punctuation, "#pop"), ], "property.square": [ include("whitespace"), include("property"), (r"\]", Punctuation, "#pop"),
# lists can have sequences of items (r",", Punctuation), ], "property.key": [ include("whitespace"),
# resource names (for advancements) # can omit `:` to default `minecraft:` # must check if there is a future equals sign if `:` is in the name (r"#?[a-z_][a-z_\.\-]*\:[a-z0-9_\.\-/]+(?=\s*\=)", Name.Attribute, "property.delimiter"), (r"#?[a-z_][a-z0-9_\.\-/]+", Name.Attribute, "property.delimiter"),
# unquoted NBT key (r"[A-Za-z_\-\+]+", Name.Attribute, "property.delimiter"),
# quoted JSON or NBT key (r'"', Name.Attribute, "property.delimiter", "literals.string-double"), (r"'", Name.Attribute, "property.delimiter", "literals.string-single"),
# index for a list (r"-?\d+", Number.Integer, "property.delimiter"),
default("#pop"), ], "property.key.string-double": [ (r"\\.", String.Escape), (r'[^\\"\n]+', Name.Attribute), (r'"', Name.Attribute, "#pop"), ], "property.key.string-single": [ (r"\\.", String.Escape), (r"[^\\'\n]+", Name.Attribute), (r"'", Name.Attribute, "#pop"), ], "property.delimiter": [ include("whitespace"),
(r"[:=]!?", Punctuation, "property.value"), (r",", Punctuation),
default("#pop"), ], "property.value": [ include("whitespace"),
# unquoted resource names are valid literals here (r"#?[a-z_][a-z_\.\-]*\:[a-z0-9_\.\-/]+", Name.Tag), (r"#?[a-z_][a-z0-9_\.\-/]+", Name.Tag),
include("literals"), include("property"),
default("#pop"), ], }
class MCSchemaLexer(RegexLexer): """Lexer for Minecraft Add-ons data Schemas, an interface structure standard used in Minecraft """
name = 'MCSchema' url = 'https://learn.microsoft.com/en-us/minecraft/creator/reference/content/schemasreference/' aliases = ['mcschema'] filenames = ['*.mcschema'] mimetypes = ['text/mcschema'] version_added = '2.14'
tokens = { 'commentsandwhitespace': [ (r'\s+', Whitespace), (r'//.*?$', Comment.Single), (r'/\*.*?\*/', Comment.Multiline) ], 'slashstartsregex': [ include('commentsandwhitespace'), (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/' r'([gimuysd]+\b|\B)', String.Regex, '#pop'), (r'(?=/)', Text, ('#pop', 'badregex')), default('#pop') ], 'badregex': [ (r'\n', Whitespace, '#pop') ], 'singlestring': [ (r'\\.', String.Escape), (r"'", String.Single, '#pop'), (r"[^\\']+", String.Single), ], 'doublestring': [ (r'\\.', String.Escape), (r'"', String.Double, '#pop'), (r'[^\\"]+', String.Double), ], 'root': [ (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'), include('commentsandwhitespace'),
# keywords for optional word and field types (r'(?<=: )opt', Operator.Word), (r'(?<=\s)[\w-]*(?=(\s+"|\n))', Keyword.Declaration),
# numeric literals (r'0[bB][01]+', Number.Bin), (r'0[oO]?[0-7]+', Number.Oct), (r'0[xX][0-9a-fA-F]+', Number.Hex), (r'\d+', Number.Integer), (r'(\.\d+|\d+\.\d*|\d+)([eE][-+]?\d+)?', Number.Float),
# possible punctuations (r'\.\.\.|=>', Punctuation), (r'\+\+|--|~|\?\?=?|\?|:|\\(?=\n)|' r'(<<|>>>?|==?|!=?|(?:\*\*|\|\||&&|[-<>+*%&|^/]))=?', Operator, 'slashstartsregex'), (r'[{(\[;,]', Punctuation, 'slashstartsregex'), (r'[})\].]', Punctuation),
# strings (r"'", String.Single, 'singlestring'), (r'"', String.Double, 'doublestring'),
# title line (r'[\w-]*?(?=:\{?\n)', String.Symbol), # title line with a version code, formatted # `major.minor.patch-prerelease+buildmeta` (r'([\w-]*?)(:)(\d+)(?:(\.)(\d+)(?:(\.)(\d+)(?:(\-)((?:[^\W_]|-)*(?:\.(?:[^\W_]|-)*)*))?(?:(\+)((?:[^\W_]|-)+(?:\.(?:[^\W_]|-)+)*))?)?)?(?=:\{?\n)', bygroups(String.Symbol, Operator, Number.Integer, Operator, Number.Integer, Operator, Number.Integer, Operator, String, Operator, String)),
(r'.*\n', Text), ] }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130""" pygments.lexers.mips ~~~~~~~~~~~~~~~~~~~~
Lexers for MIPS assembly.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, wordsfrom pygments.token import Whitespace, Comment, String, Keyword, Name, Text
__all__ = ["MIPSLexer"]
class MIPSLexer(RegexLexer): """ A MIPS Assembly Lexer.
Based on the Emacs major mode by hlissner: https://github.com/hlissner/emacs-mips-mode """
name = 'MIPS' aliases = ['mips'] version_added = '' # TODO: add '*.s' and '*.asm', which will require designing an analyse_text # method for this lexer and refactoring those from Gas and Nasm in order to # have relatively reliable detection filenames = ['*.mips', '*.MIPS'] url = 'https://mips.com'
keywords = [ # Arithmetic insturctions "add", "sub", "subu", "addi", "subi", "addu", "addiu", # Multiplication/division "mul", "mult", "multu", "mulu", "madd", "maddu", "msub", "msubu", "div", "divu", # Bitwise operations "and", "or", "nor", "xor", "andi", "ori", "xori", "clo", "clz", # Shifts "sll", "srl", "sllv", "srlv", "sra", "srav", # Comparisons "slt", "sltu", "slti", "sltiu", # Move data "mfhi", "mthi", "mflo", "mtlo", "movn", "movz", "movf", "movt", # Jump "j", "jal", "jalr", "jr", # branch "bc1f", "bc1t", "beq", "bgez", "bgezal", "bgtz", "blez", "bltzal", "bltz", "bne", # Load "lui", "lb", "lbu", "lh", "lhu", "lw", "lwcl", "lwl", "lwr", # Store "sb", "sh", "sw", "swl", "swr", # coproc: swc1 sdc1 # Concurrent load/store "ll", "sc", # Trap handling "teq", "teqi", "tne", "tneqi", "tge", "tgeu", "tgei", "tgeiu", "tlt", "tltu", "tlti", "tltiu", # Exception / Interrupt "eret", "break", "bop", "syscall", # --- Floats ----------------------------------------------------- # Arithmetic "add.s", "add.d", "sub.s", "sub.d", "mul.s", "mul.d", "div.s", "div.d", "neg.d", "neg.s", # Comparison "c.e.d", "c.e.s", "c.le.d", "c.le.s", "c.lt.s", "c.lt.d", # "c.gt.s", "c.gt.d", "madd.s", "madd.d", "msub.s", "msub.d", # Move Floats "mov.d", "move.s", "movf.d", "movf.s", "movt.d", "movt.s", "movn.d", "movn.s", "movnzd", "movz.s", "movz.d", # Conversion "cvt.d.s", "cvt.d.w", "cvt.s.d", "cvt.s.w", "cvt.w.d", "cvt.w.s", "trunc.w.d", "trunc.w.s", # Math "abs.s", "abs.d", "sqrt.s", "sqrt.d", "ceil.w.d", "ceil.w.s", "floor.w.d", "floor.w.s", "round.w.d", "round.w.s", ]
pseudoinstructions = [ # Arithmetic & logical "rem", "remu", "mulo", "mulou", "abs", "neg", "negu", "not", "rol", "ror", # branches "b", "beqz", "bge", "bgeu", "bgt", "bgtu", "ble", "bleu", "blt", "bltu", "bnez", # loads "la", "li", "ld", "ulh", "ulhu", "ulw", # Store "sd", "ush", "usw", # move "move", # coproc: "mfc1.d", # comparisons "sgt", "sgtu", "sge", "sgeu", "sle", "sleu", "sne", "seq", # --- Floats ----------------------------------------------------- # load-store "l.d", "l.s", "s.d", "s.s", ]
directives = [ ".align", ".ascii", ".asciiz", ".byte", ".data", ".double", ".extern", ".float", ".globl", ".half", ".kdata", ".ktext", ".space", ".text", ".word", ]
deprecated = [ "beql", "bnel", "bgtzl", "bgezl", "bltzl", "blezl", "bltzall", "bgezall", ]
tokens = { 'root': [ (r'\s+', Whitespace), (r'#.*', Comment), (r'"', String, 'string'), (r'-?[0-9]+?', Keyword.Constant), (r'\w*:', Name.Function), (words(deprecated, suffix=r'\b'), Keyword.Pseudo), # need warning face (words(pseudoinstructions, suffix=r'\b'), Name.Variable), (words(keywords, suffix=r'\b'), Keyword), (r'[slm][ftwd]c[0-9]([.]d)?', Keyword), (r'\$(f?[0-2][0-9]|f?3[01]|[ft]?[0-9]|[vk][01]|a[0-3]|s[0-7]|[gsf]p|ra|at|zero)', Keyword.Type), (words(directives, suffix=r'\b'), Name.Entity), # Preprocessor? (r':|,|;|\{|\}|=>|@|\$|=', Name.Builtin), (r'\w+', Text), (r'.', Text), ], 'string': [ (r'\\.', String.Escape), (r'"', String, '#pop'), (r'[^\\"]+', String), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958""" pygments.lexers.ml ~~~~~~~~~~~~~~~~~~
Lexers for ML family languages.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, include, bygroups, default, wordsfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Error
__all__ = ['SMLLexer', 'OcamlLexer', 'OpaLexer', 'ReasonLexer', 'FStarLexer']
class SMLLexer(RegexLexer): """ For the Standard ML language. """
name = 'Standard ML' aliases = ['sml'] filenames = ['*.sml', '*.sig', '*.fun'] mimetypes = ['text/x-standardml', 'application/x-standardml'] url = 'https://en.wikipedia.org/wiki/Standard_ML' version_added = '1.5'
alphanumid_reserved = { # Core 'abstype', 'and', 'andalso', 'as', 'case', 'datatype', 'do', 'else', 'end', 'exception', 'fn', 'fun', 'handle', 'if', 'in', 'infix', 'infixr', 'let', 'local', 'nonfix', 'of', 'op', 'open', 'orelse', 'raise', 'rec', 'then', 'type', 'val', 'with', 'withtype', 'while', # Modules 'eqtype', 'functor', 'include', 'sharing', 'sig', 'signature', 'struct', 'structure', 'where', }
symbolicid_reserved = { # Core ':', r'\|', '=', '=>', '->', '#', # Modules ':>', }
nonid_reserved = {'(', ')', '[', ']', '{', '}', ',', ';', '...', '_'}
alphanumid_re = r"[a-zA-Z][\w']*" symbolicid_re = r"[!%&$#+\-/:<=>?@\\~`^|*]+"
# A character constant is a sequence of the form #s, where s is a string # constant denoting a string of size one character. This setup just parses # the entire string as either a String.Double or a String.Char (depending # on the argument), even if the String.Char is an erroneous # multiple-character string. def stringy(whatkind): return [ (r'[^"\\]', whatkind), (r'\\[\\"abtnvfr]', String.Escape), # Control-character notation is used for codes < 32, # where \^@ == \000 (r'\\\^[\x40-\x5e]', String.Escape), # Docs say 'decimal digits' (r'\\[0-9]{3}', String.Escape), (r'\\u[0-9a-fA-F]{4}', String.Escape), (r'\\\s+\\', String.Interpol), (r'"', whatkind, '#pop'), ]
# Callbacks for distinguishing tokens and reserved words def long_id_callback(self, match): if match.group(1) in self.alphanumid_reserved: token = Error else: token = Name.Namespace yield match.start(1), token, match.group(1) yield match.start(2), Punctuation, match.group(2)
def end_id_callback(self, match): if match.group(1) in self.alphanumid_reserved: token = Error elif match.group(1) in self.symbolicid_reserved: token = Error else: token = Name yield match.start(1), token, match.group(1)
def id_callback(self, match): str = match.group(1) if str in self.alphanumid_reserved: token = Keyword.Reserved elif str in self.symbolicid_reserved: token = Punctuation else: token = Name yield match.start(1), token, str
tokens = { # Whitespace and comments are (almost) everywhere 'whitespace': [ (r'\s+', Text), (r'\(\*', Comment.Multiline, 'comment'), ],
'delimiters': [ # This lexer treats these delimiters specially: # Delimiters define scopes, and the scope is how the meaning of # the `|' is resolved - is it a case/handle expression, or function # definition by cases? (This is not how the Definition works, but # it's how MLton behaves, see http://mlton.org/SMLNJDeviations) (r'\(|\[|\{', Punctuation, 'main'), (r'\)|\]|\}', Punctuation, '#pop'), (r'\b(let|if|local)\b(?!\')', Keyword.Reserved, ('main', 'main')), (r'\b(struct|sig|while)\b(?!\')', Keyword.Reserved, 'main'), (r'\b(do|else|end|in|then)\b(?!\')', Keyword.Reserved, '#pop'), ],
'core': [ # Punctuation that doesn't overlap symbolic identifiers (r'({})'.format('|'.join(re.escape(z) for z in nonid_reserved)), Punctuation),
# Special constants: strings, floats, numbers in decimal and hex (r'#"', String.Char, 'char'), (r'"', String.Double, 'string'), (r'~?0x[0-9a-fA-F]+', Number.Hex), (r'0wx[0-9a-fA-F]+', Number.Hex), (r'0w\d+', Number.Integer), (r'~?\d+\.\d+[eE]~?\d+', Number.Float), (r'~?\d+\.\d+', Number.Float), (r'~?\d+[eE]~?\d+', Number.Float), (r'~?\d+', Number.Integer),
# Labels (r'#\s*[1-9][0-9]*', Name.Label), (rf'#\s*({alphanumid_re})', Name.Label), (rf'#\s+({symbolicid_re})', Name.Label), # Some reserved words trigger a special, local lexer state change (r'\b(datatype|abstype)\b(?!\')', Keyword.Reserved, 'dname'), (r'\b(exception)\b(?!\')', Keyword.Reserved, 'ename'), (r'\b(functor|include|open|signature|structure)\b(?!\')', Keyword.Reserved, 'sname'), (r'\b(type|eqtype)\b(?!\')', Keyword.Reserved, 'tname'),
# Regular identifiers, long and otherwise (r'\'[\w\']*', Name.Decorator), (rf'({alphanumid_re})(\.)', long_id_callback, "dotted"), (rf'({alphanumid_re})', id_callback), (rf'({symbolicid_re})', id_callback), ], 'dotted': [ (rf'({alphanumid_re})(\.)', long_id_callback), (rf'({alphanumid_re})', end_id_callback, "#pop"), (rf'({symbolicid_re})', end_id_callback, "#pop"), (r'\s+', Error), (r'\S+', Error), ],
# Main parser (prevents errors in files that have scoping errors) 'root': [ default('main') ],
# In this scope, I expect '|' to not be followed by a function name, # and I expect 'and' to be followed by a binding site 'main': [ include('whitespace'),
# Special behavior of val/and/fun (r'\b(val|and)\b(?!\')', Keyword.Reserved, 'vname'), (r'\b(fun)\b(?!\')', Keyword.Reserved, ('#pop', 'main-fun', 'fname')),
include('delimiters'), include('core'), (r'\S+', Error), ],
# In this scope, I expect '|' and 'and' to be followed by a function 'main-fun': [ include('whitespace'),
(r'\s', Text), (r'\(\*', Comment.Multiline, 'comment'),
# Special behavior of val/and/fun (r'\b(fun|and)\b(?!\')', Keyword.Reserved, 'fname'), (r'\b(val)\b(?!\')', Keyword.Reserved, ('#pop', 'main', 'vname')),
# Special behavior of '|' and '|'-manipulating keywords (r'\|', Punctuation, 'fname'), (r'\b(case|handle)\b(?!\')', Keyword.Reserved, ('#pop', 'main')),
include('delimiters'), include('core'), (r'\S+', Error), ],
# Character and string parsers 'char': stringy(String.Char), 'string': stringy(String.Double),
'breakout': [ (r'(?=\b({})\b(?!\'))'.format('|'.join(alphanumid_reserved)), Text, '#pop'), ],
# Dealing with what comes after module system keywords 'sname': [ include('whitespace'), include('breakout'),
(rf'({alphanumid_re})', Name.Namespace), default('#pop'), ],
# Dealing with what comes after the 'fun' (or 'and' or '|') keyword 'fname': [ include('whitespace'), (r'\'[\w\']*', Name.Decorator), (r'\(', Punctuation, 'tyvarseq'),
(rf'({alphanumid_re})', Name.Function, '#pop'), (rf'({symbolicid_re})', Name.Function, '#pop'),
# Ignore interesting function declarations like "fun (x + y) = ..." default('#pop'), ],
# Dealing with what comes after the 'val' (or 'and') keyword 'vname': [ include('whitespace'), (r'\'[\w\']*', Name.Decorator), (r'\(', Punctuation, 'tyvarseq'),
(rf'({alphanumid_re})(\s*)(=(?!{symbolicid_re}))', bygroups(Name.Variable, Text, Punctuation), '#pop'), (rf'({symbolicid_re})(\s*)(=(?!{symbolicid_re}))', bygroups(Name.Variable, Text, Punctuation), '#pop'), (rf'({alphanumid_re})', Name.Variable, '#pop'), (rf'({symbolicid_re})', Name.Variable, '#pop'),
# Ignore interesting patterns like 'val (x, y)' default('#pop'), ],
# Dealing with what comes after the 'type' (or 'and') keyword 'tname': [ include('whitespace'), include('breakout'),
(r'\'[\w\']*', Name.Decorator), (r'\(', Punctuation, 'tyvarseq'), (rf'=(?!{symbolicid_re})', Punctuation, ('#pop', 'typbind')),
(rf'({alphanumid_re})', Keyword.Type), (rf'({symbolicid_re})', Keyword.Type), (r'\S+', Error, '#pop'), ],
# A type binding includes most identifiers 'typbind': [ include('whitespace'),
(r'\b(and)\b(?!\')', Keyword.Reserved, ('#pop', 'tname')),
include('breakout'), include('core'), (r'\S+', Error, '#pop'), ],
# Dealing with what comes after the 'datatype' (or 'and') keyword 'dname': [ include('whitespace'), include('breakout'),
(r'\'[\w\']*', Name.Decorator), (r'\(', Punctuation, 'tyvarseq'), (r'(=)(\s*)(datatype)', bygroups(Punctuation, Text, Keyword.Reserved), '#pop'), (rf'=(?!{symbolicid_re})', Punctuation, ('#pop', 'datbind', 'datcon')),
(rf'({alphanumid_re})', Keyword.Type), (rf'({symbolicid_re})', Keyword.Type), (r'\S+', Error, '#pop'), ],
# common case - A | B | C of int 'datbind': [ include('whitespace'),
(r'\b(and)\b(?!\')', Keyword.Reserved, ('#pop', 'dname')), (r'\b(withtype)\b(?!\')', Keyword.Reserved, ('#pop', 'tname')), (r'\b(of)\b(?!\')', Keyword.Reserved),
(rf'(\|)(\s*)({alphanumid_re})', bygroups(Punctuation, Text, Name.Class)), (rf'(\|)(\s+)({symbolicid_re})', bygroups(Punctuation, Text, Name.Class)),
include('breakout'), include('core'), (r'\S+', Error), ],
# Dealing with what comes after an exception 'ename': [ include('whitespace'),
(rf'(and\b)(\s+)({alphanumid_re})', bygroups(Keyword.Reserved, Text, Name.Class)), (rf'(and\b)(\s*)({symbolicid_re})', bygroups(Keyword.Reserved, Text, Name.Class)), (r'\b(of)\b(?!\')', Keyword.Reserved), (rf'({alphanumid_re})|({symbolicid_re})', Name.Class),
default('#pop'), ],
'datcon': [ include('whitespace'), (rf'({alphanumid_re})', Name.Class, '#pop'), (rf'({symbolicid_re})', Name.Class, '#pop'), (r'\S+', Error, '#pop'), ],
# Series of type variables 'tyvarseq': [ (r'\s', Text), (r'\(\*', Comment.Multiline, 'comment'),
(r'\'[\w\']*', Name.Decorator), (alphanumid_re, Name), (r',', Punctuation), (r'\)', Punctuation, '#pop'), (symbolicid_re, Name), ],
'comment': [ (r'[^(*)]', Comment.Multiline), (r'\(\*', Comment.Multiline, '#push'), (r'\*\)', Comment.Multiline, '#pop'), (r'[(*)]', Comment.Multiline), ], }
class OcamlLexer(RegexLexer): """ For the OCaml language. """
name = 'OCaml' url = 'https://ocaml.org/' aliases = ['ocaml'] filenames = ['*.ml', '*.mli', '*.mll', '*.mly'] mimetypes = ['text/x-ocaml'] version_added = '0.7'
keywords = ( 'and', 'as', 'assert', 'begin', 'class', 'constraint', 'do', 'done', 'downto', 'else', 'end', 'exception', 'external', 'false', 'for', 'fun', 'function', 'functor', 'if', 'in', 'include', 'inherit', 'initializer', 'lazy', 'let', 'match', 'method', 'module', 'mutable', 'new', 'object', 'of', 'open', 'private', 'raise', 'rec', 'sig', 'struct', 'then', 'to', 'true', 'try', 'type', 'val', 'virtual', 'when', 'while', 'with', ) keyopts = ( '!=', '#', '&', '&&', r'\(', r'\)', r'\*', r'\+', ',', '-', r'-\.', '->', r'\.', r'\.\.', ':', '::', ':=', ':>', ';', ';;', '<', '<-', '=', '>', '>]', r'>\}', r'\?', r'\?\?', r'\[', r'\[<', r'\[>', r'\[\|', ']', '_', '`', r'\{', r'\{<', r'\|', r'\|]', r'\}', '~' )
operators = r'[!$%&*+\./:<=>?@^|~-]' word_operators = ('asr', 'land', 'lor', 'lsl', 'lxor', 'mod', 'or') prefix_syms = r'[!?~]' infix_syms = r'[=<>@^|&+\*/$%-]' primitives = ('unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array')
tokens = { 'escape-sequence': [ (r'\\[\\"\'ntbr]', String.Escape), (r'\\[0-9]{3}', String.Escape), (r'\\x[0-9a-fA-F]{2}', String.Escape), ], 'root': [ (r'\s+', Text), (r'false|true|\(\)|\[\]', Name.Builtin.Pseudo), (r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Namespace, 'dotted'), (r'\b([A-Z][\w\']*)', Name.Class), (r'\(\*(?![)])', Comment, 'comment'), (r'\b({})\b'.format('|'.join(keywords)), Keyword), (r'({})'.format('|'.join(keyopts[::-1])), Operator), (rf'({infix_syms}|{prefix_syms})?{operators}', Operator), (r'\b({})\b'.format('|'.join(word_operators)), Operator.Word), (r'\b({})\b'.format('|'.join(primitives)), Keyword.Type),
(r"[^\W\d][\w']*", Name),
(r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float), (r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex), (r'0[oO][0-7][0-7_]*', Number.Oct), (r'0[bB][01][01_]*', Number.Bin), (r'\d[\d_]*', Number.Integer),
(r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'", String.Char), (r"'.'", String.Char), (r"'", Keyword), # a stray quote is another syntax element
(r'"', String.Double, 'string'),
(r'[~?][a-z][\w\']*:', Name.Variable), ], 'comment': [ (r'[^(*)]+', Comment), (r'\(\*', Comment, '#push'), (r'\*\)', Comment, '#pop'), (r'[(*)]', Comment), ], 'string': [ (r'[^\\"]+', String.Double), include('escape-sequence'), (r'\\\n', String.Double), (r'"', String.Double, '#pop'), ], 'dotted': [ (r'\s+', Text), (r'\.', Punctuation), (r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace), (r'[A-Z][\w\']*', Name.Class, '#pop'), (r'[a-z_][\w\']*', Name, '#pop'), default('#pop'), ], }
class OpaLexer(RegexLexer): """ Lexer for the Opa language. """
name = 'Opa' aliases = ['opa'] filenames = ['*.opa'] mimetypes = ['text/x-opa'] url = 'http://opalang.org' version_added = '1.5'
# most of these aren't strictly keywords # but if you color only real keywords, you might just # as well not color anything keywords = ( 'and', 'as', 'begin', 'case', 'client', 'css', 'database', 'db', 'do', 'else', 'end', 'external', 'forall', 'function', 'if', 'import', 'match', 'module', 'or', 'package', 'parser', 'rec', 'server', 'then', 'type', 'val', 'with', 'xml_parser', )
# matches both stuff and `stuff` ident_re = r'(([a-zA-Z_]\w*)|(`[^`]*`))'
op_re = r'[.=\-<>,@~%/+?*&^!]' punc_re = r'[()\[\],;|]' # '{' and '}' are treated elsewhere # because they are also used for inserts
tokens = { # copied from the caml lexer, should be adapted 'escape-sequence': [ (r'\\[\\"\'ntr}]', String.Escape), (r'\\[0-9]{3}', String.Escape), (r'\\x[0-9a-fA-F]{2}', String.Escape), ],
# factorizing these rules, because they are inserted many times 'comments': [ (r'/\*', Comment, 'nested-comment'), (r'//.*?$', Comment), ], 'comments-and-spaces': [ include('comments'), (r'\s+', Text), ],
'root': [ include('comments-and-spaces'), # keywords (words(keywords, prefix=r'\b', suffix=r'\b'), Keyword), # directives # we could parse the actual set of directives instead of anything # starting with @, but this is troublesome # because it needs to be adjusted all the time # and assuming we parse only sources that compile, it is useless (r'@' + ident_re + r'\b', Name.Builtin.Pseudo),
# number literals (r'-?.[\d]+([eE][+\-]?\d+)', Number.Float), (r'-?\d+.\d*([eE][+\-]?\d+)', Number.Float), (r'-?\d+[eE][+\-]?\d+', Number.Float), (r'0[xX][\da-fA-F]+', Number.Hex), (r'0[oO][0-7]+', Number.Oct), (r'0[bB][01]+', Number.Bin), (r'\d+', Number.Integer), # color literals (r'#[\da-fA-F]{3,6}', Number.Integer),
# string literals (r'"', String.Double, 'string'), # char literal, should be checked because this is the regexp from # the caml lexer (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2})|.)'", String.Char),
# this is meant to deal with embedded exprs in strings # every time we find a '}' we pop a state so that if we were # inside a string, we are back in the string state # as a consequence, we must also push a state every time we find a # '{' or else we will have errors when parsing {} for instance (r'\{', Operator, '#push'), (r'\}', Operator, '#pop'),
# html literals # this is a much more strict that the actual parser, # since a<b would not be parsed as html # but then again, the parser is way too lax, and we can't hope # to have something as tolerant (r'<(?=[a-zA-Z>])', String.Single, 'html-open-tag'),
# db path # matching the '[_]' in '/a[_]' because it is a part # of the syntax of the db path definition # unfortunately, i don't know how to match the ']' in # /a[1], so this is somewhat inconsistent (r'[@?!]?(/\w+)+(\[_\])?', Name.Variable), # putting the same color on <- as on db path, since # it can be used only to mean Db.write (r'<-(?!'+op_re+r')', Name.Variable),
# 'modules' # although modules are not distinguished by their names as in caml # the standard library seems to follow the convention that modules # only area capitalized (r'\b([A-Z]\w*)(?=\.)', Name.Namespace),
# operators # = has a special role because this is the only # way to syntactic distinguish binding constructions # unfortunately, this colors the equal in {x=2} too (r'=(?!'+op_re+r')', Keyword), (rf'({op_re})+', Operator), (rf'({punc_re})+', Operator),
# coercions (r':', Operator, 'type'), # type variables # we need this rule because we don't parse specially type # definitions so in "type t('a) = ...", "'a" is parsed by 'root' ("'"+ident_re, Keyword.Type),
# id literal, #something, or #{expr} (r'#'+ident_re, String.Single), (r'#(?=\{)', String.Single),
# identifiers # this avoids to color '2' in 'a2' as an integer (ident_re, Text),
# default, not sure if that is needed or not # (r'.', Text), ],
# it is quite painful to have to parse types to know where they end # this is the general rule for a type # a type is either: # * -> ty # * type-with-slash # * type-with-slash -> ty # * type-with-slash (, type-with-slash)+ -> ty # # the code is pretty funky in here, but this code would roughly # translate in caml to: # let rec type stream = # match stream with # | [< "->"; stream >] -> type stream # | [< ""; stream >] -> # type_with_slash stream # type_lhs_1 stream; # and type_1 stream = ... 'type': [ include('comments-and-spaces'), (r'->', Keyword.Type), default(('#pop', 'type-lhs-1', 'type-with-slash')), ],
# parses all the atomic or closed constructions in the syntax of type # expressions: record types, tuple types, type constructors, basic type # and type variables 'type-1': [ include('comments-and-spaces'), (r'\(', Keyword.Type, ('#pop', 'type-tuple')), (r'~?\{', Keyword.Type, ('#pop', 'type-record')), (ident_re+r'\(', Keyword.Type, ('#pop', 'type-tuple')), (ident_re, Keyword.Type, '#pop'), ("'"+ident_re, Keyword.Type), # this case is not in the syntax but sometimes # we think we are parsing types when in fact we are parsing # some css, so we just pop the states until we get back into # the root state default('#pop'), ],
# type-with-slash is either: # * type-1 # * type-1 (/ type-1)+ 'type-with-slash': [ include('comments-and-spaces'), default(('#pop', 'slash-type-1', 'type-1')), ], 'slash-type-1': [ include('comments-and-spaces'), ('/', Keyword.Type, ('#pop', 'type-1')), # same remark as above default('#pop'), ],
# we go in this state after having parsed a type-with-slash # while trying to parse a type # and at this point we must determine if we are parsing an arrow # type (in which case we must continue parsing) or not (in which # case we stop) 'type-lhs-1': [ include('comments-and-spaces'), (r'->', Keyword.Type, ('#pop', 'type')), (r'(?=,)', Keyword.Type, ('#pop', 'type-arrow')), default('#pop'), ], 'type-arrow': [ include('comments-and-spaces'), # the look ahead here allows to parse f(x : int, y : float -> truc) # correctly (r',(?=[^:]*?->)', Keyword.Type, 'type-with-slash'), (r'->', Keyword.Type, ('#pop', 'type')), # same remark as above default('#pop'), ],
# no need to do precise parsing for tuples and records # because they are closed constructions, so we can simply # find the closing delimiter # note that this function would be not work if the source # contained identifiers like `{)` (although it could be patched # to support it) 'type-tuple': [ include('comments-and-spaces'), (r'[^()/*]+', Keyword.Type), (r'[/*]', Keyword.Type), (r'\(', Keyword.Type, '#push'), (r'\)', Keyword.Type, '#pop'), ], 'type-record': [ include('comments-and-spaces'), (r'[^{}/*]+', Keyword.Type), (r'[/*]', Keyword.Type), (r'\{', Keyword.Type, '#push'), (r'\}', Keyword.Type, '#pop'), ],
# 'type-tuple': [ # include('comments-and-spaces'), # (r'\)', Keyword.Type, '#pop'), # default(('#pop', 'type-tuple-1', 'type-1')), # ], # 'type-tuple-1': [ # include('comments-and-spaces'), # (r',?\s*\)', Keyword.Type, '#pop'), # ,) is a valid end of tuple, in (1,) # (r',', Keyword.Type, 'type-1'), # ], # 'type-record':[ # include('comments-and-spaces'), # (r'\}', Keyword.Type, '#pop'), # (r'~?(?:\w+|`[^`]*`)', Keyword.Type, 'type-record-field-expr'), # ], # 'type-record-field-expr': [ # # ],
'nested-comment': [ (r'[^/*]+', Comment), (r'/\*', Comment, '#push'), (r'\*/', Comment, '#pop'), (r'[/*]', Comment), ],
# the copy pasting between string and single-string # is kinda sad. Is there a way to avoid that?? 'string': [ (r'[^\\"{]+', String.Double), (r'"', String.Double, '#pop'), (r'\{', Operator, 'root'), include('escape-sequence'), ], 'single-string': [ (r'[^\\\'{]+', String.Double), (r'\'', String.Double, '#pop'), (r'\{', Operator, 'root'), include('escape-sequence'), ],
# all the html stuff # can't really reuse some existing html parser # because we must be able to parse embedded expressions
# we are in this state after someone parsed the '<' that # started the html literal 'html-open-tag': [ (r'[\w\-:]+', String.Single, ('#pop', 'html-attr')), (r'>', String.Single, ('#pop', 'html-content')), ],
# we are in this state after someone parsed the '</' that # started the end of the closing tag 'html-end-tag': [ # this is a star, because </> is allowed (r'[\w\-:]*>', String.Single, '#pop'), ],
# we are in this state after having parsed '<ident(:ident)?' # we thus parse a possibly empty list of attributes 'html-attr': [ (r'\s+', Text), (r'[\w\-:]+=', String.Single, 'html-attr-value'), (r'/>', String.Single, '#pop'), (r'>', String.Single, ('#pop', 'html-content')), ],
'html-attr-value': [ (r"'", String.Single, ('#pop', 'single-string')), (r'"', String.Single, ('#pop', 'string')), (r'#'+ident_re, String.Single, '#pop'), (r'#(?=\{)', String.Single, ('#pop', 'root')), (r'[^"\'{`=<>]+', String.Single, '#pop'), (r'\{', Operator, ('#pop', 'root')), # this is a tail call! ],
# we should probably deal with '\' escapes here 'html-content': [ (r'<!--', Comment, 'html-comment'), (r'</', String.Single, ('#pop', 'html-end-tag')), (r'<', String.Single, 'html-open-tag'), (r'\{', Operator, 'root'), (r'[^<{]+', String.Single), ],
'html-comment': [ (r'-->', Comment, '#pop'), (r'[^\-]+|-', Comment), ], }
class ReasonLexer(RegexLexer): """ For the ReasonML language. """
name = 'ReasonML' url = 'https://reasonml.github.io/' aliases = ['reasonml', 'reason'] filenames = ['*.re', '*.rei'] mimetypes = ['text/x-reasonml'] version_added = '2.6'
keywords = ( 'as', 'assert', 'begin', 'class', 'constraint', 'do', 'done', 'downto', 'else', 'end', 'exception', 'external', 'false', 'for', 'fun', 'esfun', 'function', 'functor', 'if', 'in', 'include', 'inherit', 'initializer', 'lazy', 'let', 'switch', 'module', 'pub', 'mutable', 'new', 'nonrec', 'object', 'of', 'open', 'pri', 'rec', 'sig', 'struct', 'then', 'to', 'true', 'try', 'type', 'val', 'virtual', 'when', 'while', 'with', ) keyopts = ( '!=', '#', '&', '&&', r'\(', r'\)', r'\*', r'\+', ',', '-', r'-\.', '=>', r'\.', r'\.\.', r'\.\.\.', ':', '::', ':=', ':>', ';', ';;', '<', '<-', '=', '>', '>]', r'>\}', r'\?', r'\?\?', r'\[', r'\[<', r'\[>', r'\[\|', ']', '_', '`', r'\{', r'\{<', r'\|', r'\|\|', r'\|]', r'\}', '~' )
operators = r'[!$%&*+\./:<=>?@^|~-]' word_operators = ('and', 'asr', 'land', 'lor', 'lsl', 'lsr', 'lxor', 'mod', 'or') prefix_syms = r'[!?~]' infix_syms = r'[=<>@^|&+\*/$%-]' primitives = ('unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array')
tokens = { 'escape-sequence': [ (r'\\[\\"\'ntbr]', String.Escape), (r'\\[0-9]{3}', String.Escape), (r'\\x[0-9a-fA-F]{2}', String.Escape), ], 'root': [ (r'\s+', Text), (r'false|true|\(\)|\[\]', Name.Builtin.Pseudo), (r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Namespace, 'dotted'), (r'\b([A-Z][\w\']*)', Name.Class), (r'//.*?\n', Comment.Single), (r'\/\*(?!/)', Comment.Multiline, 'comment'), (r'\b({})\b'.format('|'.join(keywords)), Keyword), (r'({})'.format('|'.join(keyopts[::-1])), Operator.Word), (rf'({infix_syms}|{prefix_syms})?{operators}', Operator), (r'\b({})\b'.format('|'.join(word_operators)), Operator.Word), (r'\b({})\b'.format('|'.join(primitives)), Keyword.Type),
(r"[^\W\d][\w']*", Name),
(r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float), (r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex), (r'0[oO][0-7][0-7_]*', Number.Oct), (r'0[bB][01][01_]*', Number.Bin), (r'\d[\d_]*', Number.Integer),
(r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'", String.Char), (r"'.'", String.Char), (r"'", Keyword),
(r'"', String.Double, 'string'),
(r'[~?][a-z][\w\']*:', Name.Variable), ], 'comment': [ (r'[^/*]+', Comment.Multiline), (r'\/\*', Comment.Multiline, '#push'), (r'\*\/', Comment.Multiline, '#pop'), (r'\*', Comment.Multiline), ], 'string': [ (r'[^\\"]+', String.Double), include('escape-sequence'), (r'\\\n', String.Double), (r'"', String.Double, '#pop'), ], 'dotted': [ (r'\s+', Text), (r'\.', Punctuation), (r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace), (r'[A-Z][\w\']*', Name.Class, '#pop'), (r'[a-z_][\w\']*', Name, '#pop'), default('#pop'), ], }
class FStarLexer(RegexLexer): """ For the F* language. """
name = 'FStar' url = 'https://www.fstar-lang.org/' aliases = ['fstar'] filenames = ['*.fst', '*.fsti'] mimetypes = ['text/x-fstar'] version_added = '2.7'
keywords = ( 'abstract', 'attributes', 'noeq', 'unopteq', 'and' 'begin', 'by', 'default', 'effect', 'else', 'end', 'ensures', 'exception', 'exists', 'false', 'forall', 'fun', 'function', 'if', 'in', 'include', 'inline', 'inline_for_extraction', 'irreducible', 'logic', 'match', 'module', 'mutable', 'new', 'new_effect', 'noextract', 'of', 'open', 'opaque', 'private', 'range_of', 'reifiable', 'reify', 'reflectable', 'requires', 'set_range_of', 'sub_effect', 'synth', 'then', 'total', 'true', 'try', 'type', 'unfold', 'unfoldable', 'val', 'when', 'with', 'not' ) decl_keywords = ('let', 'rec') assume_keywords = ('assume', 'admit', 'assert', 'calc') keyopts = ( r'~', r'-', r'/\\', r'\\/', r'<:', r'<@', r'\(\|', r'\|\)', r'#', r'u#', r'&', r'\(', r'\)', r'\(\)', r',', r'~>', r'->', r'<-', r'<--', r'<==>', r'==>', r'\.', r'\?', r'\?\.', r'\.\[', r'\.\(', r'\.\(\|', r'\.\[\|', r'\{:pattern', r':', r'::', r':=', r';', r';;', r'=', r'%\[', r'!\{', r'\[', r'\[@', r'\[\|', r'\|>', r'\]', r'\|\]', r'\{', r'\|', r'\}', r'\$' )
operators = r'[!$%&*+\./:<=>?@^|~-]' prefix_syms = r'[!?~]' infix_syms = r'[=<>@^|&+\*/$%-]' primitives = ('unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array')
tokens = { 'escape-sequence': [ (r'\\[\\"\'ntbr]', String.Escape), (r'\\[0-9]{3}', String.Escape), (r'\\x[0-9a-fA-F]{2}', String.Escape), ], 'root': [ (r'\s+', Text), (r'false|true|False|True|\(\)|\[\]', Name.Builtin.Pseudo), (r'\b([A-Z][\w\']*)(?=\s*\.)', Name.Namespace, 'dotted'), (r'\b([A-Z][\w\']*)', Name.Class), (r'\(\*(?![)])', Comment, 'comment'), (r'\/\/.+$', Comment), (r'\b({})\b'.format('|'.join(keywords)), Keyword), (r'\b({})\b'.format('|'.join(assume_keywords)), Name.Exception), (r'\b({})\b'.format('|'.join(decl_keywords)), Keyword.Declaration), (r'({})'.format('|'.join(keyopts[::-1])), Operator), (rf'({infix_syms}|{prefix_syms})?{operators}', Operator), (r'\b({})\b'.format('|'.join(primitives)), Keyword.Type),
(r"[^\W\d][\w']*", Name),
(r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float), (r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex), (r'0[oO][0-7][0-7_]*', Number.Oct), (r'0[bB][01][01_]*', Number.Bin), (r'\d[\d_]*', Number.Integer),
(r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'", String.Char), (r"'.'", String.Char), (r"'", Keyword), # a stray quote is another syntax element (r"\`([\w\'.]+)\`", Operator.Word), # for infix applications (r"\`", Keyword), # for quoting (r'"', String.Double, 'string'),
(r'[~?][a-z][\w\']*:', Name.Variable), ], 'comment': [ (r'[^(*)]+', Comment), (r'\(\*', Comment, '#push'), (r'\*\)', Comment, '#pop'), (r'[(*)]', Comment), ], 'string': [ (r'[^\\"]+', String.Double), include('escape-sequence'), (r'\\\n', String.Double), (r'"', String.Double, '#pop'), ], 'dotted': [ (r'\s+', Text), (r'\.', Punctuation), (r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace), (r'[A-Z][\w\']*', Name.Class, '#pop'), (r'[a-z_][\w\']*', Name, '#pop'), default('#pop'), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368""" pygments.lexers.modeling ~~~~~~~~~~~~~~~~~~~~~~~~
Lexers for modeling languages.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, include, bygroups, using, defaultfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Whitespace
from pygments.lexers.html import HtmlLexerfrom pygments.lexers import _stan_builtins
__all__ = ['ModelicaLexer', 'BugsLexer', 'JagsLexer', 'StanLexer']
class ModelicaLexer(RegexLexer): """ For Modelica source code. """ name = 'Modelica' url = 'http://www.modelica.org/' aliases = ['modelica'] filenames = ['*.mo'] mimetypes = ['text/x-modelica'] version_added = '1.1'
flags = re.DOTALL | re.MULTILINE
_name = r"(?:'(?:[^\\']|\\.)+'|[a-zA-Z_]\w*)"
tokens = { 'whitespace': [ (r'[\s\ufeff]+', Text), (r'//[^\n]*\n?', Comment.Single), (r'/\*.*?\*/', Comment.Multiline) ], 'root': [ include('whitespace'), (r'"', String.Double, 'string'), (r'[()\[\]{},;]+', Punctuation), (r'\.?[*^/+-]|\.|<>|[<>:=]=?', Operator), (r'\d+(\.?\d*[eE][-+]?\d+|\.\d*)', Number.Float), (r'\d+', Number.Integer), (r'(abs|acos|actualStream|array|asin|assert|AssertionLevel|atan|' r'atan2|backSample|Boolean|cardinality|cat|ceil|change|Clock|' r'Connections|cos|cosh|cross|delay|diagonal|div|edge|exp|' r'ExternalObject|fill|floor|getInstanceName|hold|homotopy|' r'identity|inStream|integer|Integer|interval|inverse|isPresent|' r'linspace|log|log10|matrix|max|min|mod|ndims|noClock|noEvent|' r'ones|outerProduct|pre|previous|product|Real|reinit|rem|rooted|' r'sample|scalar|semiLinear|shiftSample|sign|sin|sinh|size|skew|' r'smooth|spatialDistribution|sqrt|StateSelect|String|subSample|' r'sum|superSample|symmetric|tan|tanh|terminal|terminate|time|' r'transpose|vector|zeros)\b', Name.Builtin), (r'(algorithm|annotation|break|connect|constant|constrainedby|der|' r'discrete|each|else|elseif|elsewhen|encapsulated|enumeration|' r'equation|exit|expandable|extends|external|firstTick|final|flow|for|if|' r'import|impure|in|initial|inner|input|interval|loop|nondiscrete|outer|' r'output|parameter|partial|protected|public|pure|redeclare|' r'replaceable|return|stream|then|when|while)\b', Keyword.Reserved), (r'(and|not|or)\b', Operator.Word), (r'(block|class|connector|end|function|model|operator|package|' r'record|type)\b', Keyword.Reserved, 'class'), (r'(false|true)\b', Keyword.Constant), (r'within\b', Keyword.Reserved, 'package-prefix'), (_name, Name) ], 'class': [ include('whitespace'), (r'(function|record)\b', Keyword.Reserved), (r'(if|for|when|while)\b', Keyword.Reserved, '#pop'), (_name, Name.Class, '#pop'), default('#pop') ], 'package-prefix': [ include('whitespace'), (_name, Name.Namespace, '#pop'), default('#pop') ], 'string': [ (r'"', String.Double, '#pop'), (r'\\[\'"?\\abfnrtv]', String.Escape), (r'(?i)<\s*html\s*>([^\\"]|\\.)+?(<\s*/\s*html\s*>|(?="))', using(HtmlLexer)), (r'<|\\?[^"\\<]+', String.Double) ] }
class BugsLexer(RegexLexer): """ Pygments Lexer for OpenBugs and WinBugs models. """
name = 'BUGS' aliases = ['bugs', 'winbugs', 'openbugs'] filenames = ['*.bug'] url = 'https://www.mrc-bsu.cam.ac.uk/software/bugs/openbugs' version_added = '1.6'
_FUNCTIONS = ( # Scalar functions 'abs', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctanh', 'cloglog', 'cos', 'cosh', 'cumulative', 'cut', 'density', 'deviance', 'equals', 'expr', 'gammap', 'ilogit', 'icloglog', 'integral', 'log', 'logfact', 'loggam', 'logit', 'max', 'min', 'phi', 'post.p.value', 'pow', 'prior.p.value', 'probit', 'replicate.post', 'replicate.prior', 'round', 'sin', 'sinh', 'solution', 'sqrt', 'step', 'tan', 'tanh', 'trunc', # Vector functions 'inprod', 'interp.lin', 'inverse', 'logdet', 'mean', 'eigen.vals', 'ode', 'prod', 'p.valueM', 'rank', 'ranked', 'replicate.postM', 'sd', 'sort', 'sum', # Special 'D', 'I', 'F', 'T', 'C') """ OpenBUGS built-in functions
From http://www.openbugs.info/Manuals/ModelSpecification.html#ContentsAII
This also includes
- T, C, I : Truncation and censoring. ``T`` and ``C`` are in OpenBUGS. ``I`` in WinBUGS. - D : ODE - F : Functional http://www.openbugs.info/Examples/Functionals.html
"""
_DISTRIBUTIONS = ('dbern', 'dbin', 'dcat', 'dnegbin', 'dpois', 'dhyper', 'dbeta', 'dchisqr', 'ddexp', 'dexp', 'dflat', 'dgamma', 'dgev', 'df', 'dggamma', 'dgpar', 'dloglik', 'dlnorm', 'dlogis', 'dnorm', 'dpar', 'dt', 'dunif', 'dweib', 'dmulti', 'ddirch', 'dmnorm', 'dmt', 'dwish') """ OpenBUGS built-in distributions
Functions from http://www.openbugs.info/Manuals/ModelSpecification.html#ContentsAI """
tokens = { 'whitespace': [ (r"\s+", Text), ], 'comments': [ # Comments (r'#.*$', Comment.Single), ], 'root': [ # Comments include('comments'), include('whitespace'), # Block start (r'(model)(\s+)(\{)', bygroups(Keyword.Namespace, Text, Punctuation)), # Reserved Words (r'(for|in)(?![\w.])', Keyword.Reserved), # Built-in Functions (r'({})(?=\s*\()'.format(r'|'.join(_FUNCTIONS + _DISTRIBUTIONS)), Name.Builtin), # Regular variable names (r'[A-Za-z][\w.]*', Name), # Number Literals (r'[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?', Number), # Punctuation (r'\[|\]|\(|\)|:|,|;', Punctuation), # Assignment operators # SLexer makes these tokens Operators. (r'<-|~', Operator), # Infix and prefix operators (r'\+|-|\*|/', Operator), # Block (r'[{}]', Punctuation), ] }
def analyse_text(text): if re.search(r"^\s*model\s*{", text, re.M): return 0.7 else: return 0.0
class JagsLexer(RegexLexer): """ Pygments Lexer for JAGS. """
name = 'JAGS' aliases = ['jags'] filenames = ['*.jag', '*.bug'] url = 'https://mcmc-jags.sourceforge.io' version_added = '1.6'
# JAGS _FUNCTIONS = ( 'abs', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctanh', 'cos', 'cosh', 'cloglog', 'equals', 'exp', 'icloglog', 'ifelse', 'ilogit', 'log', 'logfact', 'loggam', 'logit', 'phi', 'pow', 'probit', 'round', 'sin', 'sinh', 'sqrt', 'step', 'tan', 'tanh', 'trunc', 'inprod', 'interp.lin', 'logdet', 'max', 'mean', 'min', 'prod', 'sum', 'sd', 'inverse', 'rank', 'sort', 't', 'acos', 'acosh', 'asin', 'asinh', 'atan', # Truncation/Censoring (should I include) 'T', 'I') # Distributions with density, probability and quartile functions _DISTRIBUTIONS = tuple(f'[dpq]{x}' for x in ('bern', 'beta', 'dchiqsqr', 'ddexp', 'dexp', 'df', 'gamma', 'gen.gamma', 'logis', 'lnorm', 'negbin', 'nchisqr', 'norm', 'par', 'pois', 'weib')) # Other distributions without density and probability _OTHER_DISTRIBUTIONS = ( 'dt', 'dunif', 'dbetabin', 'dbern', 'dbin', 'dcat', 'dhyper', 'ddirch', 'dmnorm', 'dwish', 'dmt', 'dmulti', 'dbinom', 'dchisq', 'dnbinom', 'dweibull', 'ddirich')
tokens = { 'whitespace': [ (r"\s+", Text), ], 'names': [ # Regular variable names (r'[a-zA-Z][\w.]*\b', Name), ], 'comments': [ # do not use stateful comments (r'(?s)/\*.*?\*/', Comment.Multiline), # Comments (r'#.*$', Comment.Single), ], 'root': [ # Comments include('comments'), include('whitespace'), # Block start (r'(model|data)(\s+)(\{)', bygroups(Keyword.Namespace, Text, Punctuation)), (r'var(?![\w.])', Keyword.Declaration), # Reserved Words (r'(for|in)(?![\w.])', Keyword.Reserved), # Builtins # Need to use lookahead because . is a valid char (r'({})(?=\s*\()'.format(r'|'.join(_FUNCTIONS + _DISTRIBUTIONS + _OTHER_DISTRIBUTIONS)), Name.Builtin), # Names include('names'), # Number Literals (r'[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?', Number), (r'\[|\]|\(|\)|:|,|;', Punctuation), # Assignment operators (r'<-|~', Operator), # # JAGS includes many more than OpenBUGS (r'\+|-|\*|\/|\|\|[&]{2}|[<>=]=?|\^|%.*?%', Operator), (r'[{}]', Punctuation), ] }
def analyse_text(text): if re.search(r'^\s*model\s*\{', text, re.M): if re.search(r'^\s*data\s*\{', text, re.M): return 0.9 elif re.search(r'^\s*var', text, re.M): return 0.9 else: return 0.3 else: return 0
class StanLexer(RegexLexer): """Pygments Lexer for Stan models.
The Stan modeling language is specified in the *Stan Modeling Language User's Guide and Reference Manual, v2.17.0*, `pdf <https://github.com/stan-dev/stan/releases/download/v2.17.0/stan-reference-2.17.0.pdf>`__. """
name = 'Stan' aliases = ['stan'] filenames = ['*.stan'] url = 'https://mc-stan.org' version_added = '1.6'
tokens = { 'whitespace': [ (r"\s+", Text), ], 'comments': [ (r'(?s)/\*.*?\*/', Comment.Multiline), # Comments (r'(//|#).*$', Comment.Single), ], 'root': [ (r'"[^"]*"', String), # Comments include('comments'), # block start include('whitespace'), # Block start (r'({})(\s*)(\{{)'.format(r'|'.join(('functions', 'data', r'transformed\s+?data', 'parameters', r'transformed\s+parameters', 'model', r'generated\s+quantities'))), bygroups(Keyword.Namespace, Text, Punctuation)), # target keyword (r'target\s*\+=', Keyword), # jacobian += statement (r'jacobian\s*\+=', Keyword), # Reserved Words (r'({})\b'.format(r'|'.join(_stan_builtins.KEYWORDS)), Keyword), # Truncation (r'T(?=\s*\[)', Keyword), # Data types (r'({})\b'.format(r'|'.join(_stan_builtins.TYPES)), Keyword.Type), # < should be punctuation, but elsewhere I can't tell if it is in # a range constraint (r'(<)(\s*)(upper|lower|offset|multiplier)(\s*)(=)', bygroups(Operator, Whitespace, Keyword, Whitespace, Punctuation)), (r'(,)(\s*)(upper)(\s*)(=)', bygroups(Punctuation, Whitespace, Keyword, Whitespace, Punctuation)), # Punctuation (r"[;,\[\]()]", Punctuation), # Builtin (r'({})(?=\s*\()'.format('|'.join(_stan_builtins.FUNCTIONS)), Name.Builtin), (r'(~)(\s*)({})(?=\s*\()'.format('|'.join(_stan_builtins.DISTRIBUTIONS)), bygroups(Operator, Whitespace, Name.Builtin)), # Special names ending in __, like lp__ (r'[A-Za-z]\w*__\b', Name.Builtin.Pseudo), (r'({})\b'.format(r'|'.join(_stan_builtins.RESERVED)), Keyword.Reserved), # user-defined functions (r'[A-Za-z]\w*(?=\s*\()]', Name.Function), # Imaginary Literals (r'[0-9]+(\.[0-9]*)?([eE][+-]?[0-9]+)?i', Number.Float), (r'\.[0-9]+([eE][+-]?[0-9]+)?i', Number.Float), (r'[0-9]+i', Number.Float), # Real Literals (r'[0-9]+(\.[0-9]*)?([eE][+-]?[0-9]+)?', Number.Float), (r'\.[0-9]+([eE][+-]?[0-9]+)?', Number.Float), # Integer Literals (r'[0-9]+', Number.Integer), # Regular variable names (r'[A-Za-z]\w*\b', Name), # Assignment operators (r'<-|(?:\+|-|\.?/|\.?\*|=)?=|~', Operator), # Infix, prefix and postfix operators (and = ) (r"\+|-|\.?\*|\.?/|\\|'|\.?\^|!=?|<=?|>=?|\|\||&&|%|\?|:|%/%|!", Operator), # Block delimiters (r'[{}]', Punctuation), # Distribution | (r'\|', Punctuation) ] }
def analyse_text(text): if re.search(r'^\s*parameters\s*\{', text, re.M): return 1.0 else: return 0.01234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579""" pygments.lexers.modula2 ~~~~~~~~~~~~~~~~~~~~~~~
Multi-Dialect Lexer for Modula-2.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, includefrom pygments.util import get_bool_opt, get_list_optfrom pygments.token import Text, Comment, Operator, Keyword, Name, \ String, Number, Punctuation, Error
__all__ = ['Modula2Lexer']
# Multi-Dialect Modula-2 Lexerclass Modula2Lexer(RegexLexer): """ For Modula-2 source code.
The Modula-2 lexer supports several dialects. By default, it operates in fallback mode, recognising the *combined* literals, punctuation symbols and operators of all supported dialects, and the *combined* reserved words and builtins of PIM Modula-2, ISO Modula-2 and Modula-2 R10, while not differentiating between library defined identifiers.
To select a specific dialect, a dialect option may be passed or a dialect tag may be embedded into a source file.
Dialect Options:
`m2pim` Select PIM Modula-2 dialect. `m2iso` Select ISO Modula-2 dialect. `m2r10` Select Modula-2 R10 dialect. `objm2` Select Objective Modula-2 dialect.
The PIM and ISO dialect options may be qualified with a language extension.
Language Extensions:
`+aglet` Select Aglet Modula-2 extensions, available with m2iso. `+gm2` Select GNU Modula-2 extensions, available with m2pim. `+p1` Select p1 Modula-2 extensions, available with m2iso. `+xds` Select XDS Modula-2 extensions, available with m2iso.
Passing a Dialect Option via Unix Commandline Interface
Dialect options may be passed to the lexer using the `dialect` key. Only one such option should be passed. If multiple dialect options are passed, the first valid option is used, any subsequent options are ignored.
Examples:
`$ pygmentize -O full,dialect=m2iso -f html -o /path/to/output /path/to/input` Use ISO dialect to render input to HTML output `$ pygmentize -O full,dialect=m2iso+p1 -f rtf -o /path/to/output /path/to/input` Use ISO dialect with p1 extensions to render input to RTF output
Embedding a Dialect Option within a source file
A dialect option may be embedded in a source file in form of a dialect tag, a specially formatted comment that specifies a dialect option.
Dialect Tag EBNF::
dialectTag : OpeningCommentDelim Prefix dialectOption ClosingCommentDelim ;
dialectOption : 'm2pim' | 'm2iso' | 'm2r10' | 'objm2' | 'm2iso+aglet' | 'm2pim+gm2' | 'm2iso+p1' | 'm2iso+xds' ;
Prefix : '!' ;
OpeningCommentDelim : '(*' ;
ClosingCommentDelim : '*)' ;
No whitespace is permitted between the tokens of a dialect tag.
In the event that a source file contains multiple dialect tags, the first tag that contains a valid dialect option will be used and any subsequent dialect tags will be ignored. Ideally, a dialect tag should be placed at the beginning of a source file.
An embedded dialect tag overrides a dialect option set via command line.
Examples:
``(*!m2r10*) DEFINITION MODULE Foobar; ...`` Use Modula2 R10 dialect to render this source file. ``(*!m2pim+gm2*) DEFINITION MODULE Bazbam; ...`` Use PIM dialect with GNU extensions to render this source file.
Algol Publication Mode:
In Algol publication mode, source text is rendered for publication of algorithms in scientific papers and academic texts, following the format of the Revised Algol-60 Language Report. It is activated by passing one of two corresponding styles as an option:
`algol` render reserved words lowercase underline boldface and builtins lowercase boldface italic `algol_nu` render reserved words lowercase boldface (no underlining) and builtins lowercase boldface italic
The lexer automatically performs the required lowercase conversion when this mode is activated.
Example:
``$ pygmentize -O full,style=algol -f latex -o /path/to/output /path/to/input`` Render input file in Algol publication mode to LaTeX output.
Rendering Mode of First Class ADT Identifiers:
The rendering of standard library first class ADT identifiers is controlled by option flag "treat_stdlib_adts_as_builtins".
When this option is turned on, standard library ADT identifiers are rendered as builtins. When it is turned off, they are rendered as ordinary library identifiers.
`treat_stdlib_adts_as_builtins` (default: On)
The option is useful for dialects that support ADTs as first class objects and provide ADTs in the standard library that would otherwise be built-in.
At present, only Modula-2 R10 supports library ADTs as first class objects and therefore, no ADT identifiers are defined for any other dialects.
Example:
``$ pygmentize -O full,dialect=m2r10,treat_stdlib_adts_as_builtins=Off ...`` Render standard library ADTs as ordinary library types.
.. versionchanged:: 2.1 Added multi-dialect support. """ name = 'Modula-2' url = 'http://www.modula2.org/' aliases = ['modula2', 'm2'] filenames = ['*.def', '*.mod'] mimetypes = ['text/x-modula2'] version_added = '1.3'
flags = re.MULTILINE | re.DOTALL
tokens = { 'whitespace': [ (r'\n+', Text), # blank lines (r'\s+', Text), # whitespace ], 'dialecttags': [ # PIM Dialect Tag (r'\(\*!m2pim\*\)', Comment.Special), # ISO Dialect Tag (r'\(\*!m2iso\*\)', Comment.Special), # M2R10 Dialect Tag (r'\(\*!m2r10\*\)', Comment.Special), # ObjM2 Dialect Tag (r'\(\*!objm2\*\)', Comment.Special), # Aglet Extensions Dialect Tag (r'\(\*!m2iso\+aglet\*\)', Comment.Special), # GNU Extensions Dialect Tag (r'\(\*!m2pim\+gm2\*\)', Comment.Special), # p1 Extensions Dialect Tag (r'\(\*!m2iso\+p1\*\)', Comment.Special), # XDS Extensions Dialect Tag (r'\(\*!m2iso\+xds\*\)', Comment.Special), ], 'identifiers': [ (r'([a-zA-Z_$][\w$]*)', Name), ], 'prefixed_number_literals': [ # # Base-2, whole number (r'0b[01]+(\'[01]+)*', Number.Bin), # # Base-16, whole number (r'0[ux][0-9A-F]+(\'[0-9A-F]+)*', Number.Hex), ], 'plain_number_literals': [ # # Base-10, real number with exponent (r'[0-9]+(\'[0-9]+)*' # integral part r'\.[0-9]+(\'[0-9]+)*' # fractional part r'[eE][+-]?[0-9]+(\'[0-9]+)*', # exponent Number.Float), # # Base-10, real number without exponent (r'[0-9]+(\'[0-9]+)*' # integral part r'\.[0-9]+(\'[0-9]+)*', # fractional part Number.Float), # # Base-10, whole number (r'[0-9]+(\'[0-9]+)*', Number.Integer), ], 'suffixed_number_literals': [ # # Base-8, whole number (r'[0-7]+B', Number.Oct), # # Base-8, character code (r'[0-7]+C', Number.Oct), # # Base-16, number (r'[0-9A-F]+H', Number.Hex), ], 'string_literals': [ (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double), (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single), ], 'digraph_operators': [ # Dot Product Operator (r'\*\.', Operator), # Array Concatenation Operator (r'\+>', Operator), # M2R10 + ObjM2 # Inequality Operator (r'<>', Operator), # ISO + PIM # Less-Or-Equal, Subset (r'<=', Operator), # Greater-Or-Equal, Superset (r'>=', Operator), # Identity Operator (r'==', Operator), # M2R10 + ObjM2 # Type Conversion Operator (r'::', Operator), # M2R10 + ObjM2 # Assignment Symbol (r':=', Operator), # Postfix Increment Mutator (r'\+\+', Operator), # M2R10 + ObjM2 # Postfix Decrement Mutator (r'--', Operator), # M2R10 + ObjM2 ], 'unigraph_operators': [ # Arithmetic Operators (r'[+-]', Operator), (r'[*/]', Operator), # ISO 80000-2 compliant Set Difference Operator (r'\\', Operator), # M2R10 + ObjM2 # Relational Operators (r'[=#<>]', Operator), # Dereferencing Operator (r'\^', Operator), # Dereferencing Operator Synonym (r'@', Operator), # ISO # Logical AND Operator Synonym (r'&', Operator), # PIM + ISO # Logical NOT Operator Synonym (r'~', Operator), # PIM + ISO # Smalltalk Message Prefix (r'`', Operator), # ObjM2 ], 'digraph_punctuation': [ # Range Constructor (r'\.\.', Punctuation), # Opening Chevron Bracket (r'<<', Punctuation), # M2R10 + ISO # Closing Chevron Bracket (r'>>', Punctuation), # M2R10 + ISO # Blueprint Punctuation (r'->', Punctuation), # M2R10 + ISO # Distinguish |# and # in M2 R10 (r'\|#', Punctuation), # Distinguish ## and # in M2 R10 (r'##', Punctuation), # Distinguish |* and * in M2 R10 (r'\|\*', Punctuation), ], 'unigraph_punctuation': [ # Common Punctuation (r'[()\[\]{},.:;|]', Punctuation), # Case Label Separator Synonym (r'!', Punctuation), # ISO # Blueprint Punctuation (r'\?', Punctuation), # M2R10 + ObjM2 ], 'comments': [ # Single Line Comment (r'^//.*?\n', Comment.Single), # M2R10 + ObjM2 # Block Comment (r'\(\*([^$].*?)\*\)', Comment.Multiline), # Template Block Comment (r'/\*(.*?)\*/', Comment.Multiline), # M2R10 + ObjM2 ], 'pragmas': [ # ISO Style Pragmas (r'<\*.*?\*>', Comment.Preproc), # ISO, M2R10 + ObjM2 # Pascal Style Pragmas (r'\(\*\$.*?\*\)', Comment.Preproc), # PIM ], 'root': [ include('whitespace'), include('dialecttags'), include('pragmas'), include('comments'), include('identifiers'), include('suffixed_number_literals'), # PIM + ISO include('prefixed_number_literals'), # M2R10 + ObjM2 include('plain_number_literals'), include('string_literals'), include('digraph_punctuation'), include('digraph_operators'), include('unigraph_punctuation'), include('unigraph_operators'), ] }
# C o m m o n D a t a s e t s
# Common Reserved Words Dataset common_reserved_words = ( # 37 common reserved words 'AND', 'ARRAY', 'BEGIN', 'BY', 'CASE', 'CONST', 'DEFINITION', 'DIV', 'DO', 'ELSE', 'ELSIF', 'END', 'EXIT', 'FOR', 'FROM', 'IF', 'IMPLEMENTATION', 'IMPORT', 'IN', 'LOOP', 'MOD', 'MODULE', 'NOT', 'OF', 'OR', 'POINTER', 'PROCEDURE', 'RECORD', 'REPEAT', 'RETURN', 'SET', 'THEN', 'TO', 'TYPE', 'UNTIL', 'VAR', 'WHILE', )
# Common Builtins Dataset common_builtins = ( # 16 common builtins 'ABS', 'BOOLEAN', 'CARDINAL', 'CHAR', 'CHR', 'FALSE', 'INTEGER', 'LONGINT', 'LONGREAL', 'MAX', 'MIN', 'NIL', 'ODD', 'ORD', 'REAL', 'TRUE', )
# Common Pseudo-Module Builtins Dataset common_pseudo_builtins = ( # 4 common pseudo builtins 'ADDRESS', 'BYTE', 'WORD', 'ADR' )
# P I M M o d u l a - 2 D a t a s e t s
# Lexemes to Mark as Error Tokens for PIM Modula-2 pim_lexemes_to_reject = ( '!', '`', '@', '$', '%', '?', '\\', '==', '++', '--', '::', '*.', '+>', '->', '<<', '>>', '|#', '##', )
# PIM Modula-2 Additional Reserved Words Dataset pim_additional_reserved_words = ( # 3 additional reserved words 'EXPORT', 'QUALIFIED', 'WITH', )
# PIM Modula-2 Additional Builtins Dataset pim_additional_builtins = ( # 16 additional builtins 'BITSET', 'CAP', 'DEC', 'DISPOSE', 'EXCL', 'FLOAT', 'HALT', 'HIGH', 'INC', 'INCL', 'NEW', 'NIL', 'PROC', 'SIZE', 'TRUNC', 'VAL', )
# PIM Modula-2 Additional Pseudo-Module Builtins Dataset pim_additional_pseudo_builtins = ( # 5 additional pseudo builtins 'SYSTEM', 'PROCESS', 'TSIZE', 'NEWPROCESS', 'TRANSFER', )
# I S O M o d u l a - 2 D a t a s e t s
# Lexemes to Mark as Error Tokens for ISO Modula-2 iso_lexemes_to_reject = ( '`', '$', '%', '?', '\\', '==', '++', '--', '::', '*.', '+>', '->', '<<', '>>', '|#', '##', )
# ISO Modula-2 Additional Reserved Words Dataset iso_additional_reserved_words = ( # 9 additional reserved words (ISO 10514-1) 'EXCEPT', 'EXPORT', 'FINALLY', 'FORWARD', 'PACKEDSET', 'QUALIFIED', 'REM', 'RETRY', 'WITH', # 10 additional reserved words (ISO 10514-2 & ISO 10514-3) 'ABSTRACT', 'AS', 'CLASS', 'GUARD', 'INHERIT', 'OVERRIDE', 'READONLY', 'REVEAL', 'TRACED', 'UNSAFEGUARDED', )
# ISO Modula-2 Additional Builtins Dataset iso_additional_builtins = ( # 26 additional builtins (ISO 10514-1) 'BITSET', 'CAP', 'CMPLX', 'COMPLEX', 'DEC', 'DISPOSE', 'EXCL', 'FLOAT', 'HALT', 'HIGH', 'IM', 'INC', 'INCL', 'INT', 'INTERRUPTIBLE', 'LENGTH', 'LFLOAT', 'LONGCOMPLEX', 'NEW', 'PROC', 'PROTECTION', 'RE', 'SIZE', 'TRUNC', 'UNINTERRUBTIBLE', 'VAL', # 5 additional builtins (ISO 10514-2 & ISO 10514-3) 'CREATE', 'DESTROY', 'EMPTY', 'ISMEMBER', 'SELF', )
# ISO Modula-2 Additional Pseudo-Module Builtins Dataset iso_additional_pseudo_builtins = ( # 14 additional builtins (SYSTEM) 'SYSTEM', 'BITSPERLOC', 'LOCSPERBYTE', 'LOCSPERWORD', 'LOC', 'ADDADR', 'SUBADR', 'DIFADR', 'MAKEADR', 'ADR', 'ROTATE', 'SHIFT', 'CAST', 'TSIZE', # 13 additional builtins (COROUTINES) 'COROUTINES', 'ATTACH', 'COROUTINE', 'CURRENT', 'DETACH', 'HANDLER', 'INTERRUPTSOURCE', 'IOTRANSFER', 'IsATTACHED', 'LISTEN', 'NEWCOROUTINE', 'PROT', 'TRANSFER', # 9 additional builtins (EXCEPTIONS) 'EXCEPTIONS', 'AllocateSource', 'CurrentNumber', 'ExceptionNumber', 'ExceptionSource', 'GetMessage', 'IsCurrentSource', 'IsExceptionalExecution', 'RAISE', # 3 additional builtins (TERMINATION) 'TERMINATION', 'IsTerminating', 'HasHalted', # 4 additional builtins (M2EXCEPTION) 'M2EXCEPTION', 'M2Exceptions', 'M2Exception', 'IsM2Exception', 'indexException', 'rangeException', 'caseSelectException', 'invalidLocation', 'functionException', 'wholeValueException', 'wholeDivException', 'realValueException', 'realDivException', 'complexValueException', 'complexDivException', 'protException', 'sysException', 'coException', 'exException', )
# M o d u l a - 2 R 1 0 D a t a s e t s
# Lexemes to Mark as Error Tokens for Modula-2 R10 m2r10_lexemes_to_reject = ( '!', '`', '@', '$', '%', '&', '<>', )
# Modula-2 R10 reserved words in addition to the common set m2r10_additional_reserved_words = ( # 12 additional reserved words 'ALIAS', 'ARGLIST', 'BLUEPRINT', 'COPY', 'GENLIB', 'INDETERMINATE', 'NEW', 'NONE', 'OPAQUE', 'REFERENTIAL', 'RELEASE', 'RETAIN', # 2 additional reserved words with symbolic assembly option 'ASM', 'REG', )
# Modula-2 R10 builtins in addition to the common set m2r10_additional_builtins = ( # 26 additional builtins 'CARDINAL', 'COUNT', 'EMPTY', 'EXISTS', 'INSERT', 'LENGTH', 'LONGCARD', 'OCTET', 'PTR', 'PRED', 'READ', 'READNEW', 'REMOVE', 'RETRIEVE', 'SORT', 'STORE', 'SUBSET', 'SUCC', 'TLIMIT', 'TMAX', 'TMIN', 'TRUE', 'TSIZE', 'UNICHAR', 'WRITE', 'WRITEF', )
# Modula-2 R10 Additional Pseudo-Module Builtins Dataset m2r10_additional_pseudo_builtins = ( # 13 additional builtins (TPROPERTIES) 'TPROPERTIES', 'PROPERTY', 'LITERAL', 'TPROPERTY', 'TLITERAL', 'TBUILTIN', 'TDYN', 'TREFC', 'TNIL', 'TBASE', 'TPRECISION', 'TMAXEXP', 'TMINEXP', # 4 additional builtins (CONVERSION) 'CONVERSION', 'TSXFSIZE', 'SXF', 'VAL', # 35 additional builtins (UNSAFE) 'UNSAFE', 'CAST', 'INTRINSIC', 'AVAIL', 'ADD', 'SUB', 'ADDC', 'SUBC', 'FETCHADD', 'FETCHSUB', 'SHL', 'SHR', 'ASHR', 'ROTL', 'ROTR', 'ROTLC', 'ROTRC', 'BWNOT', 'BWAND', 'BWOR', 'BWXOR', 'BWNAND', 'BWNOR', 'SETBIT', 'TESTBIT', 'LSBIT', 'MSBIT', 'CSBITS', 'BAIL', 'HALT', 'TODO', 'FFI', 'ADDR', 'VARGLIST', 'VARGC', # 11 additional builtins (ATOMIC) 'ATOMIC', 'INTRINSIC', 'AVAIL', 'SWAP', 'CAS', 'INC', 'DEC', 'BWAND', 'BWNAND', 'BWOR', 'BWXOR', # 7 additional builtins (COMPILER) 'COMPILER', 'DEBUG', 'MODNAME', 'PROCNAME', 'LINENUM', 'DEFAULT', 'HASH', # 5 additional builtins (ASSEMBLER) 'ASSEMBLER', 'REGISTER', 'SETREG', 'GETREG', 'CODE', )
# O b j e c t i v e M o d u l a - 2 D a t a s e t s
# Lexemes to Mark as Error Tokens for Objective Modula-2 objm2_lexemes_to_reject = ( '!', '$', '%', '&', '<>', )
# Objective Modula-2 Extensions # reserved words in addition to Modula-2 R10 objm2_additional_reserved_words = ( # 16 additional reserved words 'BYCOPY', 'BYREF', 'CLASS', 'CONTINUE', 'CRITICAL', 'INOUT', 'METHOD', 'ON', 'OPTIONAL', 'OUT', 'PRIVATE', 'PROTECTED', 'PROTOCOL', 'PUBLIC', 'SUPER', 'TRY', )
# Objective Modula-2 Extensions # builtins in addition to Modula-2 R10 objm2_additional_builtins = ( # 3 additional builtins 'OBJECT', 'NO', 'YES', )
# Objective Modula-2 Extensions # pseudo-module builtins in addition to Modula-2 R10 objm2_additional_pseudo_builtins = ( # None )
# A g l e t M o d u l a - 2 D a t a s e t s
# Aglet Extensions # reserved words in addition to ISO Modula-2 aglet_additional_reserved_words = ( # None )
# Aglet Extensions # builtins in addition to ISO Modula-2 aglet_additional_builtins = ( # 9 additional builtins 'BITSET8', 'BITSET16', 'BITSET32', 'CARDINAL8', 'CARDINAL16', 'CARDINAL32', 'INTEGER8', 'INTEGER16', 'INTEGER32', )
# Aglet Modula-2 Extensions # pseudo-module builtins in addition to ISO Modula-2 aglet_additional_pseudo_builtins = ( # None )
# G N U M o d u l a - 2 D a t a s e t s
# GNU Extensions # reserved words in addition to PIM Modula-2 gm2_additional_reserved_words = ( # 10 additional reserved words 'ASM', '__ATTRIBUTE__', '__BUILTIN__', '__COLUMN__', '__DATE__', '__FILE__', '__FUNCTION__', '__LINE__', '__MODULE__', 'VOLATILE', )
# GNU Extensions # builtins in addition to PIM Modula-2 gm2_additional_builtins = ( # 21 additional builtins 'BITSET8', 'BITSET16', 'BITSET32', 'CARDINAL8', 'CARDINAL16', 'CARDINAL32', 'CARDINAL64', 'COMPLEX32', 'COMPLEX64', 'COMPLEX96', 'COMPLEX128', 'INTEGER8', 'INTEGER16', 'INTEGER32', 'INTEGER64', 'REAL8', 'REAL16', 'REAL32', 'REAL96', 'REAL128', 'THROW', )
# GNU Extensions # pseudo-module builtins in addition to PIM Modula-2 gm2_additional_pseudo_builtins = ( # None )
# p 1 M o d u l a - 2 D a t a s e t s
# p1 Extensions # reserved words in addition to ISO Modula-2 p1_additional_reserved_words = ( # None )
# p1 Extensions # builtins in addition to ISO Modula-2 p1_additional_builtins = ( # None )
# p1 Modula-2 Extensions # pseudo-module builtins in addition to ISO Modula-2 p1_additional_pseudo_builtins = ( # 1 additional builtin 'BCD', )
# X D S M o d u l a - 2 D a t a s e t s
# XDS Extensions # reserved words in addition to ISO Modula-2 xds_additional_reserved_words = ( # 1 additional reserved word 'SEQ', )
# XDS Extensions # builtins in addition to ISO Modula-2 xds_additional_builtins = ( # 9 additional builtins 'ASH', 'ASSERT', 'DIFFADR_TYPE', 'ENTIER', 'INDEX', 'LEN', 'LONGCARD', 'SHORTCARD', 'SHORTINT', )
# XDS Modula-2 Extensions # pseudo-module builtins in addition to ISO Modula-2 xds_additional_pseudo_builtins = ( # 22 additional builtins (SYSTEM) 'PROCESS', 'NEWPROCESS', 'BOOL8', 'BOOL16', 'BOOL32', 'CARD8', 'CARD16', 'CARD32', 'INT8', 'INT16', 'INT32', 'REF', 'MOVE', 'FILL', 'GET', 'PUT', 'CC', 'int', 'unsigned', 'size_t', 'void' # 3 additional builtins (COMPILER) 'COMPILER', 'OPTION', 'EQUATION' )
# P I M S t a n d a r d L i b r a r y D a t a s e t s
# PIM Modula-2 Standard Library Modules Dataset pim_stdlib_module_identifiers = ( 'Terminal', 'FileSystem', 'InOut', 'RealInOut', 'MathLib0', 'Storage', )
# PIM Modula-2 Standard Library Types Dataset pim_stdlib_type_identifiers = ( 'Flag', 'FlagSet', 'Response', 'Command', 'Lock', 'Permission', 'MediumType', 'File', 'FileProc', 'DirectoryProc', 'FileCommand', 'DirectoryCommand', )
# PIM Modula-2 Standard Library Procedures Dataset pim_stdlib_proc_identifiers = ( 'Read', 'BusyRead', 'ReadAgain', 'Write', 'WriteString', 'WriteLn', 'Create', 'Lookup', 'Close', 'Delete', 'Rename', 'SetRead', 'SetWrite', 'SetModify', 'SetOpen', 'Doio', 'SetPos', 'GetPos', 'Length', 'Reset', 'Again', 'ReadWord', 'WriteWord', 'ReadChar', 'WriteChar', 'CreateMedium', 'DeleteMedium', 'AssignName', 'DeassignName', 'ReadMedium', 'LookupMedium', 'OpenInput', 'OpenOutput', 'CloseInput', 'CloseOutput', 'ReadString', 'ReadInt', 'ReadCard', 'ReadWrd', 'WriteInt', 'WriteCard', 'WriteOct', 'WriteHex', 'WriteWrd', 'ReadReal', 'WriteReal', 'WriteFixPt', 'WriteRealOct', 'sqrt', 'exp', 'ln', 'sin', 'cos', 'arctan', 'entier', 'ALLOCATE', 'DEALLOCATE', )
# PIM Modula-2 Standard Library Variables Dataset pim_stdlib_var_identifiers = ( 'Done', 'termCH', 'in', 'out' )
# PIM Modula-2 Standard Library Constants Dataset pim_stdlib_const_identifiers = ( 'EOL', )
# I S O S t a n d a r d L i b r a r y D a t a s e t s
# ISO Modula-2 Standard Library Modules Dataset iso_stdlib_module_identifiers = ( # TO DO )
# ISO Modula-2 Standard Library Types Dataset iso_stdlib_type_identifiers = ( # TO DO )
# ISO Modula-2 Standard Library Procedures Dataset iso_stdlib_proc_identifiers = ( # TO DO )
# ISO Modula-2 Standard Library Variables Dataset iso_stdlib_var_identifiers = ( # TO DO )
# ISO Modula-2 Standard Library Constants Dataset iso_stdlib_const_identifiers = ( # TO DO )
# M 2 R 1 0 S t a n d a r d L i b r a r y D a t a s e t s
# Modula-2 R10 Standard Library ADTs Dataset m2r10_stdlib_adt_identifiers = ( 'BCD', 'LONGBCD', 'BITSET', 'SHORTBITSET', 'LONGBITSET', 'LONGLONGBITSET', 'COMPLEX', 'LONGCOMPLEX', 'SHORTCARD', 'LONGLONGCARD', 'SHORTINT', 'LONGLONGINT', 'POSINT', 'SHORTPOSINT', 'LONGPOSINT', 'LONGLONGPOSINT', 'BITSET8', 'BITSET16', 'BITSET32', 'BITSET64', 'BITSET128', 'BS8', 'BS16', 'BS32', 'BS64', 'BS128', 'CARDINAL8', 'CARDINAL16', 'CARDINAL32', 'CARDINAL64', 'CARDINAL128', 'CARD8', 'CARD16', 'CARD32', 'CARD64', 'CARD128', 'INTEGER8', 'INTEGER16', 'INTEGER32', 'INTEGER64', 'INTEGER128', 'INT8', 'INT16', 'INT32', 'INT64', 'INT128', 'STRING', 'UNISTRING', )
# Modula-2 R10 Standard Library Blueprints Dataset m2r10_stdlib_blueprint_identifiers = ( 'ProtoRoot', 'ProtoComputational', 'ProtoNumeric', 'ProtoScalar', 'ProtoNonScalar', 'ProtoCardinal', 'ProtoInteger', 'ProtoReal', 'ProtoComplex', 'ProtoVector', 'ProtoTuple', 'ProtoCompArray', 'ProtoCollection', 'ProtoStaticArray', 'ProtoStaticSet', 'ProtoStaticString', 'ProtoArray', 'ProtoString', 'ProtoSet', 'ProtoMultiSet', 'ProtoDictionary', 'ProtoMultiDict', 'ProtoExtension', 'ProtoIO', 'ProtoCardMath', 'ProtoIntMath', 'ProtoRealMath', )
# Modula-2 R10 Standard Library Modules Dataset m2r10_stdlib_module_identifiers = ( 'ASCII', 'BooleanIO', 'CharIO', 'UnicharIO', 'OctetIO', 'CardinalIO', 'LongCardIO', 'IntegerIO', 'LongIntIO', 'RealIO', 'LongRealIO', 'BCDIO', 'LongBCDIO', 'CardMath', 'LongCardMath', 'IntMath', 'LongIntMath', 'RealMath', 'LongRealMath', 'BCDMath', 'LongBCDMath', 'FileIO', 'FileSystem', 'Storage', 'IOSupport', )
# Modula-2 R10 Standard Library Types Dataset m2r10_stdlib_type_identifiers = ( 'File', 'Status', # TO BE COMPLETED )
# Modula-2 R10 Standard Library Procedures Dataset m2r10_stdlib_proc_identifiers = ( 'ALLOCATE', 'DEALLOCATE', 'SIZE', # TO BE COMPLETED )
# Modula-2 R10 Standard Library Variables Dataset m2r10_stdlib_var_identifiers = ( 'stdIn', 'stdOut', 'stdErr', )
# Modula-2 R10 Standard Library Constants Dataset m2r10_stdlib_const_identifiers = ( 'pi', 'tau', )
# D i a l e c t s
# Dialect modes dialects = ( 'unknown', 'm2pim', 'm2iso', 'm2r10', 'objm2', 'm2iso+aglet', 'm2pim+gm2', 'm2iso+p1', 'm2iso+xds', )
# D a t a b a s e s
# Lexemes to Mark as Errors Database lexemes_to_reject_db = { # Lexemes to reject for unknown dialect 'unknown': ( # LEAVE THIS EMPTY ), # Lexemes to reject for PIM Modula-2 'm2pim': ( pim_lexemes_to_reject, ), # Lexemes to reject for ISO Modula-2 'm2iso': ( iso_lexemes_to_reject, ), # Lexemes to reject for Modula-2 R10 'm2r10': ( m2r10_lexemes_to_reject, ), # Lexemes to reject for Objective Modula-2 'objm2': ( objm2_lexemes_to_reject, ), # Lexemes to reject for Aglet Modula-2 'm2iso+aglet': ( iso_lexemes_to_reject, ), # Lexemes to reject for GNU Modula-2 'm2pim+gm2': ( pim_lexemes_to_reject, ), # Lexemes to reject for p1 Modula-2 'm2iso+p1': ( iso_lexemes_to_reject, ), # Lexemes to reject for XDS Modula-2 'm2iso+xds': ( iso_lexemes_to_reject, ), }
# Reserved Words Database reserved_words_db = { # Reserved words for unknown dialect 'unknown': ( common_reserved_words, pim_additional_reserved_words, iso_additional_reserved_words, m2r10_additional_reserved_words, ),
# Reserved words for PIM Modula-2 'm2pim': ( common_reserved_words, pim_additional_reserved_words, ),
# Reserved words for Modula-2 R10 'm2iso': ( common_reserved_words, iso_additional_reserved_words, ),
# Reserved words for ISO Modula-2 'm2r10': ( common_reserved_words, m2r10_additional_reserved_words, ),
# Reserved words for Objective Modula-2 'objm2': ( common_reserved_words, m2r10_additional_reserved_words, objm2_additional_reserved_words, ),
# Reserved words for Aglet Modula-2 Extensions 'm2iso+aglet': ( common_reserved_words, iso_additional_reserved_words, aglet_additional_reserved_words, ),
# Reserved words for GNU Modula-2 Extensions 'm2pim+gm2': ( common_reserved_words, pim_additional_reserved_words, gm2_additional_reserved_words, ),
# Reserved words for p1 Modula-2 Extensions 'm2iso+p1': ( common_reserved_words, iso_additional_reserved_words, p1_additional_reserved_words, ),
# Reserved words for XDS Modula-2 Extensions 'm2iso+xds': ( common_reserved_words, iso_additional_reserved_words, xds_additional_reserved_words, ), }
# Builtins Database builtins_db = { # Builtins for unknown dialect 'unknown': ( common_builtins, pim_additional_builtins, iso_additional_builtins, m2r10_additional_builtins, ),
# Builtins for PIM Modula-2 'm2pim': ( common_builtins, pim_additional_builtins, ),
# Builtins for ISO Modula-2 'm2iso': ( common_builtins, iso_additional_builtins, ),
# Builtins for ISO Modula-2 'm2r10': ( common_builtins, m2r10_additional_builtins, ),
# Builtins for Objective Modula-2 'objm2': ( common_builtins, m2r10_additional_builtins, objm2_additional_builtins, ),
# Builtins for Aglet Modula-2 Extensions 'm2iso+aglet': ( common_builtins, iso_additional_builtins, aglet_additional_builtins, ),
# Builtins for GNU Modula-2 Extensions 'm2pim+gm2': ( common_builtins, pim_additional_builtins, gm2_additional_builtins, ),
# Builtins for p1 Modula-2 Extensions 'm2iso+p1': ( common_builtins, iso_additional_builtins, p1_additional_builtins, ),
# Builtins for XDS Modula-2 Extensions 'm2iso+xds': ( common_builtins, iso_additional_builtins, xds_additional_builtins, ), }
# Pseudo-Module Builtins Database pseudo_builtins_db = { # Builtins for unknown dialect 'unknown': ( common_pseudo_builtins, pim_additional_pseudo_builtins, iso_additional_pseudo_builtins, m2r10_additional_pseudo_builtins, ),
# Builtins for PIM Modula-2 'm2pim': ( common_pseudo_builtins, pim_additional_pseudo_builtins, ),
# Builtins for ISO Modula-2 'm2iso': ( common_pseudo_builtins, iso_additional_pseudo_builtins, ),
# Builtins for ISO Modula-2 'm2r10': ( common_pseudo_builtins, m2r10_additional_pseudo_builtins, ),
# Builtins for Objective Modula-2 'objm2': ( common_pseudo_builtins, m2r10_additional_pseudo_builtins, objm2_additional_pseudo_builtins, ),
# Builtins for Aglet Modula-2 Extensions 'm2iso+aglet': ( common_pseudo_builtins, iso_additional_pseudo_builtins, aglet_additional_pseudo_builtins, ),
# Builtins for GNU Modula-2 Extensions 'm2pim+gm2': ( common_pseudo_builtins, pim_additional_pseudo_builtins, gm2_additional_pseudo_builtins, ),
# Builtins for p1 Modula-2 Extensions 'm2iso+p1': ( common_pseudo_builtins, iso_additional_pseudo_builtins, p1_additional_pseudo_builtins, ),
# Builtins for XDS Modula-2 Extensions 'm2iso+xds': ( common_pseudo_builtins, iso_additional_pseudo_builtins, xds_additional_pseudo_builtins, ), }
# Standard Library ADTs Database stdlib_adts_db = { # Empty entry for unknown dialect 'unknown': ( # LEAVE THIS EMPTY ), # Standard Library ADTs for PIM Modula-2 'm2pim': ( # No first class library types ),
# Standard Library ADTs for ISO Modula-2 'm2iso': ( # No first class library types ),
# Standard Library ADTs for Modula-2 R10 'm2r10': ( m2r10_stdlib_adt_identifiers, ),
# Standard Library ADTs for Objective Modula-2 'objm2': ( m2r10_stdlib_adt_identifiers, ),
# Standard Library ADTs for Aglet Modula-2 'm2iso+aglet': ( # No first class library types ),
# Standard Library ADTs for GNU Modula-2 'm2pim+gm2': ( # No first class library types ),
# Standard Library ADTs for p1 Modula-2 'm2iso+p1': ( # No first class library types ),
# Standard Library ADTs for XDS Modula-2 'm2iso+xds': ( # No first class library types ), }
# Standard Library Modules Database stdlib_modules_db = { # Empty entry for unknown dialect 'unknown': ( # LEAVE THIS EMPTY ), # Standard Library Modules for PIM Modula-2 'm2pim': ( pim_stdlib_module_identifiers, ),
# Standard Library Modules for ISO Modula-2 'm2iso': ( iso_stdlib_module_identifiers, ),
# Standard Library Modules for Modula-2 R10 'm2r10': ( m2r10_stdlib_blueprint_identifiers, m2r10_stdlib_module_identifiers, m2r10_stdlib_adt_identifiers, ),
# Standard Library Modules for Objective Modula-2 'objm2': ( m2r10_stdlib_blueprint_identifiers, m2r10_stdlib_module_identifiers, ),
# Standard Library Modules for Aglet Modula-2 'm2iso+aglet': ( iso_stdlib_module_identifiers, ),
# Standard Library Modules for GNU Modula-2 'm2pim+gm2': ( pim_stdlib_module_identifiers, ),
# Standard Library Modules for p1 Modula-2 'm2iso+p1': ( iso_stdlib_module_identifiers, ),
# Standard Library Modules for XDS Modula-2 'm2iso+xds': ( iso_stdlib_module_identifiers, ), }
# Standard Library Types Database stdlib_types_db = { # Empty entry for unknown dialect 'unknown': ( # LEAVE THIS EMPTY ), # Standard Library Types for PIM Modula-2 'm2pim': ( pim_stdlib_type_identifiers, ),
# Standard Library Types for ISO Modula-2 'm2iso': ( iso_stdlib_type_identifiers, ),
# Standard Library Types for Modula-2 R10 'm2r10': ( m2r10_stdlib_type_identifiers, ),
# Standard Library Types for Objective Modula-2 'objm2': ( m2r10_stdlib_type_identifiers, ),
# Standard Library Types for Aglet Modula-2 'm2iso+aglet': ( iso_stdlib_type_identifiers, ),
# Standard Library Types for GNU Modula-2 'm2pim+gm2': ( pim_stdlib_type_identifiers, ),
# Standard Library Types for p1 Modula-2 'm2iso+p1': ( iso_stdlib_type_identifiers, ),
# Standard Library Types for XDS Modula-2 'm2iso+xds': ( iso_stdlib_type_identifiers, ), }
# Standard Library Procedures Database stdlib_procedures_db = { # Empty entry for unknown dialect 'unknown': ( # LEAVE THIS EMPTY ), # Standard Library Procedures for PIM Modula-2 'm2pim': ( pim_stdlib_proc_identifiers, ),
# Standard Library Procedures for ISO Modula-2 'm2iso': ( iso_stdlib_proc_identifiers, ),
# Standard Library Procedures for Modula-2 R10 'm2r10': ( m2r10_stdlib_proc_identifiers, ),
# Standard Library Procedures for Objective Modula-2 'objm2': ( m2r10_stdlib_proc_identifiers, ),
# Standard Library Procedures for Aglet Modula-2 'm2iso+aglet': ( iso_stdlib_proc_identifiers, ),
# Standard Library Procedures for GNU Modula-2 'm2pim+gm2': ( pim_stdlib_proc_identifiers, ),
# Standard Library Procedures for p1 Modula-2 'm2iso+p1': ( iso_stdlib_proc_identifiers, ),
# Standard Library Procedures for XDS Modula-2 'm2iso+xds': ( iso_stdlib_proc_identifiers, ), }
# Standard Library Variables Database stdlib_variables_db = { # Empty entry for unknown dialect 'unknown': ( # LEAVE THIS EMPTY ), # Standard Library Variables for PIM Modula-2 'm2pim': ( pim_stdlib_var_identifiers, ),
# Standard Library Variables for ISO Modula-2 'm2iso': ( iso_stdlib_var_identifiers, ),
# Standard Library Variables for Modula-2 R10 'm2r10': ( m2r10_stdlib_var_identifiers, ),
# Standard Library Variables for Objective Modula-2 'objm2': ( m2r10_stdlib_var_identifiers, ),
# Standard Library Variables for Aglet Modula-2 'm2iso+aglet': ( iso_stdlib_var_identifiers, ),
# Standard Library Variables for GNU Modula-2 'm2pim+gm2': ( pim_stdlib_var_identifiers, ),
# Standard Library Variables for p1 Modula-2 'm2iso+p1': ( iso_stdlib_var_identifiers, ),
# Standard Library Variables for XDS Modula-2 'm2iso+xds': ( iso_stdlib_var_identifiers, ), }
# Standard Library Constants Database stdlib_constants_db = { # Empty entry for unknown dialect 'unknown': ( # LEAVE THIS EMPTY ), # Standard Library Constants for PIM Modula-2 'm2pim': ( pim_stdlib_const_identifiers, ),
# Standard Library Constants for ISO Modula-2 'm2iso': ( iso_stdlib_const_identifiers, ),
# Standard Library Constants for Modula-2 R10 'm2r10': ( m2r10_stdlib_const_identifiers, ),
# Standard Library Constants for Objective Modula-2 'objm2': ( m2r10_stdlib_const_identifiers, ),
# Standard Library Constants for Aglet Modula-2 'm2iso+aglet': ( iso_stdlib_const_identifiers, ),
# Standard Library Constants for GNU Modula-2 'm2pim+gm2': ( pim_stdlib_const_identifiers, ),
# Standard Library Constants for p1 Modula-2 'm2iso+p1': ( iso_stdlib_const_identifiers, ),
# Standard Library Constants for XDS Modula-2 'm2iso+xds': ( iso_stdlib_const_identifiers, ), }
# M e t h o d s
# initialise a lexer instance def __init__(self, **options): # # check dialect options # dialects = get_list_opt(options, 'dialect', []) # for dialect_option in dialects: if dialect_option in self.dialects[1:-1]: # valid dialect option found self.set_dialect(dialect_option) break # # Fallback Mode (DEFAULT) else: # no valid dialect option self.set_dialect('unknown') # self.dialect_set_by_tag = False # # check style options # styles = get_list_opt(options, 'style', []) # # use lowercase mode for Algol style if 'algol' in styles or 'algol_nu' in styles: self.algol_publication_mode = True else: self.algol_publication_mode = False # # Check option flags # self.treat_stdlib_adts_as_builtins = get_bool_opt( options, 'treat_stdlib_adts_as_builtins', True) # # call superclass initialiser RegexLexer.__init__(self, **options)
# Set lexer to a specified dialect def set_dialect(self, dialect_id): # # if __debug__: # print 'entered set_dialect with arg: ', dialect_id # # check dialect name against known dialects if dialect_id not in self.dialects: dialect = 'unknown' # default else: dialect = dialect_id # # compose lexemes to reject set lexemes_to_reject_set = set() # add each list of reject lexemes for this dialect for list in self.lexemes_to_reject_db[dialect]: lexemes_to_reject_set.update(set(list)) # # compose reserved words set reswords_set = set() # add each list of reserved words for this dialect for list in self.reserved_words_db[dialect]: reswords_set.update(set(list)) # # compose builtins set builtins_set = set() # add each list of builtins for this dialect excluding reserved words for list in self.builtins_db[dialect]: builtins_set.update(set(list).difference(reswords_set)) # # compose pseudo-builtins set pseudo_builtins_set = set() # add each list of builtins for this dialect excluding reserved words for list in self.pseudo_builtins_db[dialect]: pseudo_builtins_set.update(set(list).difference(reswords_set)) # # compose ADTs set adts_set = set() # add each list of ADTs for this dialect excluding reserved words for list in self.stdlib_adts_db[dialect]: adts_set.update(set(list).difference(reswords_set)) # # compose modules set modules_set = set() # add each list of builtins for this dialect excluding builtins for list in self.stdlib_modules_db[dialect]: modules_set.update(set(list).difference(builtins_set)) # # compose types set types_set = set() # add each list of types for this dialect excluding builtins for list in self.stdlib_types_db[dialect]: types_set.update(set(list).difference(builtins_set)) # # compose procedures set procedures_set = set() # add each list of procedures for this dialect excluding builtins for list in self.stdlib_procedures_db[dialect]: procedures_set.update(set(list).difference(builtins_set)) # # compose variables set variables_set = set() # add each list of variables for this dialect excluding builtins for list in self.stdlib_variables_db[dialect]: variables_set.update(set(list).difference(builtins_set)) # # compose constants set constants_set = set() # add each list of constants for this dialect excluding builtins for list in self.stdlib_constants_db[dialect]: constants_set.update(set(list).difference(builtins_set)) # # update lexer state self.dialect = dialect self.lexemes_to_reject = lexemes_to_reject_set self.reserved_words = reswords_set self.builtins = builtins_set self.pseudo_builtins = pseudo_builtins_set self.adts = adts_set self.modules = modules_set self.types = types_set self.procedures = procedures_set self.variables = variables_set self.constants = constants_set # # if __debug__: # print 'exiting set_dialect' # print ' self.dialect: ', self.dialect # print ' self.lexemes_to_reject: ', self.lexemes_to_reject # print ' self.reserved_words: ', self.reserved_words # print ' self.builtins: ', self.builtins # print ' self.pseudo_builtins: ', self.pseudo_builtins # print ' self.adts: ', self.adts # print ' self.modules: ', self.modules # print ' self.types: ', self.types # print ' self.procedures: ', self.procedures # print ' self.variables: ', self.variables # print ' self.types: ', self.types # print ' self.constants: ', self.constants
# Extracts a dialect name from a dialect tag comment string and checks # the extracted name against known dialects. If a match is found, the # matching name is returned, otherwise dialect id 'unknown' is returned def get_dialect_from_dialect_tag(self, dialect_tag): # # if __debug__: # print 'entered get_dialect_from_dialect_tag with arg: ', dialect_tag # # constants left_tag_delim = '(*!' right_tag_delim = '*)' left_tag_delim_len = len(left_tag_delim) right_tag_delim_len = len(right_tag_delim) indicator_start = left_tag_delim_len indicator_end = -(right_tag_delim_len) # # check comment string for dialect indicator if len(dialect_tag) > (left_tag_delim_len + right_tag_delim_len) \ and dialect_tag.startswith(left_tag_delim) \ and dialect_tag.endswith(right_tag_delim): # # if __debug__: # print 'dialect tag found' # # extract dialect indicator indicator = dialect_tag[indicator_start:indicator_end] # # if __debug__: # print 'extracted: ', indicator # # check against known dialects for index in range(1, len(self.dialects)): # # if __debug__: # print 'dialects[', index, ']: ', self.dialects[index] # if indicator == self.dialects[index]: # # if __debug__: # print 'matching dialect found' # # indicator matches known dialect return indicator else: # indicator does not match any dialect return 'unknown' # default else: # invalid indicator string return 'unknown' # default
# intercept the token stream, modify token attributes and return them def get_tokens_unprocessed(self, text): for index, token, value in RegexLexer.get_tokens_unprocessed(self, text): # # check for dialect tag if dialect has not been set by tag if not self.dialect_set_by_tag and token == Comment.Special: indicated_dialect = self.get_dialect_from_dialect_tag(value) if indicated_dialect != 'unknown': # token is a dialect indicator # reset reserved words and builtins self.set_dialect(indicated_dialect) self.dialect_set_by_tag = True # # check for reserved words, predefined and stdlib identifiers if token is Name: if value in self.reserved_words: token = Keyword.Reserved if self.algol_publication_mode: value = value.lower() # elif value in self.builtins: token = Name.Builtin if self.algol_publication_mode: value = value.lower() # elif value in self.pseudo_builtins: token = Name.Builtin.Pseudo if self.algol_publication_mode: value = value.lower() # elif value in self.adts: if not self.treat_stdlib_adts_as_builtins: token = Name.Namespace else: token = Name.Builtin.Pseudo if self.algol_publication_mode: value = value.lower() # elif value in self.modules: token = Name.Namespace # elif value in self.types: token = Name.Class # elif value in self.procedures: token = Name.Function # elif value in self.variables: token = Name.Variable # elif value in self.constants: token = Name.Constant # elif token in Number: # # mark prefix number literals as error for PIM and ISO dialects if self.dialect not in ('unknown', 'm2r10', 'objm2'): if "'" in value or value[0:2] in ('0b', '0x', '0u'): token = Error # elif self.dialect in ('m2r10', 'objm2'): # mark base-8 number literals as errors for M2 R10 and ObjM2 if token is Number.Oct: token = Error # mark suffix base-16 literals as errors for M2 R10 and ObjM2 elif token is Number.Hex and 'H' in value: token = Error # mark real numbers with E as errors for M2 R10 and ObjM2 elif token is Number.Float and 'E' in value: token = Error # elif token in Comment: # # mark single line comment as error for PIM and ISO dialects if token is Comment.Single: if self.dialect not in ('unknown', 'm2r10', 'objm2'): token = Error # if token is Comment.Preproc: # mark ISO pragma as error for PIM dialects if value.startswith('<*') and \ self.dialect.startswith('m2pim'): token = Error # mark PIM pragma as comment for other dialects elif value.startswith('(*$') and \ self.dialect != 'unknown' and \ not self.dialect.startswith('m2pim'): token = Comment.Multiline # else: # token is neither Name nor Comment # # mark lexemes matching the dialect's error token set as errors if value in self.lexemes_to_reject: token = Error # # substitute lexemes when in Algol mode if self.algol_publication_mode: if value == '#': value = '≠' elif value == '<=': value = '≤' elif value == '>=': value = '≥' elif value == '==': value = '≡' elif value == '*.': value = '•'
# return result yield index, token, value
def analyse_text(text): """It's Pascal-like, but does not use FUNCTION -- uses PROCEDURE instead."""
# Check if this looks like Pascal, if not, bail out early if not ('(*' in text and '*)' in text and ':=' in text): return
result = 0 # Procedure is in Modula2 if re.search(r'\bPROCEDURE\b', text): result += 0.6
# FUNCTION is only valid in Pascal, but not in Modula2 if re.search(r'\bFUNCTION\b', text): result = 0.0
return result123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707""" pygments.lexers.mojo ~~~~~~~~~~~~~~~~~~~~
Lexers for Mojo and related languages.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import keyword
from pygments import unistring as unifrom pygments.lexer import ( RegexLexer, bygroups, combined, default, include, this, using, words,)from pygments.token import ( Comment, # Error, Keyword, Name, Number, Operator, Punctuation, String, Text, Whitespace,)from pygments.util import shebang_matches
__all__ = ["MojoLexer"]
class MojoLexer(RegexLexer): """ For Mojo source code (version 24.2.1). """
name = "Mojo" url = "https://docs.modular.com/mojo/" aliases = ["mojo", "🔥"] filenames = [ "*.mojo", "*.🔥", ] mimetypes = [ "text/x-mojo", "application/x-mojo", ] version_added = "2.18"
uni_name = f"[{uni.xid_start}][{uni.xid_continue}]*"
def innerstring_rules(ttype): return [ # the old style '%s' % (...) string formatting (still valid in Py3) ( r"%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?" "[hlL]?[E-GXc-giorsaux%]", String.Interpol, ), # the new style '{}'.format(...) string formatting ( r"\{" r"((\w+)((\.\w+)|(\[[^\]]+\]))*)?" # field name r"(\![sra])?" # conversion r"(\:(.?[<>=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?" r"\}", String.Interpol, ), # backslashes, quotes and formatting signs must be parsed one at a time (r'[^\\\'"%{\n]+', ttype), (r'[\'"\\]', ttype), # unhandled string formatting sign (r"%|(\{{1,2})", ttype), # newlines are an error (use "nl" state) ]
def fstring_rules(ttype): return [ # Assuming that a '}' is the closing brace after format specifier. # Sadly, this means that we won't detect syntax error. But it's # more important to parse correct syntax correctly, than to # highlight invalid syntax. (r"\}", String.Interpol), (r"\{", String.Interpol, "expr-inside-fstring"), # backslashes, quotes and formatting signs must be parsed one at a time (r'[^\\\'"{}\n]+', ttype), (r'[\'"\\]', ttype), # newlines are an error (use "nl" state) ]
tokens = { "root": [ (r"\s+", Whitespace), ( r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")', bygroups(Whitespace, String.Affix, String.Doc), ), ( r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')", bygroups(Whitespace, String.Affix, String.Doc), ), (r"\A#!.+$", Comment.Hashbang), (r"#.*$", Comment.Single), (r"\\\n", Whitespace), (r"\\", Whitespace), include("keywords"), include("soft-keywords"), # In the original PR, all the below here used ((?:\s|\\\s)+) to # designate whitespace, but I can't find any example of this being # needed in the example file, so we're replacing it with `\s+`. ( r"(alias)(\s+)", bygroups(Keyword, Whitespace), "varname", # TODO varname the right fit? ), (r"(var)(\s+)", bygroups(Keyword, Whitespace), "varname"), (r"(def)(\s+)", bygroups(Keyword, Whitespace), "funcname"), (r"(fn)(\s+)", bygroups(Keyword, Whitespace), "funcname"), ( r"(class)(\s+)", bygroups(Keyword, Whitespace), "classname", ), # not implemented yet (r"(struct)(\s+)", bygroups(Keyword, Whitespace), "structname"), (r"(trait)(\s+)", bygroups(Keyword, Whitespace), "structname"), (r"(from)(\s+)", bygroups(Keyword.Namespace, Whitespace), "fromimport"), (r"(import)(\s+)", bygroups(Keyword.Namespace, Whitespace), "import"), include("expr"), ], "expr": [ # raw f-strings ( '(?i)(rf|fr)(""")', bygroups(String.Affix, String.Double), combined("rfstringescape", "tdqf"), ), ( "(?i)(rf|fr)(''')", bygroups(String.Affix, String.Single), combined("rfstringescape", "tsqf"), ), ( '(?i)(rf|fr)(")', bygroups(String.Affix, String.Double), combined("rfstringescape", "dqf"), ), ( "(?i)(rf|fr)(')", bygroups(String.Affix, String.Single), combined("rfstringescape", "sqf"), ), # non-raw f-strings ( '([fF])(""")', bygroups(String.Affix, String.Double), combined("fstringescape", "tdqf"), ), ( "([fF])(''')", bygroups(String.Affix, String.Single), combined("fstringescape", "tsqf"), ), ( '([fF])(")', bygroups(String.Affix, String.Double), combined("fstringescape", "dqf"), ), ( "([fF])(')", bygroups(String.Affix, String.Single), combined("fstringescape", "sqf"), ), # raw bytes and strings ('(?i)(rb|br|r)(""")', bygroups(String.Affix, String.Double), "tdqs"), ("(?i)(rb|br|r)(''')", bygroups(String.Affix, String.Single), "tsqs"), ('(?i)(rb|br|r)(")', bygroups(String.Affix, String.Double), "dqs"), ("(?i)(rb|br|r)(')", bygroups(String.Affix, String.Single), "sqs"), # non-raw strings ( '([uU]?)(""")', bygroups(String.Affix, String.Double), combined("stringescape", "tdqs"), ), ( "([uU]?)(''')", bygroups(String.Affix, String.Single), combined("stringescape", "tsqs"), ), ( '([uU]?)(")', bygroups(String.Affix, String.Double), combined("stringescape", "dqs"), ), ( "([uU]?)(')", bygroups(String.Affix, String.Single), combined("stringescape", "sqs"), ), # non-raw bytes ( '([bB])(""")', bygroups(String.Affix, String.Double), combined("bytesescape", "tdqs"), ), ( "([bB])(''')", bygroups(String.Affix, String.Single), combined("bytesescape", "tsqs"), ), ( '([bB])(")', bygroups(String.Affix, String.Double), combined("bytesescape", "dqs"), ), ( "([bB])(')", bygroups(String.Affix, String.Single), combined("bytesescape", "sqs"), ), (r"[^\S\n]+", Text), include("numbers"), (r"!=|==|<<|>>|:=|[-~+/*%=<>&^|.]", Operator), (r"([]{}:\(\),;[])+", Punctuation), (r"(in|is|and|or|not)\b", Operator.Word), include("expr-keywords"), include("builtins"), include("magicfuncs"), include("magicvars"), include("name"), ], "expr-inside-fstring": [ (r"[{([]", Punctuation, "expr-inside-fstring-inner"), # without format specifier ( r"(=\s*)?" # debug (https://bugs.python.org/issue36817) r"(\![sraf])?" # conversion r"\}", String.Interpol, "#pop", ), # with format specifier # we'll catch the remaining '}' in the outer scope ( r"(=\s*)?" # debug (https://bugs.python.org/issue36817) r"(\![sraf])?" # conversion r":", String.Interpol, "#pop", ), (r"\s+", Whitespace), # allow new lines include("expr"), ], "expr-inside-fstring-inner": [ (r"[{([]", Punctuation, "expr-inside-fstring-inner"), (r"[])}]", Punctuation, "#pop"), (r"\s+", Whitespace), # allow new lines include("expr"), ], "expr-keywords": [ # Based on https://docs.python.org/3/reference/expressions.html ( words( ( "async for", # TODO https://docs.modular.com/mojo/roadmap#no-async-for-or-async-with "async with", # TODO https://docs.modular.com/mojo/roadmap#no-async-for-or-async-with "await", "else", "for", "if", "lambda", "yield", "yield from", ), suffix=r"\b", ), Keyword, ), (words(("True", "False", "None"), suffix=r"\b"), Keyword.Constant), ], "keywords": [ ( words( ( "assert", "async", "await", "borrowed", "break", "continue", "del", "elif", "else", "except", "finally", "for", "global", "if", "lambda", "pass", "raise", "nonlocal", "return", "try", "while", "yield", "yield from", "as", "with", ), suffix=r"\b", ), Keyword, ), (words(("True", "False", "None"), suffix=r"\b"), Keyword.Constant), ], "soft-keywords": [ # `match`, `case` and `_` soft keywords ( r"(^[ \t]*)" # at beginning of line + possible indentation r"(match|case)\b" # a possible keyword r"(?![ \t]*(?:" # not followed by... r"[:,;=^&|@~)\]}]|(?:" + # characters and keywords that mean this isn't # pattern matching (but None/True/False is ok) r"|".join(k for k in keyword.kwlist if k[0].islower()) + r")\b))", bygroups(Whitespace, Keyword), "soft-keywords-inner", ), ], "soft-keywords-inner": [ # optional `_` keyword (r"(\s+)([^\n_]*)(_\b)", bygroups(Whitespace, using(this), Keyword)), default("#pop"), ], "builtins": [ ( words( ( "__import__", "abs", "aiter", "all", "any", "bin", "bool", "bytearray", "breakpoint", "bytes", "callable", "chr", "classmethod", "compile", "complex", "delattr", "dict", "dir", "divmod", "enumerate", "eval", "filter", "float", "format", "frozenset", "getattr", "globals", "hasattr", "hash", "hex", "id", "input", "int", "isinstance", "issubclass", "iter", "len", "list", "locals", "map", "max", "memoryview", "min", "next", "object", "oct", "open", "ord", "pow", "print", "property", "range", "repr", "reversed", "round", "set", "setattr", "slice", "sorted", "staticmethod", "str", "sum", "super", "tuple", "type", "vars", "zip", # Mojo builtin types: https://docs.modular.com/mojo/stdlib/builtin/ "AnyType", "Coroutine", "DType", "Error", "Int", "List", "ListLiteral", "Scalar", "Int8", "UInt8", "Int16", "UInt16", "Int32", "UInt32", "Int64", "UInt64", "BFloat16", "Float16", "Float32", "Float64", "SIMD", "String", "Tensor", "Tuple", "Movable", "Copyable", "CollectionElement", ), prefix=r"(?<!\.)", suffix=r"\b", ), Name.Builtin, ), (r"(?<!\.)(self|Ellipsis|NotImplemented|cls)\b", Name.Builtin.Pseudo), ( words( ("Error",), prefix=r"(?<!\.)", suffix=r"\b", ), Name.Exception, ), ], "magicfuncs": [ ( words( ( "__abs__", "__add__", "__aenter__", "__aexit__", "__aiter__", "__and__", "__anext__", "__await__", "__bool__", "__bytes__", "__call__", "__complex__", "__contains__", "__del__", "__delattr__", "__delete__", "__delitem__", "__dir__", "__divmod__", "__enter__", "__eq__", "__exit__", "__float__", "__floordiv__", "__format__", "__ge__", "__get__", "__getattr__", "__getattribute__", "__getitem__", "__gt__", "__hash__", "__iadd__", "__iand__", "__ifloordiv__", "__ilshift__", "__imatmul__", "__imod__", "__imul__", "__index__", "__init__", "__instancecheck__", "__int__", "__invert__", "__ior__", "__ipow__", "__irshift__", "__isub__", "__iter__", "__itruediv__", "__ixor__", "__le__", "__len__", "__length_hint__", "__lshift__", "__lt__", "__matmul__", "__missing__", "__mod__", "__mul__", "__ne__", "__neg__", "__new__", "__next__", "__or__", "__pos__", "__pow__", "__prepare__", "__radd__", "__rand__", "__rdivmod__", "__repr__", "__reversed__", "__rfloordiv__", "__rlshift__", "__rmatmul__", "__rmod__", "__rmul__", "__ror__", "__round__", "__rpow__", "__rrshift__", "__rshift__", "__rsub__", "__rtruediv__", "__rxor__", "__set__", "__setattr__", "__setitem__", "__str__", "__sub__", "__subclasscheck__", "__truediv__", "__xor__", ), suffix=r"\b", ), Name.Function.Magic, ), ], "magicvars": [ ( words( ( "__annotations__", "__bases__", "__class__", "__closure__", "__code__", "__defaults__", "__dict__", "__doc__", "__file__", "__func__", "__globals__", "__kwdefaults__", "__module__", "__mro__", "__name__", "__objclass__", "__qualname__", "__self__", "__slots__", "__weakref__", ), suffix=r"\b", ), Name.Variable.Magic, ), ], "numbers": [ ( r"(\d(?:_?\d)*\.(?:\d(?:_?\d)*)?|(?:\d(?:_?\d)*)?\.\d(?:_?\d)*)" r"([eE][+-]?\d(?:_?\d)*)?", Number.Float, ), (r"\d(?:_?\d)*[eE][+-]?\d(?:_?\d)*j?", Number.Float), (r"0[oO](?:_?[0-7])+", Number.Oct), (r"0[bB](?:_?[01])+", Number.Bin), (r"0[xX](?:_?[a-fA-F0-9])+", Number.Hex), (r"\d(?:_?\d)*", Number.Integer), ], "name": [ (r"@" + uni_name, Name.Decorator), (r"@", Operator), # new matrix multiplication operator (uni_name, Name), ], "varname": [ (uni_name, Name.Variable, "#pop"), ], "funcname": [ include("magicfuncs"), (uni_name, Name.Function, "#pop"), default("#pop"), ], "classname": [ (uni_name, Name.Class, "#pop"), ], "structname": [ (uni_name, Name.Struct, "#pop"), ], "import": [ (r"(\s+)(as)(\s+)", bygroups(Whitespace, Keyword, Whitespace)), (r"\.", Name.Namespace), (uni_name, Name.Namespace), (r"(\s*)(,)(\s*)", bygroups(Whitespace, Operator, Whitespace)), default("#pop"), # all else: go back ], "fromimport": [ (r"(\s+)(import)\b", bygroups(Whitespace, Keyword.Namespace), "#pop"), (r"\.", Name.Namespace), # if None occurs here, it's "raise x from None", since None can # never be a module name (r"None\b", Keyword.Constant, "#pop"), (uni_name, Name.Namespace), default("#pop"), ], "rfstringescape": [ (r"\{\{", String.Escape), (r"\}\}", String.Escape), ], "fstringescape": [ include("rfstringescape"), include("stringescape"), ], "bytesescape": [ (r'\\([\\abfnrtv"\']|\n|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape) ], "stringescape": [ (r"\\(N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8})", String.Escape), include("bytesescape"), ], "fstrings-single": fstring_rules(String.Single), "fstrings-double": fstring_rules(String.Double), "strings-single": innerstring_rules(String.Single), "strings-double": innerstring_rules(String.Double), "dqf": [ (r'"', String.Double, "#pop"), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings include("fstrings-double"), ], "sqf": [ (r"'", String.Single, "#pop"), (r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings include("fstrings-single"), ], "dqs": [ (r'"', String.Double, "#pop"), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings include("strings-double"), ], "sqs": [ (r"'", String.Single, "#pop"), (r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings include("strings-single"), ], "tdqf": [ (r'"""', String.Double, "#pop"), include("fstrings-double"), (r"\n", String.Double), ], "tsqf": [ (r"'''", String.Single, "#pop"), include("fstrings-single"), (r"\n", String.Single), ], "tdqs": [ (r'"""', String.Double, "#pop"), include("strings-double"), (r"\n", String.Double), ], "tsqs": [ (r"'''", String.Single, "#pop"), include("strings-single"), (r"\n", String.Single), ], }
def analyse_text(text): # TODO supported? if shebang_matches(text, r"mojo?"): return 1.0 if "import " in text[:1000]: return 0.9 return 0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203""" pygments.lexers.monte ~~~~~~~~~~~~~~~~~~~~~
Lexer for the Monte programming language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.token import Comment, Error, Keyword, Name, Number, Operator, \ Punctuation, String, Whitespacefrom pygments.lexer import RegexLexer, include, words
__all__ = ['MonteLexer']
# `var` handled separately# `interface` handled separately_declarations = ['bind', 'def', 'fn', 'object']_methods = ['method', 'to']_keywords = [ 'as', 'break', 'catch', 'continue', 'else', 'escape', 'exit', 'exports', 'extends', 'finally', 'for', 'guards', 'if', 'implements', 'import', 'in', 'match', 'meta', 'pass', 'return', 'switch', 'try', 'via', 'when', 'while',]_operators = [ # Unary '~', '!', # Binary '+', '-', '*', '/', '%', '**', '&', '|', '^', '<<', '>>', # Binary augmented '+=', '-=', '*=', '/=', '%=', '**=', '&=', '|=', '^=', '<<=', '>>=', # Comparison '==', '!=', '<', '<=', '>', '>=', '<=>', # Patterns and assignment ':=', '?', '=~', '!~', '=>', # Calls and sends '.', '<-', '->',]_escape_pattern = ( r'(?:\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|' r'\\["\'\\bftnr])')# _char = _escape_chars + [('.', String.Char)]_identifier = r'[_a-zA-Z]\w*'
_constants = [ # Void constants 'null', # Bool constants 'false', 'true', # Double constants 'Infinity', 'NaN', # Special objects 'M', 'Ref', 'throw', 'traceln',]
_guards = [ 'Any', 'Binding', 'Bool', 'Bytes', 'Char', 'DeepFrozen', 'Double', 'Empty', 'Int', 'List', 'Map', 'Near', 'NullOk', 'Same', 'Selfless', 'Set', 'Str', 'SubrangeGuard', 'Transparent', 'Void',]
_safeScope = [ '_accumulateList', '_accumulateMap', '_auditedBy', '_bind', '_booleanFlow', '_comparer', '_equalizer', '_iterForever', '_loop', '_makeBytes', '_makeDouble', '_makeFinalSlot', '_makeInt', '_makeList', '_makeMap', '_makeMessageDesc', '_makeOrderedSpace', '_makeParamDesc', '_makeProtocolDesc', '_makeSourceSpan', '_makeString', '_makeVarSlot', '_makeVerbFacet', '_mapExtract', '_matchSame', '_quasiMatcher', '_slotToBinding', '_splitList', '_suchThat', '_switchFailed', '_validateFor', 'b__quasiParser', 'eval', 'import', 'm__quasiParser', 'makeBrandPair', 'makeLazySlot', 'safeScope', 'simple__quasiParser',]
class MonteLexer(RegexLexer): """ Lexer for the Monte programming language. """ name = 'Monte' url = 'https://monte.readthedocs.io/' aliases = ['monte'] filenames = ['*.mt'] version_added = '2.2'
tokens = { 'root': [ # Comments (r'#[^\n]*\n', Comment),
# Docstrings # Apologies for the non-greedy matcher here. (r'/\*\*.*?\*/', String.Doc),
# `var` declarations (r'\bvar\b', Keyword.Declaration, 'var'),
# `interface` declarations (r'\binterface\b', Keyword.Declaration, 'interface'),
# method declarations (words(_methods, prefix='\\b', suffix='\\b'), Keyword, 'method'),
# All other declarations (words(_declarations, prefix='\\b', suffix='\\b'), Keyword.Declaration),
# Keywords (words(_keywords, prefix='\\b', suffix='\\b'), Keyword),
# Literals ('[+-]?0x[_0-9a-fA-F]+', Number.Hex), (r'[+-]?[_0-9]+\.[_0-9]*([eE][+-]?[_0-9]+)?', Number.Float), ('[+-]?[_0-9]+', Number.Integer), ("'", String.Double, 'char'), ('"', String.Double, 'string'),
# Quasiliterals ('`', String.Backtick, 'ql'),
# Operators (words(_operators), Operator),
# Verb operators (_identifier + '=', Operator.Word),
# Safe scope constants (words(_constants, prefix='\\b', suffix='\\b'), Keyword.Pseudo),
# Safe scope guards (words(_guards, prefix='\\b', suffix='\\b'), Keyword.Type),
# All other safe scope names (words(_safeScope, prefix='\\b', suffix='\\b'), Name.Builtin),
# Identifiers (_identifier, Name),
# Punctuation (r'\(|\)|\{|\}|\[|\]|:|,', Punctuation),
# Whitespace (' +', Whitespace),
# Definite lexer errors ('=', Error), ], 'char': [ # It is definitely an error to have a char of width == 0. ("'", Error, 'root'), (_escape_pattern, String.Escape, 'charEnd'), ('.', String.Char, 'charEnd'), ], 'charEnd': [ ("'", String.Char, '#pop:2'), # It is definitely an error to have a char of width > 1. ('.', Error), ], # The state of things coming into an interface. 'interface': [ (' +', Whitespace), (_identifier, Name.Class, '#pop'), include('root'), ], # The state of things coming into a method. 'method': [ (' +', Whitespace), (_identifier, Name.Function, '#pop'), include('root'), ], 'string': [ ('"', String.Double, 'root'), (_escape_pattern, String.Escape), (r'\n', String.Double), ('.', String.Double), ], 'ql': [ ('`', String.Backtick, 'root'), (r'\$' + _escape_pattern, String.Escape), (r'\$\$', String.Escape), (r'@@', String.Escape), (r'\$\{', String.Interpol, 'qlNest'), (r'@\{', String.Interpol, 'qlNest'), (r'\$' + _identifier, Name), ('@' + _identifier, Name), ('.', String.Backtick), ], 'qlNest': [ (r'\}', String.Interpol, '#pop'), include('root'), ], # The state of things immediately following `var`. 'var': [ (' +', Whitespace), (_identifier, Name.Variable, '#pop'), include('root'), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447""" pygments.lexers.mosel ~~~~~~~~~~~~~~~~~~~~~
Lexers for the mosel language. http://www.fico.com/en/products/fico-xpress-optimization
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, wordsfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation
__all__ = ['MoselLexer']
FUNCTIONS = ( # core functions '_', 'abs', 'arctan', 'asproc', 'assert', 'bitflip', 'bitneg', 'bitset', 'bitshift', 'bittest', 'bitval', 'ceil', 'cos', 'create', 'currentdate', 'currenttime', 'cutelt', 'cutfirst', 'cuthead', 'cutlast', 'cuttail', 'datablock', 'delcell', 'exists', 'exit', 'exp', 'exportprob', 'fclose', 'fflush', 'finalize', 'findfirst', 'findlast', 'floor', 'fopen', 'fselect', 'fskipline', 'fwrite', 'fwrite_', 'fwriteln', 'fwriteln_', 'getact', 'getcoeff', 'getcoeffs', 'getdual', 'getelt', 'getfid', 'getfirst', 'getfname', 'gethead', 'getlast', 'getobjval', 'getparam', 'getrcost', 'getreadcnt', 'getreverse', 'getsize', 'getslack', 'getsol', 'gettail', 'gettype', 'getvars', 'isdynamic', 'iseof', 'isfinite', 'ishidden', 'isinf', 'isnan', 'isodd', 'ln', 'localsetparam', 'log', 'makesos1', 'makesos2', 'maxlist', 'memoryuse', 'minlist', 'newmuid', 'publish', 'random', 'read', 'readln', 'reset', 'restoreparam', 'reverse', 'round', 'setcoeff', 'sethidden', 'setioerr', 'setmatherr', 'setname', 'setparam', 'setrandseed', 'setrange', 'settype', 'sin', 'splithead', 'splittail', 'sqrt', 'strfmt', 'substr', 'timestamp', 'unpublish', 'versionnum', 'versionstr', 'write', 'write_', 'writeln', 'writeln_',
# mosel exam mmxprs | sed -n -e "s/ [pf][a-z]* \([a-zA-Z0-9_]*\).*/'\1',/p" | sort -u 'addcut', 'addcuts', 'addmipsol', 'basisstability', 'calcsolinfo', 'clearmipdir', 'clearmodcut', 'command', 'copysoltoinit', 'crossoverlpsol', 'defdelayedrows', 'defsecurevecs', 'delcuts', 'dropcuts', 'estimatemarginals', 'fixglobal', 'flushmsgq', 'getbstat', 'getcnlist', 'getcplist', 'getdualray', 'getiis', 'getiissense', 'getiistype', 'getinfcause', 'getinfeas', 'getlb', 'getlct', 'getleft', 'getloadedlinctrs', 'getloadedmpvars', 'getname', 'getprimalray', 'getprobstat', 'getrange', 'getright', 'getsensrng', 'getsize', 'getsol', 'gettype', 'getub', 'getvars', 'gety', 'hasfeature', 'implies', 'indicator', 'initglobal', 'ishidden', 'isiisvalid', 'isintegral', 'loadbasis', 'loadcuts', 'loadlpsol', 'loadmipsol', 'loadprob', 'maximise', 'maximize', 'minimise', 'minimize', 'postsolve', 'readbasis', 'readdirs', 'readsol', 'refinemipsol', 'rejectintsol', 'repairinfeas', 'repairinfeas_deprec', 'resetbasis', 'resetiis', 'resetsol', 'savebasis', 'savemipsol', 'savesol', 'savestate', 'selectsol', 'setarchconsistency', 'setbstat', 'setcallback', 'setcbcutoff', 'setgndata', 'sethidden', 'setlb', 'setmipdir', 'setmodcut', 'setsol', 'setub', 'setucbdata', 'stopoptimise', 'stopoptimize', 'storecut', 'storecuts', 'unloadprob', 'uselastbarsol', 'writebasis', 'writedirs', 'writeprob', 'writesol', 'xor', 'xprs_addctr', 'xprs_addindic',
# mosel exam mmsystem | sed -n -e "s/ [pf][a-z]* \([a-zA-Z0-9_]*\).*/'\1',/p" | sort -u 'addmonths', 'copytext', 'cuttext', 'deltext', 'endswith', 'erase', 'expandpath', 'fcopy', 'fdelete', 'findfiles', 'findtext', 'fmove', 'formattext', 'getasnumber', 'getchar', 'getcwd', 'getdate', 'getday', 'getdaynum', 'getdays', 'getdirsep', 'getdsoparam', 'getendparse', 'getenv', 'getfsize', 'getfstat', 'getftime', 'gethour', 'getminute', 'getmonth', 'getmsec', 'getoserrmsg', 'getoserror', 'getpathsep', 'getqtype', 'getsecond', 'getsepchar', 'getsize', 'getstart', 'getsucc', 'getsysinfo', 'getsysstat', 'gettime', 'gettmpdir', 'gettrim', 'getweekday', 'getyear', 'inserttext', 'isvalid', 'jointext', 'makedir', 'makepath', 'newtar', 'newzip', 'nextfield', 'openpipe', 'parseextn', 'parseint', 'parsereal', 'parsetext', 'pastetext', 'pathmatch', 'pathsplit', 'qsort', 'quote', 'readtextline', 'regmatch', 'regreplace', 'removedir', 'removefiles', 'setchar', 'setdate', 'setday', 'setdsoparam', 'setendparse', 'setenv', 'sethour', 'setminute', 'setmonth', 'setmsec', 'setoserror', 'setqtype', 'setsecond', 'setsepchar', 'setstart', 'setsucc', 'settime', 'settrim', 'setyear', 'sleep', 'splittext', 'startswith', 'system', 'tarlist', 'textfmt', 'tolower', 'toupper', 'trim', 'untar', 'unzip', 'ziplist',
# mosel exam mmjobs | sed -n -e "s/ [pf][a-z]* \([a-zA-Z0-9_]*\).*/'\1',/p" | sort -u 'canceltimer', 'clearaliases', 'compile', 'connect', 'detach', 'disconnect', 'dropnextevent', 'findxsrvs', 'getaliases', 'getannidents', 'getannotations', 'getbanner', 'getclass', 'getdsoprop', 'getdsopropnum', 'getexitcode', 'getfromgid', 'getfromid', 'getfromuid', 'getgid', 'gethostalias', 'getid', 'getmodprop', 'getmodpropnum', 'getnextevent', 'getnode', 'getrmtid', 'getstatus', 'getsysinfo', 'gettimer', 'getuid', 'getvalue', 'isqueueempty', 'load', 'nullevent', 'peeknextevent', 'resetmodpar', 'run', 'send', 'setcontrol', 'setdefstream', 'setgid', 'sethostalias', 'setmodpar', 'settimer', 'setuid', 'setworkdir', 'stop', 'unload', 'wait', 'waitexpired', 'waitfor', 'waitforend',)
class MoselLexer(RegexLexer): """ For the Mosel optimization language. """ name = 'Mosel' aliases = ['mosel'] filenames = ['*.mos'] url = 'https://www.fico.com/fico-xpress-optimization/docs/latest/mosel/mosel_lang/dhtml/moselreflang.html' version_added = '2.6'
tokens = { 'root': [ (r'\n', Text), (r'\s+', Text.Whitespace), (r'!.*?\n', Comment.Single), (r'\(!(.|\n)*?!\)', Comment.Multiline), (words(( 'and', 'as', 'break', 'case', 'count', 'declarations', 'do', 'dynamic', 'elif', 'else', 'end-', 'end', 'evaluation', 'false', 'forall', 'forward', 'from', 'function', 'hashmap', 'if', 'imports', 'include', 'initialisations', 'initializations', 'inter', 'max', 'min', 'model', 'namespace', 'next', 'not', 'nsgroup', 'nssearch', 'of', 'options', 'or', 'package', 'parameters', 'procedure', 'public', 'prod', 'record', 'repeat', 'requirements', 'return', 'sum', 'then', 'to', 'true', 'union', 'until', 'uses', 'version', 'while', 'with'), prefix=r'\b', suffix=r'\b'), Keyword.Builtin), (words(( 'range', 'array', 'set', 'list', 'mpvar', 'mpproblem', 'linctr', 'nlctr', 'integer', 'string', 'real', 'boolean', 'text', 'time', 'date', 'datetime', 'returned', 'Model', 'Mosel', 'counter', 'xmldoc', 'is_sos1', 'is_sos2', 'is_integer', 'is_binary', 'is_continuous', 'is_free', 'is_semcont', 'is_semint', 'is_partint'), prefix=r'\b', suffix=r'\b'), Keyword.Type), (r'(\+|\-|\*|/|=|<=|>=|\||\^|<|>|<>|\.\.|\.|:=|::|:|in|mod|div)', Operator), (r'[()\[\]{},;]+', Punctuation), (words(FUNCTIONS, prefix=r'\b', suffix=r'\b'), Name.Function), (r'(\d+\.(?!\.)\d*|\.(?!.)\d+)([eE][+-]?\d+)?', Number.Float), (r'\d+([eE][+-]?\d+)?', Number.Integer), (r'[+-]?Infinity', Number.Integer), (r'0[xX][0-9a-fA-F]+', Number), (r'"', String.Double, 'double_quote'), (r'\'', String.Single, 'single_quote'), (r'(\w+|(\.(?!\.)))', Text), ], 'single_quote': [ (r'\'', String.Single, '#pop'), (r'[^\']+', String.Single), ], 'double_quote': [ (r'(\\"|\\[0-7]{1,3}\D|\\[abfnrtv]|\\\\)', String.Escape), (r'\"', String.Double, '#pop'), (r'[^"\\]+', String.Double), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894""" pygments.lexers.ncl ~~~~~~~~~~~~~~~~~~~
Lexers for NCAR Command Language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, include, wordsfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation
__all__ = ['NCLLexer']
class NCLLexer(RegexLexer): """ Lexer for NCL code. """ name = 'NCL' aliases = ['ncl'] filenames = ['*.ncl'] mimetypes = ['text/ncl'] url = 'https://www.ncl.ucar.edu' version_added = '2.2'
flags = re.MULTILINE
tokens = { 'root': [ (r';.*\n', Comment), include('strings'), include('core'), (r'[a-zA-Z_]\w*', Name), include('nums'), (r'[\s]+', Text), ], 'core': [ # Statements (words(( 'begin', 'break', 'continue', 'create', 'defaultapp', 'do', 'else', 'end', 'external', 'exit', 'True', 'False', 'file', 'function', 'getvalues', 'graphic', 'group', 'if', 'list', 'load', 'local', 'new', '_Missing', 'Missing', 'noparent', 'procedure', 'quit', 'QUIT', 'Quit', 'record', 'return', 'setvalues', 'stop', 'then', 'while'), prefix=r'\b', suffix=r'\s*\b'), Keyword),
# Data Types (words(( 'ubyte', 'uint', 'uint64', 'ulong', 'string', 'byte', 'character', 'double', 'float', 'integer', 'int64', 'logical', 'long', 'short', 'ushort', 'enumeric', 'numeric', 'snumeric'), prefix=r'\b', suffix=r'\s*\b'), Keyword.Type),
# Operators (r'[\%^*+\-/<>]', Operator),
# punctuation: (r'[\[\]():@$!&|.,\\{}]', Punctuation), (r'[=:]', Punctuation),
# Intrinsics (words(( 'abs', 'acos', 'addfile', 'addfiles', 'all', 'angmom_atm', 'any', 'area_conserve_remap', 'area_hi2lores', 'area_poly_sphere', 'asciiread', 'asciiwrite', 'asin', 'atan', 'atan2', 'attsetvalues', 'avg', 'betainc', 'bin_avg', 'bin_sum', 'bw_bandpass_filter', 'cancor', 'cbinread', 'cbinwrite', 'cd_calendar', 'cd_inv_calendar', 'cdfbin_p', 'cdfbin_pr', 'cdfbin_s', 'cdfbin_xn', 'cdfchi_p', 'cdfchi_x', 'cdfgam_p', 'cdfgam_x', 'cdfnor_p', 'cdfnor_x', 'cdft_p', 'cdft_t', 'ceil', 'center_finite_diff', 'center_finite_diff_n', 'cfftb', 'cfftf', 'cfftf_frq_reorder', 'charactertodouble', 'charactertofloat', 'charactertointeger', 'charactertolong', 'charactertoshort', 'charactertostring', 'chartodouble', 'chartofloat', 'chartoint', 'chartointeger', 'chartolong', 'chartoshort', 'chartostring', 'chiinv', 'clear', 'color_index_to_rgba', 'conform', 'conform_dims', 'cos', 'cosh', 'count_unique_values', 'covcorm', 'covcorm_xy', 'craybinnumrec', 'craybinrecread', 'create_graphic', 'csa1', 'csa1d', 'csa1s', 'csa1x', 'csa1xd', 'csa1xs', 'csa2', 'csa2d', 'csa2l', 'csa2ld', 'csa2ls', 'csa2lx', 'csa2lxd', 'csa2lxs', 'csa2s', 'csa2x', 'csa2xd', 'csa2xs', 'csa3', 'csa3d', 'csa3l', 'csa3ld', 'csa3ls', 'csa3lx', 'csa3lxd', 'csa3lxs', 'csa3s', 'csa3x', 'csa3xd', 'csa3xs', 'csc2s', 'csgetp', 'css2c', 'cssetp', 'cssgrid', 'csstri', 'csvoro', 'cumsum', 'cz2ccm', 'datatondc', 'day_of_week', 'day_of_year', 'days_in_month', 'default_fillvalue', 'delete', 'depth_to_pres', 'destroy', 'determinant', 'dewtemp_trh', 'dgeevx_lapack', 'dim_acumrun_n', 'dim_avg', 'dim_avg_n', 'dim_avg_wgt', 'dim_avg_wgt_n', 'dim_cumsum', 'dim_cumsum_n', 'dim_gamfit_n', 'dim_gbits', 'dim_max', 'dim_max_n', 'dim_median', 'dim_median_n', 'dim_min', 'dim_min_n', 'dim_num', 'dim_num_n', 'dim_numrun_n', 'dim_pqsort', 'dim_pqsort_n', 'dim_product', 'dim_product_n', 'dim_rmsd', 'dim_rmsd_n', 'dim_rmvmean', 'dim_rmvmean_n', 'dim_rmvmed', 'dim_rmvmed_n', 'dim_spi_n', 'dim_standardize', 'dim_standardize_n', 'dim_stat4', 'dim_stat4_n', 'dim_stddev', 'dim_stddev_n', 'dim_sum', 'dim_sum_n', 'dim_sum_wgt', 'dim_sum_wgt_n', 'dim_variance', 'dim_variance_n', 'dimsizes', 'doubletobyte', 'doubletochar', 'doubletocharacter', 'doubletofloat', 'doubletoint', 'doubletointeger', 'doubletolong', 'doubletoshort', 'dpres_hybrid_ccm', 'dpres_plevel', 'draw', 'draw_color_palette', 'dsgetp', 'dsgrid2', 'dsgrid2d', 'dsgrid2s', 'dsgrid3', 'dsgrid3d', 'dsgrid3s', 'dspnt2', 'dspnt2d', 'dspnt2s', 'dspnt3', 'dspnt3d', 'dspnt3s', 'dssetp', 'dtrend', 'dtrend_msg', 'dtrend_msg_n', 'dtrend_n', 'dtrend_quadratic', 'dtrend_quadratic_msg_n', 'dv2uvf', 'dv2uvg', 'dz_height', 'echo_off', 'echo_on', 'eof2data', 'eof_varimax', 'eofcor', 'eofcor_pcmsg', 'eofcor_ts', 'eofcov', 'eofcov_pcmsg', 'eofcov_ts', 'eofunc', 'eofunc_ts', 'eofunc_varimax', 'equiv_sample_size', 'erf', 'erfc', 'esacr', 'esacv', 'esccr', 'esccv', 'escorc', 'escorc_n', 'escovc', 'exit', 'exp', 'exp_tapersh', 'exp_tapersh_wgts', 'exp_tapershC', 'ezfftb', 'ezfftb_n', 'ezfftf', 'ezfftf_n', 'f2fosh', 'f2foshv', 'f2fsh', 'f2fshv', 'f2gsh', 'f2gshv', 'fabs', 'fbindirread', 'fbindirwrite', 'fbinnumrec', 'fbinread', 'fbinrecread', 'fbinrecwrite', 'fbinwrite', 'fft2db', 'fft2df', 'fftshift', 'fileattdef', 'filechunkdimdef', 'filedimdef', 'fileexists', 'filegrpdef', 'filevarattdef', 'filevarchunkdef', 'filevarcompressleveldef', 'filevardef', 'filevardimsizes', 'filwgts_lancos', 'filwgts_lanczos', 'filwgts_normal', 'floattobyte', 'floattochar', 'floattocharacter', 'floattoint', 'floattointeger', 'floattolong', 'floattoshort', 'floor', 'fluxEddy', 'fo2fsh', 'fo2fshv', 'fourier_info', 'frame', 'fspan', 'ftcurv', 'ftcurvd', 'ftcurvi', 'ftcurvp', 'ftcurvpi', 'ftcurvps', 'ftcurvs', 'ftest', 'ftgetp', 'ftkurv', 'ftkurvd', 'ftkurvp', 'ftkurvpd', 'ftsetp', 'ftsurf', 'g2fsh', 'g2fshv', 'g2gsh', 'g2gshv', 'gamma', 'gammainc', 'gaus', 'gaus_lobat', 'gaus_lobat_wgt', 'gc_aangle', 'gc_clkwise', 'gc_dangle', 'gc_inout', 'gc_latlon', 'gc_onarc', 'gc_pnt2gc', 'gc_qarea', 'gc_tarea', 'generate_2d_array', 'get_color_index', 'get_color_rgba', 'get_cpu_time', 'get_isolines', 'get_ncl_version', 'get_script_name', 'get_script_prefix_name', 'get_sphere_radius', 'get_unique_values', 'getbitsone', 'getenv', 'getfiledimsizes', 'getfilegrpnames', 'getfilepath', 'getfilevaratts', 'getfilevarchunkdimsizes', 'getfilevardims', 'getfilevardimsizes', 'getfilevarnames', 'getfilevartypes', 'getvaratts', 'getvardims', 'gradsf', 'gradsg', 'greg2jul', 'grid2triple', 'hlsrgb', 'hsvrgb', 'hydro', 'hyi2hyo', 'idsfft', 'igradsf', 'igradsg', 'ilapsf', 'ilapsg', 'ilapvf', 'ilapvg', 'ind', 'ind_resolve', 'int2p', 'int2p_n', 'integertobyte', 'integertochar', 'integertocharacter', 'integertoshort', 'inttobyte', 'inttochar', 'inttoshort', 'inverse_matrix', 'isatt', 'isbigendian', 'isbyte', 'ischar', 'iscoord', 'isdefined', 'isdim', 'isdimnamed', 'isdouble', 'isenumeric', 'isfile', 'isfilepresent', 'isfilevar', 'isfilevaratt', 'isfilevarcoord', 'isfilevardim', 'isfloat', 'isfunc', 'isgraphic', 'isint', 'isint64', 'isinteger', 'isleapyear', 'islogical', 'islong', 'ismissing', 'isnan_ieee', 'isnumeric', 'ispan', 'isproc', 'isshort', 'issnumeric', 'isstring', 'isubyte', 'isuint', 'isuint64', 'isulong', 'isunlimited', 'isunsigned', 'isushort', 'isvar', 'jul2greg', 'kmeans_as136', 'kolsm2_n', 'kron_product', 'lapsf', 'lapsg', 'lapvf', 'lapvg', 'latlon2utm', 'lclvl', 'lderuvf', 'lderuvg', 'linint1', 'linint1_n', 'linint2', 'linint2_points', 'linmsg', 'linmsg_n', 'linrood_latwgt', 'linrood_wgt', 'list_files', 'list_filevars', 'list_hlus', 'list_procfuncs', 'list_vars', 'ListAppend', 'ListCount', 'ListGetType', 'ListIndex', 'ListIndexFromName', 'ListPop', 'ListPush', 'ListSetType', 'loadscript', 'local_max', 'local_min', 'log', 'log10', 'longtobyte', 'longtochar', 'longtocharacter', 'longtoint', 'longtointeger', 'longtoshort', 'lspoly', 'lspoly_n', 'mask', 'max', 'maxind', 'min', 'minind', 'mixed_layer_depth', 'mixhum_ptd', 'mixhum_ptrh', 'mjo_cross_coh2pha', 'mjo_cross_segment', 'moc_globe_atl', 'monthday', 'natgrid', 'natgridd', 'natgrids', 'ncargpath', 'ncargversion', 'ndctodata', 'ndtooned', 'new', 'NewList', 'ngezlogo', 'nggcog', 'nggetp', 'nglogo', 'ngsetp', 'NhlAddAnnotation', 'NhlAddData', 'NhlAddOverlay', 'NhlAddPrimitive', 'NhlAppGetDefaultParentId', 'NhlChangeWorkstation', 'NhlClassName', 'NhlClearWorkstation', 'NhlDataPolygon', 'NhlDataPolyline', 'NhlDataPolymarker', 'NhlDataToNDC', 'NhlDestroy', 'NhlDraw', 'NhlFrame', 'NhlFreeColor', 'NhlGetBB', 'NhlGetClassResources', 'NhlGetErrorObjectId', 'NhlGetNamedColorIndex', 'NhlGetParentId', 'NhlGetParentWorkstation', 'NhlGetWorkspaceObjectId', 'NhlIsAllocatedColor', 'NhlIsApp', 'NhlIsDataComm', 'NhlIsDataItem', 'NhlIsDataSpec', 'NhlIsTransform', 'NhlIsView', 'NhlIsWorkstation', 'NhlName', 'NhlNDCPolygon', 'NhlNDCPolyline', 'NhlNDCPolymarker', 'NhlNDCToData', 'NhlNewColor', 'NhlNewDashPattern', 'NhlNewMarker', 'NhlPalGetDefined', 'NhlRemoveAnnotation', 'NhlRemoveData', 'NhlRemoveOverlay', 'NhlRemovePrimitive', 'NhlSetColor', 'NhlSetDashPattern', 'NhlSetMarker', 'NhlUpdateData', 'NhlUpdateWorkstation', 'nice_mnmxintvl', 'nngetaspectd', 'nngetaspects', 'nngetp', 'nngetsloped', 'nngetslopes', 'nngetwts', 'nngetwtsd', 'nnpnt', 'nnpntd', 'nnpntend', 'nnpntendd', 'nnpntinit', 'nnpntinitd', 'nnpntinits', 'nnpnts', 'nnsetp', 'num', 'obj_anal_ic', 'omega_ccm', 'onedtond', 'overlay', 'paleo_outline', 'pdfxy_bin', 'poisson_grid_fill', 'pop_remap', 'potmp_insitu_ocn', 'prcwater_dp', 'pres2hybrid', 'pres_hybrid_ccm', 'pres_sigma', 'print', 'print_table', 'printFileVarSummary', 'printVarSummary', 'product', 'pslec', 'pslhor', 'pslhyp', 'qsort', 'rand', 'random_chi', 'random_gamma', 'random_normal', 'random_setallseed', 'random_uniform', 'rcm2points', 'rcm2rgrid', 'rdsstoi', 'read_colormap_file', 'reg_multlin', 'regcoef', 'regCoef_n', 'regline', 'relhum', 'replace_ieeenan', 'reshape', 'reshape_ind', 'rgba_to_color_index', 'rgbhls', 'rgbhsv', 'rgbyiq', 'rgrid2rcm', 'rhomb_trunc', 'rip_cape_2d', 'rip_cape_3d', 'round', 'rtest', 'runave', 'runave_n', 'set_default_fillvalue', 'set_sphere_radius', 'setfileoption', 'sfvp2uvf', 'sfvp2uvg', 'shaec', 'shagc', 'shgetnp', 'shgetp', 'shgrid', 'shorttobyte', 'shorttochar', 'shorttocharacter', 'show_ascii', 'shsec', 'shsetp', 'shsgc', 'shsgc_R42', 'sigma2hybrid', 'simpeq', 'simpne', 'sin', 'sindex_yrmo', 'sinh', 'sizeof', 'sleep', 'smth9', 'snindex_yrmo', 'solve_linsys', 'span_color_indexes', 'span_color_rgba', 'sparse_matrix_mult', 'spcorr', 'spcorr_n', 'specx_anal', 'specxy_anal', 'spei', 'sprintf', 'sprinti', 'sqrt', 'sqsort', 'srand', 'stat2', 'stat4', 'stat_medrng', 'stat_trim', 'status_exit', 'stdatmus_p2tdz', 'stdatmus_z2tdp', 'stddev', 'str_capital', 'str_concat', 'str_fields_count', 'str_get_cols', 'str_get_dq', 'str_get_field', 'str_get_nl', 'str_get_sq', 'str_get_tab', 'str_index_of_substr', 'str_insert', 'str_is_blank', 'str_join', 'str_left_strip', 'str_lower', 'str_match', 'str_match_ic', 'str_match_ic_regex', 'str_match_ind', 'str_match_ind_ic', 'str_match_ind_ic_regex', 'str_match_ind_regex', 'str_match_regex', 'str_right_strip', 'str_split', 'str_split_by_length', 'str_split_csv', 'str_squeeze', 'str_strip', 'str_sub_str', 'str_switch', 'str_upper', 'stringtochar', 'stringtocharacter', 'stringtodouble', 'stringtofloat', 'stringtoint', 'stringtointeger', 'stringtolong', 'stringtoshort', 'strlen', 'student_t', 'sum', 'svd_lapack', 'svdcov', 'svdcov_sv', 'svdstd', 'svdstd_sv', 'system', 'systemfunc', 'tan', 'tanh', 'taper', 'taper_n', 'tdclrs', 'tdctri', 'tdcudp', 'tdcurv', 'tddtri', 'tdez2d', 'tdez3d', 'tdgetp', 'tdgrds', 'tdgrid', 'tdgtrs', 'tdinit', 'tditri', 'tdlbla', 'tdlblp', 'tdlbls', 'tdline', 'tdlndp', 'tdlnpa', 'tdlpdp', 'tdmtri', 'tdotri', 'tdpara', 'tdplch', 'tdprpa', 'tdprpi', 'tdprpt', 'tdsetp', 'tdsort', 'tdstri', 'tdstrs', 'tdttri', 'thornthwaite', 'tobyte', 'tochar', 'todouble', 'tofloat', 'toint', 'toint64', 'tointeger', 'tolong', 'toshort', 'tosigned', 'tostring', 'tostring_with_format', 'totype', 'toubyte', 'touint', 'touint64', 'toulong', 'tounsigned', 'toushort', 'trend_manken', 'tri_trunc', 'triple2grid', 'triple2grid2d', 'trop_wmo', 'ttest', 'typeof', 'undef', 'unique_string', 'update', 'ushorttoint', 'ut_calendar', 'ut_inv_calendar', 'utm2latlon', 'uv2dv_cfd', 'uv2dvf', 'uv2dvg', 'uv2sfvpf', 'uv2sfvpg', 'uv2vr_cfd', 'uv2vrdvf', 'uv2vrdvg', 'uv2vrf', 'uv2vrg', 'v5d_close', 'v5d_create', 'v5d_setLowLev', 'v5d_setUnits', 'v5d_write', 'v5d_write_var', 'variance', 'vhaec', 'vhagc', 'vhsec', 'vhsgc', 'vibeta', 'vinth2p', 'vinth2p_ecmwf', 'vinth2p_ecmwf_nodes', 'vinth2p_nodes', 'vintp2p_ecmwf', 'vr2uvf', 'vr2uvg', 'vrdv2uvf', 'vrdv2uvg', 'wavelet', 'wavelet_default', 'weibull', 'wgt_area_smooth', 'wgt_areaave', 'wgt_areaave2', 'wgt_arearmse', 'wgt_arearmse2', 'wgt_areasum2', 'wgt_runave', 'wgt_runave_n', 'wgt_vert_avg_beta', 'wgt_volave', 'wgt_volave_ccm', 'wgt_volrmse', 'wgt_volrmse_ccm', 'where', 'wk_smooth121', 'wmbarb', 'wmbarbmap', 'wmdrft', 'wmgetp', 'wmlabs', 'wmsetp', 'wmstnm', 'wmvect', 'wmvectmap', 'wmvlbl', 'wrf_avo', 'wrf_cape_2d', 'wrf_cape_3d', 'wrf_dbz', 'wrf_eth', 'wrf_helicity', 'wrf_ij_to_ll', 'wrf_interp_1d', 'wrf_interp_2d_xy', 'wrf_interp_3d_z', 'wrf_latlon_to_ij', 'wrf_ll_to_ij', 'wrf_omega', 'wrf_pvo', 'wrf_rh', 'wrf_slp', 'wrf_smooth_2d', 'wrf_td', 'wrf_tk', 'wrf_updraft_helicity', 'wrf_uvmet', 'wrf_virtual_temp', 'wrf_wetbulb', 'wrf_wps_close_int', 'wrf_wps_open_int', 'wrf_wps_rddata_int', 'wrf_wps_rdhead_int', 'wrf_wps_read_int', 'wrf_wps_write_int', 'write_matrix', 'write_table', 'yiqrgb', 'z2geouv', 'zonal_mpsi', 'addfiles_GetVar', 'advect_variable', 'area_conserve_remap_Wrap', 'area_hi2lores_Wrap', 'array_append_record', 'assignFillValue', 'byte2flt', 'byte2flt_hdf', 'calcDayAnomTLL', 'calcMonAnomLLLT', 'calcMonAnomLLT', 'calcMonAnomTLL', 'calcMonAnomTLLL', 'calculate_monthly_values', 'cd_convert', 'changeCase', 'changeCaseChar', 'clmDayTLL', 'clmDayTLLL', 'clmMon2clmDay', 'clmMonLLLT', 'clmMonLLT', 'clmMonTLL', 'clmMonTLLL', 'closest_val', 'copy_VarAtts', 'copy_VarCoords', 'copy_VarCoords_1', 'copy_VarCoords_2', 'copy_VarMeta', 'copyatt', 'crossp3', 'cshstringtolist', 'cssgrid_Wrap', 'dble2flt', 'decimalPlaces', 'delete_VarAtts', 'dim_avg_n_Wrap', 'dim_avg_wgt_n_Wrap', 'dim_avg_wgt_Wrap', 'dim_avg_Wrap', 'dim_cumsum_n_Wrap', 'dim_cumsum_Wrap', 'dim_max_n_Wrap', 'dim_min_n_Wrap', 'dim_rmsd_n_Wrap', 'dim_rmsd_Wrap', 'dim_rmvmean_n_Wrap', 'dim_rmvmean_Wrap', 'dim_rmvmed_n_Wrap', 'dim_rmvmed_Wrap', 'dim_standardize_n_Wrap', 'dim_standardize_Wrap', 'dim_stddev_n_Wrap', 'dim_stddev_Wrap', 'dim_sum_n_Wrap', 'dim_sum_wgt_n_Wrap', 'dim_sum_wgt_Wrap', 'dim_sum_Wrap', 'dim_variance_n_Wrap', 'dim_variance_Wrap', 'dpres_plevel_Wrap', 'dtrend_leftdim', 'dv2uvF_Wrap', 'dv2uvG_Wrap', 'eof_north', 'eofcor_Wrap', 'eofcov_Wrap', 'eofunc_north', 'eofunc_ts_Wrap', 'eofunc_varimax_reorder', 'eofunc_varimax_Wrap', 'eofunc_Wrap', 'epsZero', 'f2fosh_Wrap', 'f2foshv_Wrap', 'f2fsh_Wrap', 'f2fshv_Wrap', 'f2gsh_Wrap', 'f2gshv_Wrap', 'fbindirSwap', 'fbinseqSwap1', 'fbinseqSwap2', 'flt2dble', 'flt2string', 'fo2fsh_Wrap', 'fo2fshv_Wrap', 'g2fsh_Wrap', 'g2fshv_Wrap', 'g2gsh_Wrap', 'g2gshv_Wrap', 'generate_resample_indices', 'generate_sample_indices', 'generate_unique_indices', 'genNormalDist', 'get1Dindex', 'get1Dindex_Collapse', 'get1Dindex_Exclude', 'get_file_suffix', 'GetFillColor', 'GetFillColorIndex', 'getFillValue', 'getind_latlon2d', 'getVarDimNames', 'getVarFillValue', 'grib_stime2itime', 'hyi2hyo_Wrap', 'ilapsF_Wrap', 'ilapsG_Wrap', 'ind_nearest_coord', 'indStrSubset', 'int2dble', 'int2flt', 'int2p_n_Wrap', 'int2p_Wrap', 'isMonotonic', 'isStrSubset', 'latGau', 'latGauWgt', 'latGlobeF', 'latGlobeFo', 'latRegWgt', 'linint1_n_Wrap', 'linint1_Wrap', 'linint2_points_Wrap', 'linint2_Wrap', 'local_max_1d', 'local_min_1d', 'lonFlip', 'lonGlobeF', 'lonGlobeFo', 'lonPivot', 'merge_levels_sfc', 'mod', 'month_to_annual', 'month_to_annual_weighted', 'month_to_season', 'month_to_season12', 'month_to_seasonN', 'monthly_total_to_daily_mean', 'nameDim', 'natgrid_Wrap', 'NewCosWeight', 'niceLatLon2D', 'NormCosWgtGlobe', 'numAsciiCol', 'numAsciiRow', 'numeric2int', 'obj_anal_ic_deprecated', 'obj_anal_ic_Wrap', 'omega_ccm_driver', 'omega_to_w', 'oneDtostring', 'pack_values', 'pattern_cor', 'pdfx', 'pdfxy', 'pdfxy_conform', 'pot_temp', 'pot_vort_hybrid', 'pot_vort_isobaric', 'pres2hybrid_Wrap', 'print_clock', 'printMinMax', 'quadroots', 'rcm2points_Wrap', 'rcm2rgrid_Wrap', 'readAsciiHead', 'readAsciiTable', 'reg_multlin_stats', 'region_ind', 'regline_stats', 'relhum_ttd', 'replaceSingleChar', 'RGBtoCmap', 'rgrid2rcm_Wrap', 'rho_mwjf', 'rm_single_dims', 'rmAnnCycle1D', 'rmInsufData', 'rmMonAnnCycLLLT', 'rmMonAnnCycLLT', 'rmMonAnnCycTLL', 'runave_n_Wrap', 'runave_Wrap', 'short2flt', 'short2flt_hdf', 'shsgc_R42_Wrap', 'sign_f90', 'sign_matlab', 'smth9_Wrap', 'smthClmDayTLL', 'smthClmDayTLLL', 'SqrtCosWeight', 'stat_dispersion', 'static_stability', 'stdMonLLLT', 'stdMonLLT', 'stdMonTLL', 'stdMonTLLL', 'symMinMaxPlt', 'table_attach_columns', 'table_attach_rows', 'time_to_newtime', 'transpose', 'triple2grid_Wrap', 'ut_convert', 'uv2dvF_Wrap', 'uv2dvG_Wrap', 'uv2vrF_Wrap', 'uv2vrG_Wrap', 'vr2uvF_Wrap', 'vr2uvG_Wrap', 'w_to_omega', 'wallClockElapseTime', 'wave_number_spc', 'wgt_areaave_Wrap', 'wgt_runave_leftdim', 'wgt_runave_n_Wrap', 'wgt_runave_Wrap', 'wgt_vertical_n', 'wind_component', 'wind_direction', 'yyyyddd_to_yyyymmdd', 'yyyymm_time', 'yyyymm_to_yyyyfrac', 'yyyymmdd_time', 'yyyymmdd_to_yyyyddd', 'yyyymmdd_to_yyyyfrac', 'yyyymmddhh_time', 'yyyymmddhh_to_yyyyfrac', 'zonal_mpsi_Wrap', 'zonalAve', 'calendar_decode2', 'cd_string', 'kf_filter', 'run_cor', 'time_axis_labels', 'ut_string', 'wrf_contour', 'wrf_map', 'wrf_map_overlay', 'wrf_map_overlays', 'wrf_map_resources', 'wrf_map_zoom', 'wrf_overlay', 'wrf_overlays', 'wrf_user_getvar', 'wrf_user_ij_to_ll', 'wrf_user_intrp2d', 'wrf_user_intrp3d', 'wrf_user_latlon_to_ij', 'wrf_user_list_times', 'wrf_user_ll_to_ij', 'wrf_user_unstagger', 'wrf_user_vert_interp', 'wrf_vector', 'gsn_add_annotation', 'gsn_add_polygon', 'gsn_add_polyline', 'gsn_add_polymarker', 'gsn_add_shapefile_polygons', 'gsn_add_shapefile_polylines', 'gsn_add_shapefile_polymarkers', 'gsn_add_text', 'gsn_attach_plots', 'gsn_blank_plot', 'gsn_contour', 'gsn_contour_map', 'gsn_contour_shade', 'gsn_coordinates', 'gsn_create_labelbar', 'gsn_create_legend', 'gsn_create_text', 'gsn_csm_attach_zonal_means', 'gsn_csm_blank_plot', 'gsn_csm_contour', 'gsn_csm_contour_map', 'gsn_csm_contour_map_ce', 'gsn_csm_contour_map_overlay', 'gsn_csm_contour_map_polar', 'gsn_csm_hov', 'gsn_csm_lat_time', 'gsn_csm_map', 'gsn_csm_map_ce', 'gsn_csm_map_polar', 'gsn_csm_pres_hgt', 'gsn_csm_pres_hgt_streamline', 'gsn_csm_pres_hgt_vector', 'gsn_csm_streamline', 'gsn_csm_streamline_contour_map', 'gsn_csm_streamline_contour_map_ce', 'gsn_csm_streamline_contour_map_polar', 'gsn_csm_streamline_map', 'gsn_csm_streamline_map_ce', 'gsn_csm_streamline_map_polar', 'gsn_csm_streamline_scalar', 'gsn_csm_streamline_scalar_map', 'gsn_csm_streamline_scalar_map_ce', 'gsn_csm_streamline_scalar_map_polar', 'gsn_csm_time_lat', 'gsn_csm_vector', 'gsn_csm_vector_map', 'gsn_csm_vector_map_ce', 'gsn_csm_vector_map_polar', 'gsn_csm_vector_scalar', 'gsn_csm_vector_scalar_map', 'gsn_csm_vector_scalar_map_ce', 'gsn_csm_vector_scalar_map_polar', 'gsn_csm_x2y', 'gsn_csm_x2y2', 'gsn_csm_xy', 'gsn_csm_xy2', 'gsn_csm_xy3', 'gsn_csm_y', 'gsn_define_colormap', 'gsn_draw_colormap', 'gsn_draw_named_colors', 'gsn_histogram', 'gsn_labelbar_ndc', 'gsn_legend_ndc', 'gsn_map', 'gsn_merge_colormaps', 'gsn_open_wks', 'gsn_panel', 'gsn_polygon', 'gsn_polygon_ndc', 'gsn_polyline', 'gsn_polyline_ndc', 'gsn_polymarker', 'gsn_polymarker_ndc', 'gsn_retrieve_colormap', 'gsn_reverse_colormap', 'gsn_streamline', 'gsn_streamline_map', 'gsn_streamline_scalar', 'gsn_streamline_scalar_map', 'gsn_table', 'gsn_text', 'gsn_text_ndc', 'gsn_vector', 'gsn_vector_map', 'gsn_vector_scalar', 'gsn_vector_scalar_map', 'gsn_xy', 'gsn_y', 'hsv2rgb', 'maximize_output', 'namedcolor2rgb', 'namedcolor2rgba', 'reset_device_coordinates', 'span_named_colors'), prefix=r'\b'), Name.Builtin),
# Resources (words(( 'amDataXF', 'amDataYF', 'amJust', 'amOn', 'amOrthogonalPosF', 'amParallelPosF', 'amResizeNotify', 'amSide', 'amTrackData', 'amViewId', 'amZone', 'appDefaultParent', 'appFileSuffix', 'appResources', 'appSysDir', 'appUsrDir', 'caCopyArrays', 'caXArray', 'caXCast', 'caXMaxV', 'caXMinV', 'caXMissingV', 'caYArray', 'caYCast', 'caYMaxV', 'caYMinV', 'caYMissingV', 'cnCellFillEdgeColor', 'cnCellFillMissingValEdgeColor', 'cnConpackParams', 'cnConstFEnableFill', 'cnConstFLabelAngleF', 'cnConstFLabelBackgroundColor', 'cnConstFLabelConstantSpacingF', 'cnConstFLabelFont', 'cnConstFLabelFontAspectF', 'cnConstFLabelFontColor', 'cnConstFLabelFontHeightF', 'cnConstFLabelFontQuality', 'cnConstFLabelFontThicknessF', 'cnConstFLabelFormat', 'cnConstFLabelFuncCode', 'cnConstFLabelJust', 'cnConstFLabelOn', 'cnConstFLabelOrthogonalPosF', 'cnConstFLabelParallelPosF', 'cnConstFLabelPerimColor', 'cnConstFLabelPerimOn', 'cnConstFLabelPerimSpaceF', 'cnConstFLabelPerimThicknessF', 'cnConstFLabelSide', 'cnConstFLabelString', 'cnConstFLabelTextDirection', 'cnConstFLabelZone', 'cnConstFUseInfoLabelRes', 'cnExplicitLabelBarLabelsOn', 'cnExplicitLegendLabelsOn', 'cnExplicitLineLabelsOn', 'cnFillBackgroundColor', 'cnFillColor', 'cnFillColors', 'cnFillDotSizeF', 'cnFillDrawOrder', 'cnFillMode', 'cnFillOn', 'cnFillOpacityF', 'cnFillPalette', 'cnFillPattern', 'cnFillPatterns', 'cnFillScaleF', 'cnFillScales', 'cnFixFillBleed', 'cnGridBoundFillColor', 'cnGridBoundFillPattern', 'cnGridBoundFillScaleF', 'cnGridBoundPerimColor', 'cnGridBoundPerimDashPattern', 'cnGridBoundPerimOn', 'cnGridBoundPerimThicknessF', 'cnHighLabelAngleF', 'cnHighLabelBackgroundColor', 'cnHighLabelConstantSpacingF', 'cnHighLabelCount', 'cnHighLabelFont', 'cnHighLabelFontAspectF', 'cnHighLabelFontColor', 'cnHighLabelFontHeightF', 'cnHighLabelFontQuality', 'cnHighLabelFontThicknessF', 'cnHighLabelFormat', 'cnHighLabelFuncCode', 'cnHighLabelPerimColor', 'cnHighLabelPerimOn', 'cnHighLabelPerimSpaceF', 'cnHighLabelPerimThicknessF', 'cnHighLabelString', 'cnHighLabelsOn', 'cnHighLowLabelOverlapMode', 'cnHighUseLineLabelRes', 'cnInfoLabelAngleF', 'cnInfoLabelBackgroundColor', 'cnInfoLabelConstantSpacingF', 'cnInfoLabelFont', 'cnInfoLabelFontAspectF', 'cnInfoLabelFontColor', 'cnInfoLabelFontHeightF', 'cnInfoLabelFontQuality', 'cnInfoLabelFontThicknessF', 'cnInfoLabelFormat', 'cnInfoLabelFuncCode', 'cnInfoLabelJust', 'cnInfoLabelOn', 'cnInfoLabelOrthogonalPosF', 'cnInfoLabelParallelPosF', 'cnInfoLabelPerimColor', 'cnInfoLabelPerimOn', 'cnInfoLabelPerimSpaceF', 'cnInfoLabelPerimThicknessF', 'cnInfoLabelSide', 'cnInfoLabelString', 'cnInfoLabelTextDirection', 'cnInfoLabelZone', 'cnLabelBarEndLabelsOn', 'cnLabelBarEndStyle', 'cnLabelDrawOrder', 'cnLabelMasking', 'cnLabelScaleFactorF', 'cnLabelScaleValueF', 'cnLabelScalingMode', 'cnLegendLevelFlags', 'cnLevelCount', 'cnLevelFlag', 'cnLevelFlags', 'cnLevelSelectionMode', 'cnLevelSpacingF', 'cnLevels', 'cnLineColor', 'cnLineColors', 'cnLineDashPattern', 'cnLineDashPatterns', 'cnLineDashSegLenF', 'cnLineDrawOrder', 'cnLineLabelAngleF', 'cnLineLabelBackgroundColor', 'cnLineLabelConstantSpacingF', 'cnLineLabelCount', 'cnLineLabelDensityF', 'cnLineLabelFont', 'cnLineLabelFontAspectF', 'cnLineLabelFontColor', 'cnLineLabelFontColors', 'cnLineLabelFontHeightF', 'cnLineLabelFontQuality', 'cnLineLabelFontThicknessF', 'cnLineLabelFormat', 'cnLineLabelFuncCode', 'cnLineLabelInterval', 'cnLineLabelPerimColor', 'cnLineLabelPerimOn', 'cnLineLabelPerimSpaceF', 'cnLineLabelPerimThicknessF', 'cnLineLabelPlacementMode', 'cnLineLabelStrings', 'cnLineLabelsOn', 'cnLinePalette', 'cnLineThicknessF', 'cnLineThicknesses', 'cnLinesOn', 'cnLowLabelAngleF', 'cnLowLabelBackgroundColor', 'cnLowLabelConstantSpacingF', 'cnLowLabelCount', 'cnLowLabelFont', 'cnLowLabelFontAspectF', 'cnLowLabelFontColor', 'cnLowLabelFontHeightF', 'cnLowLabelFontQuality', 'cnLowLabelFontThicknessF', 'cnLowLabelFormat', 'cnLowLabelFuncCode', 'cnLowLabelPerimColor', 'cnLowLabelPerimOn', 'cnLowLabelPerimSpaceF', 'cnLowLabelPerimThicknessF', 'cnLowLabelString', 'cnLowLabelsOn', 'cnLowUseHighLabelRes', 'cnMaxDataValueFormat', 'cnMaxLevelCount', 'cnMaxLevelValF', 'cnMaxPointDistanceF', 'cnMinLevelValF', 'cnMissingValFillColor', 'cnMissingValFillPattern', 'cnMissingValFillScaleF', 'cnMissingValPerimColor', 'cnMissingValPerimDashPattern', 'cnMissingValPerimGridBoundOn', 'cnMissingValPerimOn', 'cnMissingValPerimThicknessF', 'cnMonoFillColor', 'cnMonoFillPattern', 'cnMonoFillScale', 'cnMonoLevelFlag', 'cnMonoLineColor', 'cnMonoLineDashPattern', 'cnMonoLineLabelFontColor', 'cnMonoLineThickness', 'cnNoDataLabelOn', 'cnNoDataLabelString', 'cnOutOfRangeFillColor', 'cnOutOfRangeFillPattern', 'cnOutOfRangeFillScaleF', 'cnOutOfRangePerimColor', 'cnOutOfRangePerimDashPattern', 'cnOutOfRangePerimOn', 'cnOutOfRangePerimThicknessF', 'cnRasterCellSizeF', 'cnRasterMinCellSizeF', 'cnRasterModeOn', 'cnRasterSampleFactorF', 'cnRasterSmoothingOn', 'cnScalarFieldData', 'cnSmoothingDistanceF', 'cnSmoothingOn', 'cnSmoothingTensionF', 'cnSpanFillPalette', 'cnSpanLinePalette', 'ctCopyTables', 'ctXElementSize', 'ctXMaxV', 'ctXMinV', 'ctXMissingV', 'ctXTable', 'ctXTableLengths', 'ctXTableType', 'ctYElementSize', 'ctYMaxV', 'ctYMinV', 'ctYMissingV', 'ctYTable', 'ctYTableLengths', 'ctYTableType', 'dcDelayCompute', 'errBuffer', 'errFileName', 'errFilePtr', 'errLevel', 'errPrint', 'errUnitNumber', 'gsClipOn', 'gsColors', 'gsEdgeColor', 'gsEdgeDashPattern', 'gsEdgeDashSegLenF', 'gsEdgeThicknessF', 'gsEdgesOn', 'gsFillBackgroundColor', 'gsFillColor', 'gsFillDotSizeF', 'gsFillIndex', 'gsFillLineThicknessF', 'gsFillOpacityF', 'gsFillScaleF', 'gsFont', 'gsFontAspectF', 'gsFontColor', 'gsFontHeightF', 'gsFontOpacityF', 'gsFontQuality', 'gsFontThicknessF', 'gsLineColor', 'gsLineDashPattern', 'gsLineDashSegLenF', 'gsLineLabelConstantSpacingF', 'gsLineLabelFont', 'gsLineLabelFontAspectF', 'gsLineLabelFontColor', 'gsLineLabelFontHeightF', 'gsLineLabelFontQuality', 'gsLineLabelFontThicknessF', 'gsLineLabelFuncCode', 'gsLineLabelString', 'gsLineOpacityF', 'gsLineThicknessF', 'gsMarkerColor', 'gsMarkerIndex', 'gsMarkerOpacityF', 'gsMarkerSizeF', 'gsMarkerThicknessF', 'gsSegments', 'gsTextAngleF', 'gsTextConstantSpacingF', 'gsTextDirection', 'gsTextFuncCode', 'gsTextJustification', 'gsnAboveYRefLineBarColors', 'gsnAboveYRefLineBarFillScales', 'gsnAboveYRefLineBarPatterns', 'gsnAboveYRefLineColor', 'gsnAddCyclic', 'gsnAttachBorderOn', 'gsnAttachPlotsXAxis', 'gsnBelowYRefLineBarColors', 'gsnBelowYRefLineBarFillScales', 'gsnBelowYRefLineBarPatterns', 'gsnBelowYRefLineColor', 'gsnBoxMargin', 'gsnCenterString', 'gsnCenterStringFontColor', 'gsnCenterStringFontHeightF', 'gsnCenterStringFuncCode', 'gsnCenterStringOrthogonalPosF', 'gsnCenterStringParallelPosF', 'gsnContourLineThicknessesScale', 'gsnContourNegLineDashPattern', 'gsnContourPosLineDashPattern', 'gsnContourZeroLineThicknessF', 'gsnDebugWriteFileName', 'gsnDraw', 'gsnFrame', 'gsnHistogramBarWidthPercent', 'gsnHistogramBinIntervals', 'gsnHistogramBinMissing', 'gsnHistogramBinWidth', 'gsnHistogramClassIntervals', 'gsnHistogramCompare', 'gsnHistogramComputePercentages', 'gsnHistogramComputePercentagesNoMissing', 'gsnHistogramDiscreteBinValues', 'gsnHistogramDiscreteClassValues', 'gsnHistogramHorizontal', 'gsnHistogramMinMaxBinsOn', 'gsnHistogramNumberOfBins', 'gsnHistogramPercentSign', 'gsnHistogramSelectNiceIntervals', 'gsnLeftString', 'gsnLeftStringFontColor', 'gsnLeftStringFontHeightF', 'gsnLeftStringFuncCode', 'gsnLeftStringOrthogonalPosF', 'gsnLeftStringParallelPosF', 'gsnMajorLatSpacing', 'gsnMajorLonSpacing', 'gsnMaskLambertConformal', 'gsnMaskLambertConformalOutlineOn', 'gsnMaximize', 'gsnMinorLatSpacing', 'gsnMinorLonSpacing', 'gsnPanelBottom', 'gsnPanelCenter', 'gsnPanelDebug', 'gsnPanelFigureStrings', 'gsnPanelFigureStringsBackgroundFillColor', 'gsnPanelFigureStringsFontHeightF', 'gsnPanelFigureStringsJust', 'gsnPanelFigureStringsPerimOn', 'gsnPanelLabelBar', 'gsnPanelLeft', 'gsnPanelMainFont', 'gsnPanelMainFontColor', 'gsnPanelMainFontHeightF', 'gsnPanelMainString', 'gsnPanelRight', 'gsnPanelRowSpec', 'gsnPanelScalePlotIndex', 'gsnPanelTop', 'gsnPanelXF', 'gsnPanelXWhiteSpacePercent', 'gsnPanelYF', 'gsnPanelYWhiteSpacePercent', 'gsnPaperHeight', 'gsnPaperMargin', 'gsnPaperOrientation', 'gsnPaperWidth', 'gsnPolar', 'gsnPolarLabelDistance', 'gsnPolarLabelFont', 'gsnPolarLabelFontHeightF', 'gsnPolarLabelSpacing', 'gsnPolarTime', 'gsnPolarUT', 'gsnRightString', 'gsnRightStringFontColor', 'gsnRightStringFontHeightF', 'gsnRightStringFuncCode', 'gsnRightStringOrthogonalPosF', 'gsnRightStringParallelPosF', 'gsnScalarContour', 'gsnScale', 'gsnShape', 'gsnSpreadColorEnd', 'gsnSpreadColorStart', 'gsnSpreadColors', 'gsnStringFont', 'gsnStringFontColor', 'gsnStringFontHeightF', 'gsnStringFuncCode', 'gsnTickMarksOn', 'gsnXAxisIrregular2Linear', 'gsnXAxisIrregular2Log', 'gsnXRefLine', 'gsnXRefLineColor', 'gsnXRefLineDashPattern', 'gsnXRefLineThicknessF', 'gsnXYAboveFillColors', 'gsnXYBarChart', 'gsnXYBarChartBarWidth', 'gsnXYBarChartColors', 'gsnXYBarChartColors2', 'gsnXYBarChartFillDotSizeF', 'gsnXYBarChartFillLineThicknessF', 'gsnXYBarChartFillOpacityF', 'gsnXYBarChartFillScaleF', 'gsnXYBarChartOutlineOnly', 'gsnXYBarChartOutlineThicknessF', 'gsnXYBarChartPatterns', 'gsnXYBarChartPatterns2', 'gsnXYBelowFillColors', 'gsnXYFillColors', 'gsnXYFillOpacities', 'gsnXYLeftFillColors', 'gsnXYRightFillColors', 'gsnYAxisIrregular2Linear', 'gsnYAxisIrregular2Log', 'gsnYRefLine', 'gsnYRefLineColor', 'gsnYRefLineColors', 'gsnYRefLineDashPattern', 'gsnYRefLineDashPatterns', 'gsnYRefLineThicknessF', 'gsnYRefLineThicknesses', 'gsnZonalMean', 'gsnZonalMeanXMaxF', 'gsnZonalMeanXMinF', 'gsnZonalMeanYRefLine', 'lbAutoManage', 'lbBottomMarginF', 'lbBoxCount', 'lbBoxEndCapStyle', 'lbBoxFractions', 'lbBoxLineColor', 'lbBoxLineDashPattern', 'lbBoxLineDashSegLenF', 'lbBoxLineThicknessF', 'lbBoxLinesOn', 'lbBoxMajorExtentF', 'lbBoxMinorExtentF', 'lbBoxSeparatorLinesOn', 'lbBoxSizing', 'lbFillBackground', 'lbFillColor', 'lbFillColors', 'lbFillDotSizeF', 'lbFillLineThicknessF', 'lbFillPattern', 'lbFillPatterns', 'lbFillScaleF', 'lbFillScales', 'lbJustification', 'lbLabelAlignment', 'lbLabelAngleF', 'lbLabelAutoStride', 'lbLabelBarOn', 'lbLabelConstantSpacingF', 'lbLabelDirection', 'lbLabelFont', 'lbLabelFontAspectF', 'lbLabelFontColor', 'lbLabelFontHeightF', 'lbLabelFontQuality', 'lbLabelFontThicknessF', 'lbLabelFuncCode', 'lbLabelJust', 'lbLabelOffsetF', 'lbLabelPosition', 'lbLabelStride', 'lbLabelStrings', 'lbLabelsOn', 'lbLeftMarginF', 'lbMaxLabelLenF', 'lbMinLabelSpacingF', 'lbMonoFillColor', 'lbMonoFillPattern', 'lbMonoFillScale', 'lbOrientation', 'lbPerimColor', 'lbPerimDashPattern', 'lbPerimDashSegLenF', 'lbPerimFill', 'lbPerimFillColor', 'lbPerimOn', 'lbPerimThicknessF', 'lbRasterFillOn', 'lbRightMarginF', 'lbTitleAngleF', 'lbTitleConstantSpacingF', 'lbTitleDirection', 'lbTitleExtentF', 'lbTitleFont', 'lbTitleFontAspectF', 'lbTitleFontColor', 'lbTitleFontHeightF', 'lbTitleFontQuality', 'lbTitleFontThicknessF', 'lbTitleFuncCode', 'lbTitleJust', 'lbTitleOffsetF', 'lbTitleOn', 'lbTitlePosition', 'lbTitleString', 'lbTopMarginF', 'lgAutoManage', 'lgBottomMarginF', 'lgBoxBackground', 'lgBoxLineColor', 'lgBoxLineDashPattern', 'lgBoxLineDashSegLenF', 'lgBoxLineThicknessF', 'lgBoxLinesOn', 'lgBoxMajorExtentF', 'lgBoxMinorExtentF', 'lgDashIndex', 'lgDashIndexes', 'lgItemCount', 'lgItemOrder', 'lgItemPlacement', 'lgItemPositions', 'lgItemType', 'lgItemTypes', 'lgJustification', 'lgLabelAlignment', 'lgLabelAngleF', 'lgLabelAutoStride', 'lgLabelConstantSpacingF', 'lgLabelDirection', 'lgLabelFont', 'lgLabelFontAspectF', 'lgLabelFontColor', 'lgLabelFontHeightF', 'lgLabelFontQuality', 'lgLabelFontThicknessF', 'lgLabelFuncCode', 'lgLabelJust', 'lgLabelOffsetF', 'lgLabelPosition', 'lgLabelStride', 'lgLabelStrings', 'lgLabelsOn', 'lgLeftMarginF', 'lgLegendOn', 'lgLineColor', 'lgLineColors', 'lgLineDashSegLenF', 'lgLineDashSegLens', 'lgLineLabelConstantSpacingF', 'lgLineLabelFont', 'lgLineLabelFontAspectF', 'lgLineLabelFontColor', 'lgLineLabelFontColors', 'lgLineLabelFontHeightF', 'lgLineLabelFontHeights', 'lgLineLabelFontQuality', 'lgLineLabelFontThicknessF', 'lgLineLabelFuncCode', 'lgLineLabelStrings', 'lgLineLabelsOn', 'lgLineThicknessF', 'lgLineThicknesses', 'lgMarkerColor', 'lgMarkerColors', 'lgMarkerIndex', 'lgMarkerIndexes', 'lgMarkerSizeF', 'lgMarkerSizes', 'lgMarkerThicknessF', 'lgMarkerThicknesses', 'lgMonoDashIndex', 'lgMonoItemType', 'lgMonoLineColor', 'lgMonoLineDashSegLen', 'lgMonoLineLabelFontColor', 'lgMonoLineLabelFontHeight', 'lgMonoLineThickness', 'lgMonoMarkerColor', 'lgMonoMarkerIndex', 'lgMonoMarkerSize', 'lgMonoMarkerThickness', 'lgOrientation', 'lgPerimColor', 'lgPerimDashPattern', 'lgPerimDashSegLenF', 'lgPerimFill', 'lgPerimFillColor', 'lgPerimOn', 'lgPerimThicknessF', 'lgRightMarginF', 'lgTitleAngleF', 'lgTitleConstantSpacingF', 'lgTitleDirection', 'lgTitleExtentF', 'lgTitleFont', 'lgTitleFontAspectF', 'lgTitleFontColor', 'lgTitleFontHeightF', 'lgTitleFontQuality', 'lgTitleFontThicknessF', 'lgTitleFuncCode', 'lgTitleJust', 'lgTitleOffsetF', 'lgTitleOn', 'lgTitlePosition', 'lgTitleString', 'lgTopMarginF', 'mpAreaGroupCount', 'mpAreaMaskingOn', 'mpAreaNames', 'mpAreaTypes', 'mpBottomAngleF', 'mpBottomMapPosF', 'mpBottomNDCF', 'mpBottomNPCF', 'mpBottomPointLatF', 'mpBottomPointLonF', 'mpBottomWindowF', 'mpCenterLatF', 'mpCenterLonF', 'mpCenterRotF', 'mpCountyLineColor', 'mpCountyLineDashPattern', 'mpCountyLineDashSegLenF', 'mpCountyLineThicknessF', 'mpDataBaseVersion', 'mpDataResolution', 'mpDataSetName', 'mpDefaultFillColor', 'mpDefaultFillPattern', 'mpDefaultFillScaleF', 'mpDynamicAreaGroups', 'mpEllipticalBoundary', 'mpFillAreaSpecifiers', 'mpFillBoundarySets', 'mpFillColor', 'mpFillColors', 'mpFillColors-default', 'mpFillDotSizeF', 'mpFillDrawOrder', 'mpFillOn', 'mpFillPatternBackground', 'mpFillPattern', 'mpFillPatterns', 'mpFillPatterns-default', 'mpFillScaleF', 'mpFillScales', 'mpFillScales-default', 'mpFixedAreaGroups', 'mpGeophysicalLineColor', 'mpGeophysicalLineDashPattern', 'mpGeophysicalLineDashSegLenF', 'mpGeophysicalLineThicknessF', 'mpGreatCircleLinesOn', 'mpGridAndLimbDrawOrder', 'mpGridAndLimbOn', 'mpGridLatSpacingF', 'mpGridLineColor', 'mpGridLineDashPattern', 'mpGridLineDashSegLenF', 'mpGridLineThicknessF', 'mpGridLonSpacingF', 'mpGridMaskMode', 'mpGridMaxLatF', 'mpGridPolarLonSpacingF', 'mpGridSpacingF', 'mpInlandWaterFillColor', 'mpInlandWaterFillPattern', 'mpInlandWaterFillScaleF', 'mpLabelDrawOrder', 'mpLabelFontColor', 'mpLabelFontHeightF', 'mpLabelsOn', 'mpLambertMeridianF', 'mpLambertParallel1F', 'mpLambertParallel2F', 'mpLandFillColor', 'mpLandFillPattern', 'mpLandFillScaleF', 'mpLeftAngleF', 'mpLeftCornerLatF', 'mpLeftCornerLonF', 'mpLeftMapPosF', 'mpLeftNDCF', 'mpLeftNPCF', 'mpLeftPointLatF', 'mpLeftPointLonF', 'mpLeftWindowF', 'mpLimbLineColor', 'mpLimbLineDashPattern', 'mpLimbLineDashSegLenF', 'mpLimbLineThicknessF', 'mpLimitMode', 'mpMaskAreaSpecifiers', 'mpMaskOutlineSpecifiers', 'mpMaxLatF', 'mpMaxLonF', 'mpMinLatF', 'mpMinLonF', 'mpMonoFillColor', 'mpMonoFillPattern', 'mpMonoFillScale', 'mpNationalLineColor', 'mpNationalLineDashPattern', 'mpNationalLineThicknessF', 'mpOceanFillColor', 'mpOceanFillPattern', 'mpOceanFillScaleF', 'mpOutlineBoundarySets', 'mpOutlineDrawOrder', 'mpOutlineMaskingOn', 'mpOutlineOn', 'mpOutlineSpecifiers', 'mpPerimDrawOrder', 'mpPerimLineColor', 'mpPerimLineDashPattern', 'mpPerimLineDashSegLenF', 'mpPerimLineThicknessF', 'mpPerimOn', 'mpPolyMode', 'mpProjection', 'mpProvincialLineColor', 'mpProvincialLineDashPattern', 'mpProvincialLineDashSegLenF', 'mpProvincialLineThicknessF', 'mpRelativeCenterLat', 'mpRelativeCenterLon', 'mpRightAngleF', 'mpRightCornerLatF', 'mpRightCornerLonF', 'mpRightMapPosF', 'mpRightNDCF', 'mpRightNPCF', 'mpRightPointLatF', 'mpRightPointLonF', 'mpRightWindowF', 'mpSatelliteAngle1F', 'mpSatelliteAngle2F', 'mpSatelliteDistF', 'mpShapeMode', 'mpSpecifiedFillColors', 'mpSpecifiedFillDirectIndexing', 'mpSpecifiedFillPatterns', 'mpSpecifiedFillPriority', 'mpSpecifiedFillScales', 'mpTopAngleF', 'mpTopMapPosF', 'mpTopNDCF', 'mpTopNPCF', 'mpTopPointLatF', 'mpTopPointLonF', 'mpTopWindowF', 'mpUSStateLineColor', 'mpUSStateLineDashPattern', 'mpUSStateLineDashSegLenF', 'mpUSStateLineThicknessF', 'pmAnnoManagers', 'pmAnnoViews', 'pmLabelBarDisplayMode', 'pmLabelBarHeightF', 'pmLabelBarKeepAspect', 'pmLabelBarOrthogonalPosF', 'pmLabelBarParallelPosF', 'pmLabelBarSide', 'pmLabelBarWidthF', 'pmLabelBarZone', 'pmLegendDisplayMode', 'pmLegendHeightF', 'pmLegendKeepAspect', 'pmLegendOrthogonalPosF', 'pmLegendParallelPosF', 'pmLegendSide', 'pmLegendWidthF', 'pmLegendZone', 'pmOverlaySequenceIds', 'pmTickMarkDisplayMode', 'pmTickMarkZone', 'pmTitleDisplayMode', 'pmTitleZone', 'prGraphicStyle', 'prPolyType', 'prXArray', 'prYArray', 'sfCopyData', 'sfDataArray', 'sfDataMaxV', 'sfDataMinV', 'sfElementNodes', 'sfExchangeDimensions', 'sfFirstNodeIndex', 'sfMissingValueV', 'sfXArray', 'sfXCActualEndF', 'sfXCActualStartF', 'sfXCEndIndex', 'sfXCEndSubsetV', 'sfXCEndV', 'sfXCStartIndex', 'sfXCStartSubsetV', 'sfXCStartV', 'sfXCStride', 'sfXCellBounds', 'sfYArray', 'sfYCActualEndF', 'sfYCActualStartF', 'sfYCEndIndex', 'sfYCEndSubsetV', 'sfYCEndV', 'sfYCStartIndex', 'sfYCStartSubsetV', 'sfYCStartV', 'sfYCStride', 'sfYCellBounds', 'stArrowLengthF', 'stArrowStride', 'stCrossoverCheckCount', 'stExplicitLabelBarLabelsOn', 'stLabelBarEndLabelsOn', 'stLabelFormat', 'stLengthCheckCount', 'stLevelColors', 'stLevelCount', 'stLevelPalette', 'stLevelSelectionMode', 'stLevelSpacingF', 'stLevels', 'stLineColor', 'stLineOpacityF', 'stLineStartStride', 'stLineThicknessF', 'stMapDirection', 'stMaxLevelCount', 'stMaxLevelValF', 'stMinArrowSpacingF', 'stMinDistanceF', 'stMinLevelValF', 'stMinLineSpacingF', 'stMinStepFactorF', 'stMonoLineColor', 'stNoDataLabelOn', 'stNoDataLabelString', 'stScalarFieldData', 'stScalarMissingValColor', 'stSpanLevelPalette', 'stStepSizeF', 'stStreamlineDrawOrder', 'stUseScalarArray', 'stVectorFieldData', 'stZeroFLabelAngleF', 'stZeroFLabelBackgroundColor', 'stZeroFLabelConstantSpacingF', 'stZeroFLabelFont', 'stZeroFLabelFontAspectF', 'stZeroFLabelFontColor', 'stZeroFLabelFontHeightF', 'stZeroFLabelFontQuality', 'stZeroFLabelFontThicknessF', 'stZeroFLabelFuncCode', 'stZeroFLabelJust', 'stZeroFLabelOn', 'stZeroFLabelOrthogonalPosF', 'stZeroFLabelParallelPosF', 'stZeroFLabelPerimColor', 'stZeroFLabelPerimOn', 'stZeroFLabelPerimSpaceF', 'stZeroFLabelPerimThicknessF', 'stZeroFLabelSide', 'stZeroFLabelString', 'stZeroFLabelTextDirection', 'stZeroFLabelZone', 'tfDoNDCOverlay', 'tfPlotManagerOn', 'tfPolyDrawList', 'tfPolyDrawOrder', 'tiDeltaF', 'tiMainAngleF', 'tiMainConstantSpacingF', 'tiMainDirection', 'tiMainFont', 'tiMainFontAspectF', 'tiMainFontColor', 'tiMainFontHeightF', 'tiMainFontQuality', 'tiMainFontThicknessF', 'tiMainFuncCode', 'tiMainJust', 'tiMainOffsetXF', 'tiMainOffsetYF', 'tiMainOn', 'tiMainPosition', 'tiMainSide', 'tiMainString', 'tiUseMainAttributes', 'tiXAxisAngleF', 'tiXAxisConstantSpacingF', 'tiXAxisDirection', 'tiXAxisFont', 'tiXAxisFontAspectF', 'tiXAxisFontColor', 'tiXAxisFontHeightF', 'tiXAxisFontQuality', 'tiXAxisFontThicknessF', 'tiXAxisFuncCode', 'tiXAxisJust', 'tiXAxisOffsetXF', 'tiXAxisOffsetYF', 'tiXAxisOn', 'tiXAxisPosition', 'tiXAxisSide', 'tiXAxisString', 'tiYAxisAngleF', 'tiYAxisConstantSpacingF', 'tiYAxisDirection', 'tiYAxisFont', 'tiYAxisFontAspectF', 'tiYAxisFontColor', 'tiYAxisFontHeightF', 'tiYAxisFontQuality', 'tiYAxisFontThicknessF', 'tiYAxisFuncCode', 'tiYAxisJust', 'tiYAxisOffsetXF', 'tiYAxisOffsetYF', 'tiYAxisOn', 'tiYAxisPosition', 'tiYAxisSide', 'tiYAxisString', 'tmBorderLineColor', 'tmBorderThicknessF', 'tmEqualizeXYSizes', 'tmLabelAutoStride', 'tmSciNoteCutoff', 'tmXBAutoPrecision', 'tmXBBorderOn', 'tmXBDataLeftF', 'tmXBDataRightF', 'tmXBFormat', 'tmXBIrrTensionF', 'tmXBIrregularPoints', 'tmXBLabelAngleF', 'tmXBLabelConstantSpacingF', 'tmXBLabelDeltaF', 'tmXBLabelDirection', 'tmXBLabelFont', 'tmXBLabelFontAspectF', 'tmXBLabelFontColor', 'tmXBLabelFontHeightF', 'tmXBLabelFontQuality', 'tmXBLabelFontThicknessF', 'tmXBLabelFuncCode', 'tmXBLabelJust', 'tmXBLabelStride', 'tmXBLabels', 'tmXBLabelsOn', 'tmXBMajorLengthF', 'tmXBMajorLineColor', 'tmXBMajorOutwardLengthF', 'tmXBMajorThicknessF', 'tmXBMaxLabelLenF', 'tmXBMaxTicks', 'tmXBMinLabelSpacingF', 'tmXBMinorLengthF', 'tmXBMinorLineColor', 'tmXBMinorOn', 'tmXBMinorOutwardLengthF', 'tmXBMinorPerMajor', 'tmXBMinorThicknessF', 'tmXBMinorValues', 'tmXBMode', 'tmXBOn', 'tmXBPrecision', 'tmXBStyle', 'tmXBTickEndF', 'tmXBTickSpacingF', 'tmXBTickStartF', 'tmXBValues', 'tmXMajorGrid', 'tmXMajorGridLineColor', 'tmXMajorGridLineDashPattern', 'tmXMajorGridThicknessF', 'tmXMinorGrid', 'tmXMinorGridLineColor', 'tmXMinorGridLineDashPattern', 'tmXMinorGridThicknessF', 'tmXTAutoPrecision', 'tmXTBorderOn', 'tmXTDataLeftF', 'tmXTDataRightF', 'tmXTFormat', 'tmXTIrrTensionF', 'tmXTIrregularPoints', 'tmXTLabelAngleF', 'tmXTLabelConstantSpacingF', 'tmXTLabelDeltaF', 'tmXTLabelDirection', 'tmXTLabelFont', 'tmXTLabelFontAspectF', 'tmXTLabelFontColor', 'tmXTLabelFontHeightF', 'tmXTLabelFontQuality', 'tmXTLabelFontThicknessF', 'tmXTLabelFuncCode', 'tmXTLabelJust', 'tmXTLabelStride', 'tmXTLabels', 'tmXTLabelsOn', 'tmXTMajorLengthF', 'tmXTMajorLineColor', 'tmXTMajorOutwardLengthF', 'tmXTMajorThicknessF', 'tmXTMaxLabelLenF', 'tmXTMaxTicks', 'tmXTMinLabelSpacingF', 'tmXTMinorLengthF', 'tmXTMinorLineColor', 'tmXTMinorOn', 'tmXTMinorOutwardLengthF', 'tmXTMinorPerMajor', 'tmXTMinorThicknessF', 'tmXTMinorValues', 'tmXTMode', 'tmXTOn', 'tmXTPrecision', 'tmXTStyle', 'tmXTTickEndF', 'tmXTTickSpacingF', 'tmXTTickStartF', 'tmXTValues', 'tmXUseBottom', 'tmYLAutoPrecision', 'tmYLBorderOn', 'tmYLDataBottomF', 'tmYLDataTopF', 'tmYLFormat', 'tmYLIrrTensionF', 'tmYLIrregularPoints', 'tmYLLabelAngleF', 'tmYLLabelConstantSpacingF', 'tmYLLabelDeltaF', 'tmYLLabelDirection', 'tmYLLabelFont', 'tmYLLabelFontAspectF', 'tmYLLabelFontColor', 'tmYLLabelFontHeightF', 'tmYLLabelFontQuality', 'tmYLLabelFontThicknessF', 'tmYLLabelFuncCode', 'tmYLLabelJust', 'tmYLLabelStride', 'tmYLLabels', 'tmYLLabelsOn', 'tmYLMajorLengthF', 'tmYLMajorLineColor', 'tmYLMajorOutwardLengthF', 'tmYLMajorThicknessF', 'tmYLMaxLabelLenF', 'tmYLMaxTicks', 'tmYLMinLabelSpacingF', 'tmYLMinorLengthF', 'tmYLMinorLineColor', 'tmYLMinorOn', 'tmYLMinorOutwardLengthF', 'tmYLMinorPerMajor', 'tmYLMinorThicknessF', 'tmYLMinorValues', 'tmYLMode', 'tmYLOn', 'tmYLPrecision', 'tmYLStyle', 'tmYLTickEndF', 'tmYLTickSpacingF', 'tmYLTickStartF', 'tmYLValues', 'tmYMajorGrid', 'tmYMajorGridLineColor', 'tmYMajorGridLineDashPattern', 'tmYMajorGridThicknessF', 'tmYMinorGrid', 'tmYMinorGridLineColor', 'tmYMinorGridLineDashPattern', 'tmYMinorGridThicknessF', 'tmYRAutoPrecision', 'tmYRBorderOn', 'tmYRDataBottomF', 'tmYRDataTopF', 'tmYRFormat', 'tmYRIrrTensionF', 'tmYRIrregularPoints', 'tmYRLabelAngleF', 'tmYRLabelConstantSpacingF', 'tmYRLabelDeltaF', 'tmYRLabelDirection', 'tmYRLabelFont', 'tmYRLabelFontAspectF', 'tmYRLabelFontColor', 'tmYRLabelFontHeightF', 'tmYRLabelFontQuality', 'tmYRLabelFontThicknessF', 'tmYRLabelFuncCode', 'tmYRLabelJust', 'tmYRLabelStride', 'tmYRLabels', 'tmYRLabelsOn', 'tmYRMajorLengthF', 'tmYRMajorLineColor', 'tmYRMajorOutwardLengthF', 'tmYRMajorThicknessF', 'tmYRMaxLabelLenF', 'tmYRMaxTicks', 'tmYRMinLabelSpacingF', 'tmYRMinorLengthF', 'tmYRMinorLineColor', 'tmYRMinorOn', 'tmYRMinorOutwardLengthF', 'tmYRMinorPerMajor', 'tmYRMinorThicknessF', 'tmYRMinorValues', 'tmYRMode', 'tmYROn', 'tmYRPrecision', 'tmYRStyle', 'tmYRTickEndF', 'tmYRTickSpacingF', 'tmYRTickStartF', 'tmYRValues', 'tmYUseLeft', 'trGridType', 'trLineInterpolationOn', 'trXAxisType', 'trXCoordPoints', 'trXInterPoints', 'trXLog', 'trXMaxF', 'trXMinF', 'trXReverse', 'trXSamples', 'trXTensionF', 'trYAxisType', 'trYCoordPoints', 'trYInterPoints', 'trYLog', 'trYMaxF', 'trYMinF', 'trYReverse', 'trYSamples', 'trYTensionF', 'txAngleF', 'txBackgroundFillColor', 'txConstantSpacingF', 'txDirection', 'txFont', 'HLU-Fonts', 'txFontAspectF', 'txFontColor', 'txFontHeightF', 'txFontOpacityF', 'txFontQuality', 'txFontThicknessF', 'txFuncCode', 'txJust', 'txPerimColor', 'txPerimDashLengthF', 'txPerimDashPattern', 'txPerimOn', 'txPerimSpaceF', 'txPerimThicknessF', 'txPosXF', 'txPosYF', 'txString', 'vcExplicitLabelBarLabelsOn', 'vcFillArrowEdgeColor', 'vcFillArrowEdgeThicknessF', 'vcFillArrowFillColor', 'vcFillArrowHeadInteriorXF', 'vcFillArrowHeadMinFracXF', 'vcFillArrowHeadMinFracYF', 'vcFillArrowHeadXF', 'vcFillArrowHeadYF', 'vcFillArrowMinFracWidthF', 'vcFillArrowWidthF', 'vcFillArrowsOn', 'vcFillOverEdge', 'vcGlyphOpacityF', 'vcGlyphStyle', 'vcLabelBarEndLabelsOn', 'vcLabelFontColor', 'vcLabelFontHeightF', 'vcLabelsOn', 'vcLabelsUseVectorColor', 'vcLevelColors', 'vcLevelCount', 'vcLevelPalette', 'vcLevelSelectionMode', 'vcLevelSpacingF', 'vcLevels', 'vcLineArrowColor', 'vcLineArrowHeadMaxSizeF', 'vcLineArrowHeadMinSizeF', 'vcLineArrowThicknessF', 'vcMagnitudeFormat', 'vcMagnitudeScaleFactorF', 'vcMagnitudeScaleValueF', 'vcMagnitudeScalingMode', 'vcMapDirection', 'vcMaxLevelCount', 'vcMaxLevelValF', 'vcMaxMagnitudeF', 'vcMinAnnoAngleF', 'vcMinAnnoArrowAngleF', 'vcMinAnnoArrowEdgeColor', 'vcMinAnnoArrowFillColor', 'vcMinAnnoArrowLineColor', 'vcMinAnnoArrowMinOffsetF', 'vcMinAnnoArrowSpaceF', 'vcMinAnnoArrowUseVecColor', 'vcMinAnnoBackgroundColor', 'vcMinAnnoConstantSpacingF', 'vcMinAnnoExplicitMagnitudeF', 'vcMinAnnoFont', 'vcMinAnnoFontAspectF', 'vcMinAnnoFontColor', 'vcMinAnnoFontHeightF', 'vcMinAnnoFontQuality', 'vcMinAnnoFontThicknessF', 'vcMinAnnoFuncCode', 'vcMinAnnoJust', 'vcMinAnnoOn', 'vcMinAnnoOrientation', 'vcMinAnnoOrthogonalPosF', 'vcMinAnnoParallelPosF', 'vcMinAnnoPerimColor', 'vcMinAnnoPerimOn', 'vcMinAnnoPerimSpaceF', 'vcMinAnnoPerimThicknessF', 'vcMinAnnoSide', 'vcMinAnnoString1', 'vcMinAnnoString1On', 'vcMinAnnoString2', 'vcMinAnnoString2On', 'vcMinAnnoTextDirection', 'vcMinAnnoZone', 'vcMinDistanceF', 'vcMinFracLengthF', 'vcMinLevelValF', 'vcMinMagnitudeF', 'vcMonoFillArrowEdgeColor', 'vcMonoFillArrowFillColor', 'vcMonoLineArrowColor', 'vcMonoWindBarbColor', 'vcNoDataLabelOn', 'vcNoDataLabelString', 'vcPositionMode', 'vcRefAnnoAngleF', 'vcRefAnnoArrowAngleF', 'vcRefAnnoArrowEdgeColor', 'vcRefAnnoArrowFillColor', 'vcRefAnnoArrowLineColor', 'vcRefAnnoArrowMinOffsetF', 'vcRefAnnoArrowSpaceF', 'vcRefAnnoArrowUseVecColor', 'vcRefAnnoBackgroundColor', 'vcRefAnnoConstantSpacingF', 'vcRefAnnoExplicitMagnitudeF', 'vcRefAnnoFont', 'vcRefAnnoFontAspectF', 'vcRefAnnoFontColor', 'vcRefAnnoFontHeightF', 'vcRefAnnoFontQuality', 'vcRefAnnoFontThicknessF', 'vcRefAnnoFuncCode', 'vcRefAnnoJust', 'vcRefAnnoOn', 'vcRefAnnoOrientation', 'vcRefAnnoOrthogonalPosF', 'vcRefAnnoParallelPosF', 'vcRefAnnoPerimColor', 'vcRefAnnoPerimOn', 'vcRefAnnoPerimSpaceF', 'vcRefAnnoPerimThicknessF', 'vcRefAnnoSide', 'vcRefAnnoString1', 'vcRefAnnoString1On', 'vcRefAnnoString2', 'vcRefAnnoString2On', 'vcRefAnnoTextDirection', 'vcRefAnnoZone', 'vcRefLengthF', 'vcRefMagnitudeF', 'vcScalarFieldData', 'vcScalarMissingValColor', 'vcScalarValueFormat', 'vcScalarValueScaleFactorF', 'vcScalarValueScaleValueF', 'vcScalarValueScalingMode', 'vcSpanLevelPalette', 'vcUseRefAnnoRes', 'vcUseScalarArray', 'vcVectorDrawOrder', 'vcVectorFieldData', 'vcWindBarbCalmCircleSizeF', 'vcWindBarbColor', 'vcWindBarbLineThicknessF', 'vcWindBarbScaleFactorF', 'vcWindBarbTickAngleF', 'vcWindBarbTickLengthF', 'vcWindBarbTickSpacingF', 'vcZeroFLabelAngleF', 'vcZeroFLabelBackgroundColor', 'vcZeroFLabelConstantSpacingF', 'vcZeroFLabelFont', 'vcZeroFLabelFontAspectF', 'vcZeroFLabelFontColor', 'vcZeroFLabelFontHeightF', 'vcZeroFLabelFontQuality', 'vcZeroFLabelFontThicknessF', 'vcZeroFLabelFuncCode', 'vcZeroFLabelJust', 'vcZeroFLabelOn', 'vcZeroFLabelOrthogonalPosF', 'vcZeroFLabelParallelPosF', 'vcZeroFLabelPerimColor', 'vcZeroFLabelPerimOn', 'vcZeroFLabelPerimSpaceF', 'vcZeroFLabelPerimThicknessF', 'vcZeroFLabelSide', 'vcZeroFLabelString', 'vcZeroFLabelTextDirection', 'vcZeroFLabelZone', 'vfCopyData', 'vfDataArray', 'vfExchangeDimensions', 'vfExchangeUVData', 'vfMagMaxV', 'vfMagMinV', 'vfMissingUValueV', 'vfMissingVValueV', 'vfPolarData', 'vfSingleMissingValue', 'vfUDataArray', 'vfUMaxV', 'vfUMinV', 'vfVDataArray', 'vfVMaxV', 'vfVMinV', 'vfXArray', 'vfXCActualEndF', 'vfXCActualStartF', 'vfXCEndIndex', 'vfXCEndSubsetV', 'vfXCEndV', 'vfXCStartIndex', 'vfXCStartSubsetV', 'vfXCStartV', 'vfXCStride', 'vfYArray', 'vfYCActualEndF', 'vfYCActualStartF', 'vfYCEndIndex', 'vfYCEndSubsetV', 'vfYCEndV', 'vfYCStartIndex', 'vfYCStartSubsetV', 'vfYCStartV', 'vfYCStride', 'vpAnnoManagerId', 'vpClipOn', 'vpHeightF', 'vpKeepAspect', 'vpOn', 'vpUseSegments', 'vpWidthF', 'vpXF', 'vpYF', 'wkAntiAlias', 'wkBackgroundColor', 'wkBackgroundOpacityF', 'wkColorMapLen', 'wkColorMap', 'wkColorModel', 'wkDashTableLength', 'wkDefGraphicStyleId', 'wkDeviceLowerX', 'wkDeviceLowerY', 'wkDeviceUpperX', 'wkDeviceUpperY', 'wkFileName', 'wkFillTableLength', 'wkForegroundColor', 'wkFormat', 'wkFullBackground', 'wkGksWorkId', 'wkHeight', 'wkMarkerTableLength', 'wkMetaName', 'wkOrientation', 'wkPDFFileName', 'wkPDFFormat', 'wkPDFResolution', 'wkPSFileName', 'wkPSFormat', 'wkPSResolution', 'wkPaperHeightF', 'wkPaperSize', 'wkPaperWidthF', 'wkPause', 'wkTopLevelViews', 'wkViews', 'wkVisualType', 'wkWidth', 'wkWindowId', 'wkXColorMode', 'wsCurrentSize', 'wsMaximumSize', 'wsThresholdSize', 'xyComputeXMax', 'xyComputeXMin', 'xyComputeYMax', 'xyComputeYMin', 'xyCoordData', 'xyCoordDataSpec', 'xyCurveDrawOrder', 'xyDashPattern', 'xyDashPatterns', 'xyExplicitLabels', 'xyExplicitLegendLabels', 'xyLabelMode', 'xyLineColor', 'xyLineColors', 'xyLineDashSegLenF', 'xyLineLabelConstantSpacingF', 'xyLineLabelFont', 'xyLineLabelFontAspectF', 'xyLineLabelFontColor', 'xyLineLabelFontColors', 'xyLineLabelFontHeightF', 'xyLineLabelFontQuality', 'xyLineLabelFontThicknessF', 'xyLineLabelFuncCode', 'xyLineThicknessF', 'xyLineThicknesses', 'xyMarkLineMode', 'xyMarkLineModes', 'xyMarker', 'xyMarkerColor', 'xyMarkerColors', 'xyMarkerSizeF', 'xyMarkerSizes', 'xyMarkerThicknessF', 'xyMarkerThicknesses', 'xyMarkers', 'xyMonoDashPattern', 'xyMonoLineColor', 'xyMonoLineLabelFontColor', 'xyMonoLineThickness', 'xyMonoMarkLineMode', 'xyMonoMarker', 'xyMonoMarkerColor', 'xyMonoMarkerSize', 'xyMonoMarkerThickness', 'xyXIrrTensionF', 'xyXIrregularPoints', 'xyXStyle', 'xyYIrrTensionF', 'xyYIrregularPoints', 'xyYStyle'), prefix=r'\b'), Name.Builtin),
# Booleans (r'\.(True|False)\.', Name.Builtin), # Comparing Operators (r'\.(eq|ne|lt|le|gt|ge|not|and|or|xor)\.', Operator.Word), ],
'strings': [ (r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double), ],
'nums': [ (r'\d+(?![.e])(_[a-z]\w+)?', Number.Integer), (r'[+-]?\d*\.\d+(e[-+]?\d+)?(_[a-z]\w+)?', Number.Float), (r'[+-]?\d+\.\d*(e[-+]?\d+)?(_[a-z]\w+)?', Number.Float), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199""" pygments.lexers.nimrod ~~~~~~~~~~~~~~~~~~~~~~
Lexer for the Nim language (formerly known as Nimrod).
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, include, default, bygroupsfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Error
__all__ = ['NimrodLexer']
class NimrodLexer(RegexLexer): """ For Nim source code. """
name = 'Nimrod' url = 'http://nim-lang.org/' aliases = ['nimrod', 'nim'] filenames = ['*.nim', '*.nimrod'] mimetypes = ['text/x-nim'] version_added = '1.5'
flags = re.MULTILINE | re.IGNORECASE
def underscorize(words): newWords = [] new = [] for word in words: for ch in word: new.append(ch) new.append("_?") newWords.append(''.join(new)) new = [] return "|".join(newWords)
keywords = [ 'addr', 'and', 'as', 'asm', 'bind', 'block', 'break', 'case', 'cast', 'concept', 'const', 'continue', 'converter', 'defer', 'discard', 'distinct', 'div', 'do', 'elif', 'else', 'end', 'enum', 'except', 'export', 'finally', 'for', 'if', 'in', 'yield', 'interface', 'is', 'isnot', 'iterator', 'let', 'mixin', 'mod', 'not', 'notin', 'object', 'of', 'or', 'out', 'ptr', 'raise', 'ref', 'return', 'shl', 'shr', 'static', 'try', 'tuple', 'type', 'using', 'when', 'while', 'xor' ]
keywordsPseudo = [ 'nil', 'true', 'false' ]
opWords = [ 'and', 'or', 'not', 'xor', 'shl', 'shr', 'div', 'mod', 'in', 'notin', 'is', 'isnot' ]
types = [ 'int', 'int8', 'int16', 'int32', 'int64', 'float', 'float32', 'float64', 'bool', 'char', 'range', 'array', 'seq', 'set', 'string' ]
tokens = { 'root': [ # Comments (r'##\[', String.Doc, 'doccomment'), (r'##.*$', String.Doc), (r'#\[', Comment.Multiline, 'comment'), (r'#.*$', Comment),
# Pragmas (r'\{\.', String.Other, 'pragma'),
# Operators (r'[*=><+\-/@$~&%!?|\\\[\]]', Operator), (r'\.\.|\.|,|\[\.|\.\]|\{\.|\.\}|\(\.|\.\)|\{|\}|\(|\)|:|\^|`|;', Punctuation),
# Case statement branch (r'(\n\s*)(of)(\s)', bygroups(Text.Whitespace, Keyword, Text.Whitespace), 'casebranch'),
# Strings (r'(?:[\w]+)"', String, 'rdqs'), (r'"""', String.Double, 'tdqs'), ('"', String, 'dqs'),
# Char ("'", String.Char, 'chars'),
# Keywords (rf'({underscorize(opWords)})\b', Operator.Word), (r'(proc|func|method|macro|template)(\s)(?![(\[\]])', bygroups(Keyword, Text.Whitespace), 'funcname'), (rf'({underscorize(keywords)})\b', Keyword), (r'({})\b'.format(underscorize(['from', 'import', 'include', 'export'])), Keyword.Namespace), (r'(v_?a_?r)\b', Keyword.Declaration), (rf'({underscorize(types)})\b', Name.Builtin), (rf'({underscorize(keywordsPseudo)})\b', Keyword.Pseudo),
# Identifiers (r'\b((?![_\d])\w)(((?!_)\w)|(_(?!_)\w))*', Name),
# Numbers (r'[0-9][0-9_]*(?=([e.]|\'f(32|64)))', Number.Float, ('float-suffix', 'float-number')), (r'0x[a-f0-9][a-f0-9_]*', Number.Hex, 'int-suffix'), (r'0b[01][01_]*', Number.Bin, 'int-suffix'), (r'0o[0-7][0-7_]*', Number.Oct, 'int-suffix'), (r'[0-9][0-9_]*', Number.Integer, 'int-suffix'),
# Whitespace (r'\s+', Text.Whitespace), (r'.+$', Error), ], 'chars': [ (r'\\([\\abcefnrtvl"\']|x[a-f0-9]{2}|[0-9]{1,3})', String.Escape), (r"'", String.Char, '#pop'), (r".", String.Char) ], 'strings': [ (r'(?<!\$)\$(\d+|#|\w+)+', String.Interpol), (r'[^\\\'"$\n]+', String), # quotes, dollars and backslashes must be parsed one at a time (r'[\'"\\]', String), # unhandled string formatting sign (r'\$', String) # newlines are an error (use "nl" state) ], 'doccomment': [ (r'[^\]#]+', String.Doc), (r'##\[', String.Doc, '#push'), (r'\]##', String.Doc, '#pop'), (r'[\]#]', String.Doc), ], 'comment': [ (r'[^\]#]+', Comment.Multiline), (r'#\[', Comment.Multiline, '#push'), (r'\]#', Comment.Multiline, '#pop'), (r'[\]#]', Comment.Multiline), ], 'dqs': [ (r'\\([\\abcefnrtvl"\']|\n|x[a-f0-9]{2}|[0-9]{1,3})', String.Escape), (r'"', String, '#pop'), include('strings') ], 'rdqs': [ (r'"(?!")', String, '#pop'), (r'""', String.Escape), include('strings') ], 'tdqs': [ (r'"""', String.Double, '#pop'), include('strings'), (r'\n', String.Double) ], 'funcname': [ (r'((?![\d_])\w)(((?!_)\w)|(_(?!_)\w))*', Name.Function, '#pop'), (r'`.+`', Name.Function, '#pop') ], 'nl': [ (r'\n', String) ], 'float-number': [ (r'\.(?!\.)[0-9_]*[f]*', Number.Float), (r'e[+-]?[0-9][0-9_]*', Number.Float), default('#pop') ], 'float-suffix': [ (r'\'f(32|64)', Number.Float), default('#pop') ], 'int-suffix': [ (r'\'i(32|64)', Number.Integer.Long), (r'\'i(8|16)', Number.Integer), default('#pop') ], 'casebranch': [ (r',', Punctuation), (r'[\n ]+', Text.Whitespace), (r':', Operator, '#pop'), (r'\w+|[^:]', Name.Label), ], 'pragma': [ (r'[:,]', Text), (r'[\n ]+', Text.Whitespace), (r'\.\}', String.Other, '#pop'), (r'\w+|\W+|[^.}]', String.Other), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263""" pygments.lexers.nit ~~~~~~~~~~~~~~~~~~~
Lexer for the Nit language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, wordsfrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation
__all__ = ['NitLexer']
class NitLexer(RegexLexer): """ For nit source. """
name = 'Nit' url = 'http://nitlanguage.org' aliases = ['nit'] filenames = ['*.nit'] version_added = '2.0' tokens = { 'root': [ (r'#.*?$', Comment.Single), (words(( 'package', 'module', 'import', 'class', 'abstract', 'interface', 'universal', 'enum', 'end', 'fun', 'type', 'init', 'redef', 'isa', 'do', 'readable', 'writable', 'var', 'intern', 'extern', 'public', 'protected', 'private', 'intrude', 'if', 'then', 'else', 'while', 'loop', 'for', 'in', 'and', 'or', 'not', 'implies', 'return', 'continue', 'break', 'abort', 'assert', 'new', 'is', 'once', 'super', 'self', 'true', 'false', 'nullable', 'null', 'as', 'isset', 'label', '__debug__'), suffix=r'(?=[\r\n\t( ])'), Keyword), (r'[A-Z]\w*', Name.Class), (r'"""(([^\'\\]|\\.)|\\r|\\n)*((\{\{?)?(""?\{\{?)*""""*)', String), # Simple long string (r'\'\'\'(((\\.|[^\'\\])|\\r|\\n)|\'((\\.|[^\'\\])|\\r|\\n)|' r'\'\'((\\.|[^\'\\])|\\r|\\n))*\'\'\'', String), # Simple long string alt (r'"""(([^\'\\]|\\.)|\\r|\\n)*((""?)?(\{\{?""?)*\{\{\{\{*)', String), # Start long string (r'\}\}\}(((\\.|[^\'\\])|\\r|\\n))*(""?)?(\{\{?""?)*\{\{\{\{*', String), # Mid long string (r'\}\}\}(((\\.|[^\'\\])|\\r|\\n))*(\{\{?)?(""?\{\{?)*""""*', String), # End long string (r'"(\\.|([^"}{\\]))*"', String), # Simple String (r'"(\\.|([^"}{\\]))*\{', String), # Start string (r'\}(\\.|([^"}{\\]))*\{', String), # Mid String (r'\}(\\.|([^"}{\\]))*"', String), # End String (r'(\'[^\'\\]\')|(\'\\.\')', String.Char), (r'[0-9]+', Number.Integer), (r'[0-9]*.[0-9]+', Number.Float), (r'0(x|X)[0-9A-Fa-f]+', Number.Hex), (r'[a-z]\w*', Name), (r'_\w+', Name.Variable.Instance), (r'==|!=|<==>|>=|>>|>|<=|<<|<|\+|-|=|/|\*|%|\+=|-=|!|@', Operator), (r'\(|\)|\[|\]|,|\.\.\.|\.\.|\.|::|:', Punctuation), (r'`\{[^`]*`\}', Text), # Extern blocks won't be Lexed by Nit (r'[\r\n\t ]+', Text), ], }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144""" pygments.lexers.nix ~~~~~~~~~~~~~~~~~~~
Lexers for the NixOS Nix language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
import re
from pygments.lexer import RegexLexer, includefrom pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Literal
__all__ = ['NixLexer']
class NixLexer(RegexLexer): """ For the Nix language. """
name = 'Nix' url = 'http://nixos.org/nix/' aliases = ['nixos', 'nix'] filenames = ['*.nix'] mimetypes = ['text/x-nix'] version_added = '2.0'
keywords = ['rec', 'with', 'let', 'in', 'inherit', 'assert', 'if', 'else', 'then', '...'] builtins = ['import', 'abort', 'baseNameOf', 'dirOf', 'isNull', 'builtins', 'map', 'removeAttrs', 'throw', 'toString', 'derivation'] operators = ['++', '+', '?', '.', '!', '//', '==', '/', '!=', '&&', '||', '->', '=', '<', '>', '*', '-']
punctuations = ["(", ")", "[", "]", ";", "{", "}", ":", ",", "@"]
tokens = { 'root': [ # comments starting with # (r'#.*$', Comment.Single),
# multiline comments (r'/\*', Comment.Multiline, 'comment'),
# whitespace (r'\s+', Text),
# keywords ('({})'.format('|'.join(re.escape(entry) + '\\b' for entry in keywords)), Keyword),
# highlight the builtins ('({})'.format('|'.join(re.escape(entry) + '\\b' for entry in builtins)), Name.Builtin),
(r'\b(true|false|null)\b', Name.Constant),
# floats (r'-?(\d+\.\d*|\.\d+)([eE][-+]?\d+)?', Number.Float),
# integers (r'-?[0-9]+', Number.Integer),
# paths (r'[\w.+-]*(\/[\w.+-]+)+', Literal), (r'~(\/[\w.+-]+)+', Literal), (r'\<[\w.+-]+(\/[\w.+-]+)*\>', Literal),
# operators ('({})'.format('|'.join(re.escape(entry) for entry in operators)), Operator),
# word operators (r'\b(or|and)\b', Operator.Word),
(r'\{', Punctuation, 'block'),
# punctuations ('({})'.format('|'.join(re.escape(entry) for entry in punctuations)), Punctuation),
# strings (r'"', String.Double, 'doublequote'), (r"''", String.Multiline, 'multiline'),
# urls (r'[a-zA-Z][a-zA-Z0-9\+\-\.]*\:[\w%/?:@&=+$,\\.!~*\'-]+', Literal),
# names of variables (r'[\w-]+(?=\s*=)', String.Symbol), (r'[a-zA-Z_][\w\'-]*', Text),
(r"\$\{", String.Interpol, 'antiquote'), ], 'comment': [ (r'[^/*]+', Comment.Multiline), (r'/\*', Comment.Multiline, '#push'), (r'\*/', Comment.Multiline, '#pop'), (r'[*/]', Comment.Multiline), ], 'multiline': [ (r"''(\$|'|\\n|\\r|\\t|\\)", String.Escape), (r"''", String.Multiline, '#pop'), (r'\$\{', String.Interpol, 'antiquote'), (r"[^'\$]+", String.Multiline), (r"\$[^\{']", String.Multiline), (r"'[^']", String.Multiline), (r"\$(?=')", String.Multiline), ], 'doublequote': [ (r'\\(\\|"|\$|n)', String.Escape), (r'"', String.Double, '#pop'), (r'\$\{', String.Interpol, 'antiquote'), (r'[^"\\\$]+', String.Double), (r'\$[^\{"]', String.Double), (r'\$(?=")', String.Double), (r'\\', String.Double), ], 'antiquote': [ (r"\}", String.Interpol, '#pop'), # TODO: we should probably escape also here ''${ \${ (r"\$\{", String.Interpol, '#push'), include('root'), ], 'block': [ (r"\}", Punctuation, '#pop'), include('root'), ], }
def analyse_text(text): rv = 0.0 # TODO: let/in if re.search(r'import.+?<[^>]+>', text): rv += 0.4 if re.search(r'mkDerivation\s+(\(|\{|rec)', text): rv += 0.4 if re.search(r'=\s+mkIf\s+', text): rv += 0.4 if re.search(r'\{[a-zA-Z,\s]+\}:', text): rv += 0.1 return rv123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263""" pygments.lexers.numbair ~~~~~~~~~~~~~~~~~~~~~~~
Lexer for other Numba Intermediate Representation.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details."""
from pygments.lexer import RegexLexer, include, bygroups, wordsfrom pygments.token import Whitespace, Name, String, Punctuation, Keyword, \ Operator, Number
__all__ = ["NumbaIRLexer"]
class NumbaIRLexer(RegexLexer): """ Lexer for Numba IR """ name = 'Numba_IR' url = "https://numba.readthedocs.io/en/stable/developer/architecture.html#stage-2-generate-the-numba-ir" aliases = ['numba_ir', 'numbair'] filenames = ['*.numba_ir'] mimetypes = ['text/x-numba_ir', 'text/x-numbair'] version_added = '2.19'
identifier = r'\$[a-zA-Z0-9._]+' fun_or_var = r'([a-zA-Z_]+[a-zA-Z0-9]*)'
tokens = { 'root' : [ (r'(label)(\ [0-9]+)(:)$', bygroups(Keyword, Name.Label, Punctuation)),
(r'=', Operator), include('whitespace'), include('keyword'),
(identifier, Name.Variable), (fun_or_var + r'(\()', bygroups(Name.Function, Punctuation)), (fun_or_var + r'(\=)', bygroups(Name.Attribute, Punctuation)), (fun_or_var, Name.Constant), (r'[0-9]+', Number),
# <built-in function some> (r'<[^>\n]*>', String),
(r'[=<>{}\[\]()*.,!\':]|x\b', Punctuation) ],
'keyword':[ (words(( 'del', 'jump', 'call', 'branch', ), suffix=' '), Keyword), ],
'whitespace': [ (r'(\n|\s)+', Whitespace), ], }.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/lisp.pyAdded
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/macaulay2.pyAdded+1847
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/make.pyAdded+212
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/maple.pyAdded+291
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/markup.pyAdded+1659
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/math.pyAdded+21
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/matlab.pyAdded
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/maxima.pyAdded+84
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/meson.pyAdded+139
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/mime.pyAdded+210
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/minecraft.pyAdded+392
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/mips.pyAdded+130
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/ml.pyAdded+958
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/modeling.pyAdded+368
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/modula2.pyAdded+1579
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/mojo.pyAdded+707
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/monte.pyAdded+203
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/mosel.pyAdded+447
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/ncl.pyAdded+894
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/nimrod.pyAdded+199
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/nit.pyAdded+63
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/nix.pyAdded+144
.cache/uv/archive-v0/RMeM3AGJKqUJ7n75un4yi/pygments/lexers/numbair.pyAdded+63