mirror of
https://github.com/alecthomas/chroma.git
synced 2025-03-17 20:58:08 +02:00
add jungle lexer
This commit is contained in:
parent
8387f77374
commit
b18849cbf7
50
lexers/j/jungle.go
Normal file
50
lexers/j/jungle.go
Normal file
@ -0,0 +1,50 @@
|
||||
package j
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
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)),
|
||||
},
|
||||
},
|
||||
))
|
14
lexers/testdata/jungle.actual
vendored
Normal file
14
lexers/testdata/jungle.actual
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
project.manifest = manifest.xml
|
||||
|
||||
#here is a comment
|
||||
base.barrelPath = barrels
|
||||
|
||||
fr235.barrelPath = barrels/IconLibrary.barrel;barrels/GraphLibrary.barrel
|
||||
fr645m.barrelPath = barrels/M.barrel;[A/A.jungle;A/B.jungle]
|
||||
round-215x215.GraphLibrary.annotations = bar
|
||||
|
||||
round.resourcePath = $(base.resourcePath);resource-round
|
||||
DigitsPicker = [..\ScreenPickers\monkey.jungle]
|
||||
base.barrelPath = $(base.barrelPath);$(DigitsPicker)
|
||||
d2bravo.resourcePath = $(d2bravo.resourcePath);resources-round-218x218-ciq_1.x;resources-ciq_1.x-no_hr
|
||||
d2bravo_titanium.resourcePath = $(d2bravo_titanium.resourcePath);resources-round-218x218-ciq_1.x;resources-ciq_1.x
|
105
lexers/testdata/jungle.expected
vendored
Normal file
105
lexers/testdata/jungle.expected
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
[
|
||||
{"type":"Name","value":"project"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"Name","value":"manifest"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Text","value":" manifest.xml\n\n"},
|
||||
{"type":"CommentSingle","value":"#here is a comment\n"},
|
||||
{"type":"NameConstant","value":"base"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"barrelPath"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Text","value":" barrels\n\n"},
|
||||
{"type":"Name","value":"fr235"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"barrelPath"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Text","value":" barrels/IconLibrary.barrel"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"barrels/GraphLibrary.barrel\n"},
|
||||
{"type":"Name","value":"fr645m"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"barrelPath"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Text","value":" barrels/M.barrel"},
|
||||
{"type":"Punctuation","value":";["},
|
||||
{"type":"Text","value":"A/A.jungle"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"A/B.jungle"},
|
||||
{"type":"Punctuation","value":"]"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameConstant","value":"round-215x215"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"Name","value":"GraphLibrary"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"annotations"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Text","value":" bar\n\n"},
|
||||
{"type":"NameConstant","value":"round"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"resourcePath"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"$("},
|
||||
{"type":"NameConstant","value":"base"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"resourcePath"},
|
||||
{"type":"Punctuation","value":");"},
|
||||
{"type":"Text","value":"resource-round\n"},
|
||||
{"type":"Name","value":"DigitsPicker"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"["},
|
||||
{"type":"Text","value":"..\\ScreenPickers\\monkey.jungle"},
|
||||
{"type":"Punctuation","value":"]"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameConstant","value":"base"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"barrelPath"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"$("},
|
||||
{"type":"NameConstant","value":"base"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"barrelPath"},
|
||||
{"type":"Punctuation","value":");$("},
|
||||
{"type":"Name","value":"DigitsPicker"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"Name","value":"d2bravo"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"resourcePath"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"$("},
|
||||
{"type":"Name","value":"d2bravo"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"resourcePath"},
|
||||
{"type":"Punctuation","value":");"},
|
||||
{"type":"Text","value":"resources-round-218x218-ciq_1.x"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"resources-ciq_1.x-no_hr\n"},
|
||||
{"type":"Name","value":"d2bravo_titanium"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"resourcePath"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"$("},
|
||||
{"type":"Name","value":"d2bravo_titanium"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameBuiltin","value":"resourcePath"},
|
||||
{"type":"Punctuation","value":");"},
|
||||
{"type":"Text","value":"resources-round-218x218-ciq_1.x"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"Text","value":"resources-ciq_1.x\n"}
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user