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			{`(true|false)\b`, KeywordConstant, nil},
25			{`(local|global|const)\b`, KeywordDeclaration, nil},
26			{Words(``, `\b`, `function`, `type`, `typealias`, `abstract`, `immutable`, `mutable`, `struct`, `baremodule`, `begin`, `bitstype`, `break`, `catch`, `ccall`, `continue`, `do`, `else`, `elseif`, `end`, `export`, `finally`, `for`, `if`, `import`, `importall`, `let`, `macro`, `module`, `quote`, `return`, `try`, `using`, `while`), Keyword, nil},
27			{Words(``, `\b`, `ANY`, `ASCIIString`, `AbstractArray`, `AbstractChannel`, `AbstractFloat`, `AbstractMatrix`, `AbstractRNG`, `AbstractSparseArray`, `AbstractSparseMatrix`, `AbstractSparseVector`, `AbstractString`, `AbstractVecOrMat`, `AbstractVector`, `Any`, `ArgumentError`, `Array`, `AssertionError`, `Associative`, `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},
28			{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},
29			{Words(``, ``, `=`, `:=`, `+=`, `-=`, `*=`, `/=`, `//=`, `.//=`, `.*=`, `./=`, `\=`, `.\=`, `^=`, `.^=`, `÷=`, `.÷=`, `%=`, `.%=`, `|=`, `&=`, `$=`, `=>`, `<<=`, `>>=`, `>>>=`, `~`, `.+=`, `.-=`, `?`, `--`, `-->`, `||`, `&&`, `>`, `<`, `>=`, `≥`, `<=`, `≤`, `==`, `===`, `≡`, `!=`, `≠`, `!==`, `≢`, `.>`, `.<`, `.>=`, `.≥`, `.<=`, `.≤`, `.==`, `.!=`, `.≠`, `.=`, `.!`, `<:`, `>:`, `∈`, `∉`, `∋`, `∌`, `⊆`, `⊈`, `⊂`, `⊄`, `⊊`, `|>`, `<|`, `:`, `+`, `-`, `.+`, `.-`, `|`, `∪`, `$`, `<<`, `>>`, `>>>`, `.<<`, `.>>`, `.>>>`, `*`, `/`, `./`, `÷`, `.÷`, `%`, `⋅`, `.%`, `.*`, `\`, `.\`, `&`, `∩`, `//`, `.//`, `^`, `.^`, `::`, `.`, `+`, `-`, `!`, `~`, `√`, `∛`, `∜`), Operator, nil},
30			{`'(\\.|\\[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},
31			{`(?<=[.\w)\]])\'+`, Operator, nil},
32			{`"""`, LiteralString, Push("tqstring")},
33			{`"`, LiteralString, Push("string")},
34			{`r"""`, LiteralStringRegex, Push("tqregex")},
35			{`r"`, LiteralStringRegex, Push("regex")},
36			{"`", LiteralStringBacktick, Push("command")},
37			{`(?:[a-zA-Z_¡-￿]|[��-��])(?:[a-zA-Z_0-9¡-￿]|[��-��])*!*`, Name, nil},
38			{`@(?:[a-zA-Z_¡-￿]|[��-��])(?:[a-zA-Z_0-9¡-￿]|[��-��])*!*`, NameDecorator, nil},
39			{`(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?`, LiteralNumberFloat, nil},
40			{`(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?`, LiteralNumberFloat, nil},
41			{`\d+(_\d+)+[eEf][+-]?[0-9]+`, LiteralNumberFloat, nil},
42			{`\d+[eEf][+-]?[0-9]+`, LiteralNumberFloat, nil},
43			{`0b[01]+(_[01]+)+`, LiteralNumberBin, nil},
44			{`0b[01]+`, LiteralNumberBin, nil},
45			{`0o[0-7]+(_[0-7]+)+`, LiteralNumberOct, nil},
46			{`0o[0-7]+`, LiteralNumberOct, nil},
47			{`0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+`, LiteralNumberHex, nil},
48			{`0x[a-fA-F0-9]+`, LiteralNumberHex, nil},
49			{`\d+(_\d+)+`, LiteralNumberInteger, nil},
50			{`\d+`, LiteralNumberInteger, nil},
51		},
52		"blockcomment": {
53			{`[^=#]`, CommentMultiline, nil},
54			{`#=`, CommentMultiline, Push()},
55			{`=#`, CommentMultiline, Pop(1)},
56			{`[=#]`, CommentMultiline, nil},
57		},
58		"string": {
59			{`"`, LiteralString, Pop(1)},
60			{`\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)`, LiteralStringEscape, nil},
61			{`\$(?:[a-zA-Z_¡-￿]|[��-��])(?:[a-zA-Z_0-9¡-￿]|[��-��])*!*`, LiteralStringInterpol, nil},
62			{`(\$)(\()`, ByGroups(LiteralStringInterpol, Punctuation), Push("in-intp")},
63			{`%[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]`, LiteralStringInterpol, nil},
64			{`.|\s`, LiteralString, nil},
65		},
66		"tqstring": {
67			{`"""`, LiteralString, Pop(1)},
68			{`\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)`, LiteralStringEscape, nil},
69			{`\$(?:[a-zA-Z_¡-￿]|[��-��])(?:[a-zA-Z_0-9¡-￿]|[��-��])*!*`, LiteralStringInterpol, nil},
70			{`(\$)(\()`, ByGroups(LiteralStringInterpol, Punctuation), Push("in-intp")},
71			{`.|\s`, LiteralString, nil},
72		},
73		"regex": {
74			{`"`, LiteralStringRegex, Pop(1)},
75			{`\\"`, LiteralStringRegex, nil},
76			{`.|\s`, LiteralStringRegex, nil},
77		},
78		"tqregex": {
79			{`"""`, LiteralStringRegex, Pop(1)},
80			{`.|\s`, LiteralStringRegex, nil},
81		},
82		"command": {
83			{"`", LiteralStringBacktick, Pop(1)},
84			{`\$(?:[a-zA-Z_¡-￿]|[��-��])(?:[a-zA-Z_0-9¡-￿]|[��-��])*!*`, LiteralStringInterpol, nil},
85			{`(\$)(\()`, ByGroups(LiteralStringInterpol, Punctuation), Push("in-intp")},
86			{`.|\s`, LiteralStringBacktick, nil},
87		},
88		"in-intp": {
89			{`\(`, Punctuation, Push()},
90			{`\)`, Punctuation, Pop(1)},
91			Include("root"),
92		},
93	},
94))
95