1package j 2 3import ( 4 . "github.com/alecthomas/chroma" // nolint 5 "github.com/alecthomas/chroma/lexers/internal" 6) 7 8// Julia lexer. 9var Julia = internal.Register(MustNewLexer( 10 &Config{ 11 Name: "Julia", 12 Aliases: []string{"julia", "jl"}, 13 Filenames: []string{"*.jl"}, 14 MimeTypes: []string{"text/x-julia", "application/x-julia"}, 15 }, 16 Rules{ 17 "root": { 18 {`\n`, Text, nil}, 19 {`[^\S\n]+`, Text, nil}, 20 {`#=`, CommentMultiline, Push("blockcomment")}, 21 {`#.*$`, Comment, nil}, 22 {`[\[\]{}(),;]`, Punctuation, nil}, 23 {`in\b`, KeywordPseudo, nil}, 24 {`isa\b`, KeywordPseudo, nil}, 25 {`(true|false)\b`, KeywordConstant, nil}, 26 {`(local|global|const)\b`, KeywordDeclaration, nil}, 27 {Words(``, `\b`, `function`, `abstract type`, `primitive type`, `baremodule`, `begin`, `bitstype`, `break`, `catch`, `ccall`, `continue`, `do`, `else`, `elseif`, `end`, `export`, `finally`, `for`, `if`, `import`, `let`, `macro`, `module`, `mutable`, `quote`, `return`, `struct`, `try`, `using`, `while`), Keyword, nil}, 28 {Words(``, `\b`, `ASCIIString`, `AbstractArray`, `AbstractChannel`, `AbstractDict`, `AbstractFloat`, `AbstractMatrix`, `AbstractRNG`, `AbstractSparseArray`, `AbstractSparseMatrix`, `AbstractSparseVector`, `AbstractString`, `AbstractVecOrMat`, `AbstractVector`, `Any`, `ArgumentError`, `Array`, `AssertionError`, `Base64DecodePipe`, `Base64EncodePipe`, `Bidiagonal`, `BigFloat`, `BigInt`, `BitArray`, `BitMatrix`, `BitVector`, `Bool`, `BoundsError`, `Box`, `BufferStream`, `CapturedException`, `CartesianIndex`, `CartesianRange`, `Cchar`, `Cdouble`, `Cfloat`, `Channel`, `Char`, `Cint`, `Cintmax_t`, `Clong`, `Clonglong`, `ClusterManager`, `Cmd`, `Coff_t`, `Colon`, `Complex`, `Complex128`, `Complex32`, `Complex64`, `CompositeException`, `Condition`, `Cptrdiff_t`, `Cshort`, `Csize_t`, `Cssize_t`, `Cstring`, `Cuchar`, `Cuint`, `Cuintmax_t`, `Culong`, `Culonglong`, `Cushort`, `Cwchar_t`, `Cwstring`, `DataType`, `Date`, `DateTime`, `DenseArray`, `DenseMatrix`, `DenseVecOrMat`, `DenseVector`, `Diagonal`, `Dict`, `DimensionMismatch`, `Dims`, `DirectIndexString`, `Display`, `DivideError`, `DomainError`, `EOFError`, `EachLine`, `Enum`, `Enumerate`, `ErrorException`, `Exception`, `Expr`, `Factorization`, `FileMonitor`, `FileOffset`, `Filter`, `Float16`, `Float32`, `Float64`, `FloatRange`, `Function`, `GenSym`, `GlobalRef`, `GotoNode`, `HTML`, `Hermitian`, `IO`, `IOBuffer`, `IOStream`, `IPv4`, `IPv6`, `InexactError`, `InitError`, `Int`, `Int128`, `Int16`, `Int32`, `Int64`, `Int8`, `IntSet`, `Integer`, `InterruptException`, `IntrinsicFunction`, `InvalidStateException`, `Irrational`, `KeyError`, `LabelNode`, `LambdaStaticData`, `LinSpace`, `LineNumberNode`, `LoadError`, `LocalProcess`, `LowerTriangular`, `MIME`, `Matrix`, `MersenneTwister`, `Method`, `MethodError`, `MethodTable`, `Module`, `NTuple`, `NewvarNode`, `NullException`, `Nullable`, `Number`, `ObjectIdDict`, `OrdinalRange`, `OutOfMemoryError`, `OverflowError`, `Pair`, `ParseError`, `PartialQuickSort`, `Pipe`, `PollingFileWatcher`, `ProcessExitedException`, `ProcessGroup`, `Ptr`, `QuoteNode`, `RandomDevice`, `Range`, `Rational`, `RawFD`, `ReadOnlyMemoryError`, `Real`, `ReentrantLock`, `Ref`, `Regex`, `RegexMatch`, `RemoteException`, `RemoteRef`, `RepString`, `RevString`, `RopeString`, `RoundingMode`, `SegmentationFault`, `SerializationState`, `Set`, `SharedArray`, `SharedMatrix`, `SharedVector`, `Signed`, `SimpleVector`, `SparseMatrixCSC`, `StackOverflowError`, `StatStruct`, `StepRange`, `StridedArray`, `StridedMatrix`, `StridedVecOrMat`, `StridedVector`, `SubArray`, `SubString`, `SymTridiagonal`, `Symbol`, `SymbolNode`, `Symmetric`, `SystemError`, `TCPSocket`, `Task`, `Text`, `TextDisplay`, `Timer`, `TopNode`, `Tridiagonal`, `Tuple`, `Type`, `TypeConstructor`, `TypeError`, `TypeName`, `TypeVar`, `UDPSocket`, `UInt`, `UInt128`, `UInt16`, `UInt32`, `UInt64`, `UInt8`, `UTF16String`, `UTF32String`, `UTF8String`, `UndefRefError`, `UndefVarError`, `UnicodeError`, `UniformScaling`, `Union`, `UnitRange`, `Unsigned`, `UpperTriangular`, `Val`, `Vararg`, `VecOrMat`, `Vector`, `VersionNumber`, `Void`, `WString`, `WeakKeyDict`, `WeakRef`, `WorkerConfig`, `Zip`), KeywordType, nil}, 29 {Words(``, `\b`, `ARGS`, `CPU_CORES`, `C_NULL`, `DevNull`, `ENDIAN_BOM`, `ENV`, `I`, `Inf`, `Inf16`, `Inf32`, `Inf64`, `InsertionSort`, `JULIA_HOME`, `LOAD_PATH`, `MergeSort`, `NaN`, `NaN16`, `NaN32`, `NaN64`, `OS_NAME`, `QuickSort`, `RoundDown`, `RoundFromZero`, `RoundNearest`, `RoundNearestTiesAway`, `RoundNearestTiesUp`, `RoundToZero`, `RoundUp`, `STDERR`, `STDIN`, `STDOUT`, `VERSION`, `WORD_SIZE`, `catalan`, `e`, `eu`, `eulergamma`, `golden`, `im`, `nothing`, `pi`, `γ`, `π`, `φ`), NameBuiltin, nil}, 30 {Words(``, ``, `=`, `:=`, `+=`, `-=`, `*=`, `/=`, `//=`, `.//=`, `.*=`, `./=`, `\=`, `.\=`, `^=`, `.^=`, `÷=`, `.÷=`, `%=`, `.%=`, `|=`, `&=`, `$=`, `=>`, `<<=`, `>>=`, `>>>=`, `~`, `.+=`, `.-=`, `?`, `--`, `-->`, `||`, `&&`, `>`, `<`, `>=`, `≥`, `<=`, `≤`, `==`, `===`, `≡`, `!=`, `≠`, `!==`, `≢`, `.>`, `.<`, `.>=`, `.≥`, `.<=`, `.≤`, `.==`, `.!=`, `.≠`, `.=`, `.!`, `<:`, `>:`, `∈`, `∉`, `∋`, `∌`, `⊆`, `⊈`, `⊂`, `⊄`, `⊊`, `|>`, `<|`, `:`, `+`, `-`, `.+`, `.-`, `|`, `∪`, `$`, `<<`, `>>`, `>>>`, `.<<`, `.>>`, `.>>>`, `*`, `/`, `./`, `÷`, `.÷`, `%`, `⋅`, `.%`, `.*`, `\`, `.\`, `&`, `∩`, `//`, `.//`, `^`, `.^`, `::`, `.`, `+`, `-`, `!`, `√`, `∛`, `∜`), Operator, nil}, 31 {`'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'`, LiteralStringChar, nil}, 32 {`(?<=[.\w)\]])\'+`, Operator, nil}, 33 {`"""`, LiteralString, Push("tqstring")}, 34 {`"`, LiteralString, Push("string")}, 35 {`r"""`, LiteralStringRegex, Push("tqregex")}, 36 {`r"`, LiteralStringRegex, Push("regex")}, 37 {"`", LiteralStringBacktick, Push("command")}, 38 {`((?:[a-zA-Z_¡-]|[-])(?:[a-zA-Z_0-9¡-]|[-])*!*)(')?`, ByGroups(Name, Operator), nil}, 39 {`(@(?:[a-zA-Z_¡-]|[-])(?:[a-zA-Z_0-9¡-]|[-])*!*)(')?`, ByGroups(NameDecorator, Operator), nil}, 40 {`(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?`, LiteralNumberFloat, nil}, 41 {`(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?`, LiteralNumberFloat, nil}, 42 {`\d+(_\d+)+[eEf][+-]?[0-9]+`, LiteralNumberFloat, nil}, 43 {`\d+[eEf][+-]?[0-9]+`, LiteralNumberFloat, nil}, 44 {`0b[01]+(_[01]+)+`, LiteralNumberBin, nil}, 45 {`0b[01]+`, LiteralNumberBin, nil}, 46 {`0o[0-7]+(_[0-7]+)+`, LiteralNumberOct, nil}, 47 {`0o[0-7]+`, LiteralNumberOct, nil}, 48 {`0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+`, LiteralNumberHex, nil}, 49 {`0x[a-fA-F0-9]+`, LiteralNumberHex, nil}, 50 {`\d+(_\d+)+`, LiteralNumberInteger, nil}, 51 {`\d+`, LiteralNumberInteger, nil}, 52 }, 53 "blockcomment": { 54 {`[^=#]`, CommentMultiline, nil}, 55 {`#=`, CommentMultiline, Push()}, 56 {`=#`, CommentMultiline, Pop(1)}, 57 {`[=#]`, CommentMultiline, nil}, 58 }, 59 "string": { 60 {`"`, LiteralString, Pop(1)}, 61 {`\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)`, LiteralStringEscape, nil}, 62 {`\$(?:[a-zA-Z_¡-]|[-])(?:[a-zA-Z_0-9¡-]|[-])*!*`, LiteralStringInterpol, nil}, 63 {`(\$)(\()`, ByGroups(LiteralStringInterpol, Punctuation), Push("in-intp")}, 64 {`%[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]`, LiteralStringInterpol, nil}, 65 {`.|\s`, LiteralString, nil}, 66 }, 67 "tqstring": { 68 {`"""`, LiteralString, Pop(1)}, 69 {`\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)`, LiteralStringEscape, nil}, 70 {`\$(?:[a-zA-Z_¡-]|[-])(?:[a-zA-Z_0-9¡-]|[-])*!*`, LiteralStringInterpol, nil}, 71 {`(\$)(\()`, ByGroups(LiteralStringInterpol, Punctuation), Push("in-intp")}, 72 {`.|\s`, LiteralString, nil}, 73 }, 74 "regex": { 75 {`"`, LiteralStringRegex, Pop(1)}, 76 {`\\"`, LiteralStringRegex, nil}, 77 {`.|\s`, LiteralStringRegex, nil}, 78 }, 79 "tqregex": { 80 {`"""`, LiteralStringRegex, Pop(1)}, 81 {`.|\s`, LiteralStringRegex, nil}, 82 }, 83 "command": { 84 {"`", LiteralStringBacktick, Pop(1)}, 85 {`\$(?:[a-zA-Z_¡-]|[-])(?:[a-zA-Z_0-9¡-]|[-])*!*`, LiteralStringInterpol, nil}, 86 {`(\$)(\()`, ByGroups(LiteralStringInterpol, Punctuation), Push("in-intp")}, 87 {`.|\s`, LiteralStringBacktick, nil}, 88 }, 89 "in-intp": { 90 {`\(`, Punctuation, Push()}, 91 {`\)`, Punctuation, Pop(1)}, 92 Include("root"), 93 }, 94 }, 95)) 96