mirror of
https://github.com/alecthomas/chroma.git
synced 2025-01-22 03:10:16 +02:00
a10fd0a23d
This makes translating Pygments lexers much much simpler (and possible).
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package lexers
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
)
|
|
|
|
// Apl lexer.
|
|
var Apl = Register(MustNewLexer(
|
|
&Config{
|
|
Name: "APL",
|
|
Aliases: []string{"apl"},
|
|
Filenames: []string{"*.apl"},
|
|
MimeTypes: []string{},
|
|
},
|
|
Rules{
|
|
"root": {
|
|
{`\s+`, Text, nil},
|
|
{`[⍝#].*$`, CommentSingle, nil},
|
|
{`\'((\'\')|[^\'])*\'`, LiteralStringSingle, nil},
|
|
{`"(("")|[^"])*"`, LiteralStringDouble, nil},
|
|
{`[⋄◇()]`, Punctuation, nil},
|
|
{`[\[\];]`, LiteralStringRegex, nil},
|
|
{`⎕[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*`, NameFunction, nil},
|
|
{`[A-Za-zΔ∆⍙][A-Za-zΔ∆⍙_¯0-9]*`, NameVariable, nil},
|
|
{`¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞)([Jj]¯?(0[Xx][0-9A-Fa-f]+|[0-9]*\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞))?`, LiteralNumber, nil},
|
|
{`[\.\\/⌿⍀¨⍣⍨⍠⍤∘]`, NameAttribute, nil},
|
|
{`[+\-×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⌸⍯↗]`, Operator, nil},
|
|
{`⍬`, NameConstant, nil},
|
|
{`[⎕⍞]`, NameVariableGlobal, nil},
|
|
{`[←→]`, KeywordDeclaration, nil},
|
|
{`[⍺⍵⍶⍹∇:]`, NameBuiltinPseudo, nil},
|
|
{`[{}]`, KeywordType, nil},
|
|
},
|
|
},
|
|
))
|