Repository: alecthomas/chroma
Pull request #258 (2019-06-11 08:10:46)

Update julia.go
They key word is `abstract type`, `abstract` or `type` alone can be defined as new bindings

matbesancon: Tested with:
```go
package main

import (
	"github.com/alecthomas/chroma/quick"
	"os"
)

func main() {
	s := `
	struct Value
		v::Int
	end
	const r = 33
	A = zeros(3,3)
	B = rand(4,3)
	type = typeof(B)
	C = A * B'
	res = C' .+ r
	abstract v = 33
	abstract type K end
	`
	_ = quick.Highlight(os.Stdout, s, "julia", "html", "monokai")
}
```

Results in correct highlighting
alecthomas: Maybe dump that source in `lexers/testdata/julia.actual` then regenerate the expected output with `RECORD=true go test ./lexers`?
matbesancon: Sorry for the delay, just done it and  fixed the similar issue for "primitive type" 
alecthomas: Brilliant, thanks!

Patch:
diff --git a/lexers/j/julia.go b/lexers/j/julia.go
index 5fe4e45..27672a6 100644
--- a/lexers/j/julia.go
+++ b/lexers/j/julia.go
@@ -24,7 +24,7 @@ var Julia = internal.Register(MustNewLexer(
 			{`isa\b`, KeywordPseudo, nil},
 			{`(true|false)\b`, KeywordConstant, nil},
 			{`(local|global|const)\b`, KeywordDeclaration, nil},
-			{Words(``, `\b`, `function`, `abstract`, `baremodule`, `begin`, `bitstype`, `break`, `catch`, `ccall`, `continue`, `do`, `else`, `elseif`, `end`, `export`, `finally`, `for`, `if`, `import`, `let`, `macro`, `module`, `mutable`, `primitive`, `quote`, `return`, `struct`, `try`, `using`, `while`), Keyword, nil},
+			{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},
 			{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},
 			{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},
 			{Words(``, ``, `=`, `:=`, `+=`, `-=`, `*=`, `/=`, `//=`, `.//=`, `.*=`, `./=`, `\=`, `.\=`, `^=`, `.^=`, `÷=`, `.÷=`, `%=`, `.%=`, `|=`, `&=`, `$=`, `=>`, `<<=`, `>>=`, `>>>=`, `~`, `.+=`, `.-=`, `?`, `--`, `-->`, `||`, `&&`, `>`, `<`, `>=`, `≥`, `<=`, `≤`, `==`, `===`, `≡`, `!=`, `≠`, `!==`, `≢`, `.>`, `.<`, `.>=`, `.≥`, `.<=`, `.≤`, `.==`, `.!=`, `.≠`, `.=`, `.!`, `<:`, `>:`, `∈`, `∉`, `∋`, `∌`, `⊆`, `⊈`, `⊂`, `⊄`, `⊊`, `|>`, `<|`, `:`, `+`, `-`, `.+`, `.-`, `|`, `∪`, `$`, `<<`, `>>`, `>>>`, `.<<`, `.>>`, `.>>>`, `*`, `/`, `./`, `÷`, `.÷`, `%`, `⋅`, `.%`, `.*`, `\`, `.\`, `&`, `∩`, `//`, `.//`, `^`, `.^`, `::`, `.`, `+`, `-`, `!`, `√`, `∛`, `∜`), Operator, nil},


Test patch:
diff --git a/lexers/testdata/julia.actual b/lexers/testdata/julia.actual
index cdddca4..1af5f30 100644
--- a/lexers/testdata/julia.actual
+++ b/lexers/testdata/julia.actual
@@ -1,6 +1,18 @@
-% Implementing Feed Forward to calculate H
+% Defining basic types
 
-m = size(X, 1);
-X = [ones(m, 1) X];
-Z2 = Theta1 * X';
-A2 = sigmoid(Z2);
\ No newline at end of file
+struct Value
+    v::Int
+end
+const r = 33
+
+A = zeros(3,3)
+B = rand(4,3)
+
+type = typeof(B)
+C = A * B'
+res = C' .+ r
+
+const abstract = 33
+abstract type K end
+
+primitive type MyFloat32 32 end
diff --git a/lexers/testdata/julia.expected b/lexers/testdata/julia.expected
index c8f2026..227b000 100644
--- a/lexers/testdata/julia.expected
+++ b/lexers/testdata/julia.expected
@@ -1,64 +1,103 @@
 [
   {"type":"Operator","value":"%"},
   {"type":"Text","value":" "},
-  {"type":"Name","value":"Implementing"},
+  {"type":"Name","value":"Defining"},
   {"type":"Text","value":" "},
-  {"type":"Name","value":"Feed"},
+  {"type":"Name","value":"basic"},
   {"type":"Text","value":" "},
-  {"type":"Name","value":"Forward"},
+  {"type":"Name","value":"types"},
+  {"type":"Text","value":"\n\n"},
+  {"type":"Keyword","value":"struct"},
+  {"type":"Text","value":" "},
+  {"type":"Name","value":"Value"},
+  {"type":"Text","value":"\n    "},
+  {"type":"Name","value":"v"},
+  {"type":"Operator","value":"::"},
+  {"type":"KeywordType","value":"Int"},
+  {"type":"Text","value":"\n"},
+  {"type":"Keyword","value":"end"},
+  {"type":"Text","value":"\n"},
+  {"type":"KeywordDeclaration","value":"const"},
   {"type":"Text","value":" "},
-  {"type":"Name","value":"to"},
+  {"type":"Name","value":"r"},
   {"type":"Text","value":" "},
-  {"type":"Name","value":"calculate"},
+  {"type":"Operator","value":"="},
   {"type":"Text","value":" "},
-  {"type":"Name","value":"H"},
+  {"type":"LiteralNumberInteger","value":"33"},
   {"type":"Text","value":"\n\n"},
-  {"type":"Name","value":"m"},
+  {"type":"Name","value":"A"},
   {"type":"Text","value":" "},
   {"type":"Operator","value":"="},
   {"type":"Text","value":" "},
-  {"type":"Name","value":"size"},
+  {"type":"Name","value":"zeros"},
   {"type":"Punctuation","value":"("},
-  {"type":"Name","value":"X"},
+  {"type":"LiteralNumberInteger","value":"3"},
   {"type":"Punctuation","value":","},
-  {"type":"Text","value":" "},
-  {"type":"LiteralNumberInteger","value":"1"},
-  {"type":"Punctuation","value":");"},
+  {"type":"LiteralNumberInteger","value":"3"},
+  {"type":"Punctuation","value":")"},
   {"type":"Text","value":"\n"},
-  {"type":"Name","value":"X"},
+  {"type":"Name","value":"B"},
   {"type":"Text","value":" "},
   {"type":"Operator","value":"="},
   {"type":"Text","value":" "},
-  {"type":"Punctuation","value":"["},
-  {"type":"Name","value":"ones"},
+  {"type":"Name","value":"rand"},
   {"type":"Punctuation","value":"("},
-  {"type":"Name","value":"m"},
+  {"type":"LiteralNumberInteger","value":"4"},
   {"type":"Punctuation","value":","},
-  {"type":"Text","value":" "},
-  {"type":"LiteralNumberInteger","value":"1"},
+  {"type":"LiteralNumberInteger","value":"3"},
   {"type":"Punctuation","value":")"},
+  {"type":"Text","value":"\n\n"},
+  {"type":"Name","value":"type"},
+  {"type":"Text","value":" "},
+  {"type":"Operator","value":"="},
   {"type":"Text","value":" "},
-  {"type":"Name","value":"X"},
-  {"type":"Punctuation","value":"];"},
+  {"type":"Name","value":"typeof"},
+  {"type":"Punctuation","value":"("},
+  {"type":"Name","value":"B"},
+  {"type":"Punctuation","value":")"},
   {"type":"Text","value":"\n"},
-  {"type":"Name","value":"Z2"},
+  {"type":"Name","value":"C"},
   {"type":"Text","value":" "},
   {"type":"Operator","value":"="},
   {"type":"Text","value":" "},
-  {"type":"Name","value":"Theta1"},
+  {"type":"Name","value":"A"},
   {"type":"Text","value":" "},
   {"type":"Operator","value":"*"},
   {"type":"Text","value":" "},
-  {"type":"Name","value":"X"},
+  {"type":"Name","value":"B"},
   {"type":"Operator","value":"'"},
-  {"type":"Punctuation","value":";"},
   {"type":"Text","value":"\n"},
-  {"type":"Name","value":"A2"},
+  {"type":"Name","value":"res"},
   {"type":"Text","value":" "},
   {"type":"Operator","value":"="},
   {"type":"Text","value":" "},
-  {"type":"Name","value":"sigmoid"},
-  {"type":"Punctuation","value":"("},
-  {"type":"Name","value":"Z2"},
-  {"type":"Punctuation","value":");"}
+  {"type":"Name","value":"C"},
+  {"type":"Operator","value":"'"},
+  {"type":"Text","value":" "},
+  {"type":"Operator","value":".+"},
+  {"type":"Text","value":" "},
+  {"type":"Name","value":"r"},
+  {"type":"Text","value":"\n\n"},
+  {"type":"KeywordDeclaration","value":"const"},
+  {"type":"Text","value":" "},
+  {"type":"Name","value":"abstract"},
+  {"type":"Text","value":" "},
+  {"type":"Operator","value":"="},
+  {"type":"Text","value":" "},
+  {"type":"LiteralNumberInteger","value":"33"},
+  {"type":"Text","value":"\n"},
+  {"type":"Keyword","value":"abstract type"},
+  {"type":"Text","value":" "},
+  {"type":"Name","value":"K"},
+  {"type":"Text","value":" "},
+  {"type":"Keyword","value":"end"},
+  {"type":"Text","value":"\n\n"},
+  {"type":"Keyword","value":"primitive type"},
+  {"type":"Text","value":" "},
+  {"type":"Name","value":"MyFloat32"},
+  {"type":"Text","value":" "},
+  {"type":"LiteralNumberInteger","value":"32"},
+  {"type":"Text","value":" "},
+  {"type":"Keyword","value":"end"},
+  {"type":"Text","value":"\n"}
 ]