package j
import "github.com/alecthomas/chroma/lexers/j"
Index ¶
Variables ¶
var JSON = internal.Register(MustNewLexer( &Config{ Name: "JSON", Aliases: []string{"json"}, Filenames: []string{"*.json"}, MimeTypes: []string{"application/json"}, NotMultiline: true, DotAll: true, }, Rules{ "whitespace": { {`\s+`, Text, nil}, }, "simplevalue": { {`(true|false|null)\b`, KeywordConstant, nil}, {`-?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)`, LiteralNumberFloat, nil}, {`-?(0|[1-9]\d*)`, LiteralNumberInteger, nil}, {`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil}, }, "objectattribute": { Include("value"), {`:`, Punctuation, nil}, {`,`, Punctuation, Pop(1)}, {`\}`, Punctuation, Pop(2)}, }, "objectvalue": { Include("whitespace"), {`"(\\\\|\\"|[^"])*"`, NameTag, Push("objectattribute")}, {`\}`, Punctuation, Pop(1)}, }, "arrayvalue": { Include("whitespace"), Include("value"), {`,`, Punctuation, nil}, {`\]`, Punctuation, Pop(1)}, }, "value": { Include("whitespace"), Include("simplevalue"), {`\{`, Punctuation, Push("objectvalue")}, {`\[`, Punctuation, Push("arrayvalue")}, }, "root": { Include("value"), }, }, ))
JSON lexer.
var JSX = internal.Register(MustNewLexer( &Config{ Name: "JSX", Aliases: []string{"react"}, Filenames: []string{"*.jsx", "*.react"}, MimeTypes: []string{"text/jsx", "text/typescript-jsx"}, DotAll: true, }, JSXRules, ))
JSX lexer.
var JSXRules = func() Rules { rules := JavascriptRules.Clone() rules["jsx"] = []Rule{ {`(<)([\w_\-]+)`, ByGroups(Punctuation, NameTag), Push("tag")}, {`(<)(/)(\s*)([\w_\-]+)(\s*)(>)`, ByGroups(Punctuation, Punctuation, Text, NameTag, Text, Punctuation), nil}, } rules["tag"] = []Rule{ {`\s+`, Text, nil}, {`([\w]+\s*)(=)(\s*)`, ByGroups(NameAttribute, Operator, Text), Push("attr")}, {`[{}]+`, Punctuation, nil}, {`[\w\.]+`, NameAttribute, nil}, {`(/?)(\s*)(>)`, ByGroups(Punctuation, Text, Punctuation), Pop(1)}, } rules["attr"] = []Rule{ {`\s+`, Text, nil}, {`".*?"`, String, Pop(1)}, {`'.*?'`, String, Pop(1)}, {`[^\s>]+`, String, Pop(1)}, } rules["root"] = append([]Rule{Include("jsx")}, rules["root"]...) return rules }()
var Java = internal.Register(MustNewLexer( &Config{ Name: "Java", Aliases: []string{"java"}, Filenames: []string{"*.java"}, MimeTypes: []string{"text/x-java"}, DotAll: true, }, Rules{ "root": { {`[^\S\n]+`, Text, nil}, {`//.*?\n`, CommentSingle, nil}, {`/\*.*?\*/`, CommentMultiline, nil}, {`(assert|break|case|catch|continue|default|do|else|finally|for|if|goto|instanceof|new|return|switch|this|throw|try|while)\b`, Keyword, nil}, {`((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil}, {`@[^\W\d][\w.]*`, NameDecorator, nil}, {"" /* 143 byte string literal not displayed */, KeywordDeclaration, nil}, {`(boolean|byte|char|double|float|int|long|short|void)\b`, KeywordType, nil}, {`(package)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")}, {`(true|false|null)\b`, KeywordConstant, nil}, {`(class|interface)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")}, {`(import(?:\s+static)?)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")}, {`"(\\\\|\\"|[^"])*"`, LiteralString, nil}, {`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil}, {`(\.)((?:[^\W\d]|\$)[\w$]*)`, ByGroups(Operator, NameAttribute), nil}, {`^\s*([^\W\d]|\$)[\w$]*:`, NameLabel, nil}, {`([^\W\d]|\$)[\w$]*`, Name, nil}, {"" /* 270 byte string literal not displayed */, LiteralNumberFloat, nil}, {`0[xX][0-9a-fA-F][0-9a-fA-F_]*[lL]?`, LiteralNumberHex, nil}, {`0[bB][01][01_]*[lL]?`, LiteralNumberBin, nil}, {`0[0-7_]+[lL]?`, LiteralNumberOct, nil}, {`0|[1-9][0-9_]*[lL]?`, LiteralNumberInteger, nil}, {`[~^*!%&\[\](){}<>|+=:;,./?-]`, Operator, nil}, {`\n`, Text, nil}, }, "class": { {`([^\W\d]|\$)[\w$]*`, NameClass, Pop(1)}, }, "import": { {`[\w.]+\*?`, NameNamespace, Pop(1)}, }, }, ))
Java lexer.
var Javascript = internal.Register(MustNewLexer( &Config{ Name: "JavaScript", Aliases: []string{"js", "javascript"}, Filenames: []string{"*.js", "*.jsm"}, MimeTypes: []string{"application/javascript", "application/x-javascript", "text/x-javascript", "text/javascript"}, DotAll: true, EnsureNL: true, }, JavascriptRules, ))
Javascript lexer.
var JavascriptRules = Rules{ "commentsandwhitespace": { {`\s+`, Text, nil}, {`<!--`, Comment, nil}, {`//.*?\n`, CommentSingle, nil}, {`/\*.*?\*/`, CommentMultiline, nil}, }, "slashstartsregex": { Include("commentsandwhitespace"), {`/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/([gimuy]+\b|\B)`, LiteralStringRegex, Pop(1)}, {`(?=/)`, Text, Push("#pop", "badregex")}, Default(Pop(1)), }, "badregex": { {`\n`, Text, Pop(1)}, }, "root": { {`\A#! ?/.*?\n`, CommentHashbang, nil}, Include("commentsandwhitespace"), {`(\.\d+|[0-9]+\.[0-9]*)([eE][-+]?[0-9]+)?`, LiteralNumberFloat, nil}, {`0[bB][01]+`, LiteralNumberBin, nil}, {`0[oO][0-7]+`, LiteralNumberOct, nil}, {`0[xX][0-9a-fA-F]+`, LiteralNumberHex, nil}, {`[0-9]+`, LiteralNumberInteger, nil}, {`\.\.\.|=>`, Punctuation, nil}, {`\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?`, Operator, Push("slashstartsregex")}, {`^(?=\s|/|<!--)`, Text, Push("slashstartsregex")}, {`[{(\[;,]`, Punctuation, Push("slashstartsregex")}, {`[})\].]`, Punctuation, nil}, {"" /* 192 byte string literal not displayed */, Keyword, Push("slashstartsregex")}, {`(var|let|with|function)\b`, KeywordDeclaration, Push("slashstartsregex")}, {"" /* 195 byte string literal not displayed */, KeywordReserved, nil}, {`(true|false|null|NaN|Infinity|undefined)\b`, KeywordConstant, nil}, {"" /* 247 byte string literal not displayed */, NameBuiltin, nil}, {"" /* 15604 byte string literal not displayed */, NameOther, nil}, {`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil}, {`'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil}, {"`", LiteralStringBacktick, Push("interp")}, }, "interp": { {"`", LiteralStringBacktick, Pop(1)}, {`\\\\`, LiteralStringBacktick, nil}, {"\\\\`", LiteralStringBacktick, nil}, {`\$\{`, LiteralStringInterpol, Push("interp-inside")}, {`\$`, LiteralStringBacktick, nil}, {"[^`\\\\$]+", LiteralStringBacktick, nil}, }, "interp-inside": { {`\}`, LiteralStringInterpol, Pop(1)}, Include("root"), }, }
var Julia = internal.Register(MustNewLexer( &Config{ Name: "Julia", Aliases: []string{"julia", "jl"}, Filenames: []string{"*.jl"}, MimeTypes: []string{"text/x-julia", "application/x-julia"}, }, Rules{ "root": { {`\n`, Text, nil}, {`[^\S\n]+`, Text, nil}, {`#=`, CommentMultiline, Push("blockcomment")}, {`#.*$`, Comment, nil}, {`[\[\]{}(),;]`, Punctuation, nil}, {`in\b`, KeywordPseudo, nil}, {`(true|false)\b`, KeywordConstant, nil}, {`(local|global|const)\b`, KeywordDeclaration, nil}, {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}, {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}, {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}, {`'(\\.|\\[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}, {`(?<=[.\w)\]])\'+`, Operator, nil}, {`"""`, LiteralString, Push("tqstring")}, {`"`, LiteralString, Push("string")}, {`r"""`, LiteralStringRegex, Push("tqregex")}, {`r"`, LiteralStringRegex, Push("regex")}, {"`", LiteralStringBacktick, Push("command")}, {`(?:[a-zA-Z_¡-]|[𐀀-])(?:[a-zA-Z_0-9¡-]|[𐀀-])*!*`, Name, nil}, {`@(?:[a-zA-Z_¡-]|[𐀀-])(?:[a-zA-Z_0-9¡-]|[𐀀-])*!*`, NameDecorator, nil}, {`(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?`, LiteralNumberFloat, nil}, {`(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?`, LiteralNumberFloat, nil}, {`\d+(_\d+)+[eEf][+-]?[0-9]+`, LiteralNumberFloat, nil}, {`\d+[eEf][+-]?[0-9]+`, LiteralNumberFloat, nil}, {`0b[01]+(_[01]+)+`, LiteralNumberBin, nil}, {`0b[01]+`, LiteralNumberBin, nil}, {`0o[0-7]+(_[0-7]+)+`, LiteralNumberOct, nil}, {`0o[0-7]+`, LiteralNumberOct, nil}, {`0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+`, LiteralNumberHex, nil}, {`0x[a-fA-F0-9]+`, LiteralNumberHex, nil}, {`\d+(_\d+)+`, LiteralNumberInteger, nil}, {`\d+`, LiteralNumberInteger, nil}, }, "blockcomment": { {`[^=#]`, CommentMultiline, nil}, {`#=`, CommentMultiline, Push()}, {`=#`, CommentMultiline, Pop(1)}, {`[=#]`, CommentMultiline, nil}, }, "string": { {`"`, LiteralString, Pop(1)}, {`\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)`, LiteralStringEscape, nil}, {`\$(?:[a-zA-Z_¡-]|[𐀀-])(?:[a-zA-Z_0-9¡-]|[𐀀-])*!*`, LiteralStringInterpol, nil}, {`(\$)(\()`, ByGroups(LiteralStringInterpol, Punctuation), Push("in-intp")}, {`%[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]`, LiteralStringInterpol, nil}, {`.|\s`, LiteralString, nil}, }, "tqstring": { {`"""`, LiteralString, Pop(1)}, {`\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)`, LiteralStringEscape, nil}, {`\$(?:[a-zA-Z_¡-]|[𐀀-])(?:[a-zA-Z_0-9¡-]|[𐀀-])*!*`, LiteralStringInterpol, nil}, {`(\$)(\()`, ByGroups(LiteralStringInterpol, Punctuation), Push("in-intp")}, {`.|\s`, LiteralString, nil}, }, "regex": { {`"`, LiteralStringRegex, Pop(1)}, {`\\"`, LiteralStringRegex, nil}, {`.|\s`, LiteralStringRegex, nil}, }, "tqregex": { {`"""`, LiteralStringRegex, Pop(1)}, {`.|\s`, LiteralStringRegex, nil}, }, "command": { {"`", LiteralStringBacktick, Pop(1)}, {`\$(?:[a-zA-Z_¡-]|[𐀀-])(?:[a-zA-Z_0-9¡-]|[𐀀-])*!*`, LiteralStringInterpol, nil}, {`(\$)(\()`, ByGroups(LiteralStringInterpol, Punctuation), Push("in-intp")}, {`.|\s`, LiteralStringBacktick, nil}, }, "in-intp": { {`\(`, Punctuation, Push()}, {`\)`, Punctuation, Pop(1)}, Include("root"), }, }, ))
Julia lexer.
var Jungle = internal.Register(MustNewLexer( &Config{ Name: "Jungle", Aliases: []string{"jungle"}, Filenames: []string{"*.jungle"}, MimeTypes: []string{"text/x-jungle"}, }, Rules{ "root": { {`[^\S\n]+`, Text, nil}, {`\n`, Text, nil}, {`#(\n|[\w\W]*?[^#]\n)`, CommentSingle, nil}, {`^(?=\S)`, None, Push("instruction")}, {`[\.;\[\]\(\)\$]`, Punctuation, nil}, {`[a-zA-Z_]\w*`, Name, nil}, }, "instruction": { {`[^\S\n]+`, Text, nil}, {`=`, Operator, Push("value")}, {`(?=\S)`, None, Push("var")}, Default(Pop(1)), }, "value": { {`[^\S\n]+`, Text, nil}, {`\$\(`, Punctuation, Push("var")}, {`[;\[\]\(\)\$]`, Punctuation, nil}, {`#(\n|[\w\W]*?[^#]\n)`, CommentSingle, nil}, {`[\w_\-\.\/\\]+`, Text, nil}, Default(Pop(1)), }, "var": { {`[^\S\n]+`, Text, nil}, {`\b(((re)?source|barrel)Path|excludeAnnotations|annotations|lang)\b`, NameBuiltin, nil}, {`\bbase\b`, NameConstant, nil}, {`\b(ind|zsm|hrv|ces|dan|dut|eng|fin|fre|deu|gre|hun|ita|nob|po[lr]|rus|sl[ov]|spa|swe|ara|heb|zh[st]|jpn|kor|tha|vie|bul|tur)`, NameConstant, nil}, {`\b((semi)?round|rectangle)(-\d+x\d+)?\b`, NameConstant, nil}, {`[\.;\[\]\(\$]`, Punctuation, nil}, {`\)`, Punctuation, Pop(1)}, {`[a-zA-Z_]\w*`, Name, nil}, Default(Pop(1)), }, }, ))
Source Files ¶
java.go javascript.go json.go jsx.go julia.go jungle.go
- Version
- v0.6.3
- Published
- Mar 25, 2019
- Platform
- js/wasm
- Imports
- 2 packages
- Last checked
- 7 minutes ago –
Tools for package owners.