diff options
Diffstat (limited to 'vendor/github.com/alecthomas/chroma/lexers/y')
-rw-r--r-- | vendor/github.com/alecthomas/chroma/lexers/y/yaml.go | 50 | ||||
-rw-r--r-- | vendor/github.com/alecthomas/chroma/lexers/y/yang.go | 67 |
2 files changed, 117 insertions, 0 deletions
diff --git a/vendor/github.com/alecthomas/chroma/lexers/y/yaml.go b/vendor/github.com/alecthomas/chroma/lexers/y/yaml.go new file mode 100644 index 0000000000..82fed0c0f4 --- /dev/null +++ b/vendor/github.com/alecthomas/chroma/lexers/y/yaml.go @@ -0,0 +1,50 @@ +package y + +import ( + . "github.com/alecthomas/chroma" // nolint + "github.com/alecthomas/chroma/lexers/internal" +) + +var YAML = internal.Register(MustNewLexer( + &Config{ + Name: "YAML", + Aliases: []string{"yaml"}, + Filenames: []string{"*.yaml", "*.yml"}, + MimeTypes: []string{"text/x-yaml"}, + }, + Rules{ + "root": { + Include("whitespace"), + {`^---`, Text, nil}, + {`[\n?]?\s*- `, Text, nil}, + {`#.*$`, Comment, nil}, + {`!![^\s]+`, CommentPreproc, nil}, + {`&[^\s]+`, CommentPreproc, nil}, + {`\*[^\s]+`, CommentPreproc, nil}, + {`^%include\s+[^\n\r]+`, CommentPreproc, nil}, + {`([>|+-]\s+)(\s+)((?:(?:.*?$)(?:[\n\r]*?)?)*)`, ByGroups(StringDoc, StringDoc, StringDoc), nil}, + Include("key"), + Include("value"), + {`[?:,\[\]]`, Punctuation, nil}, + {`.`, Text, nil}, + }, + "value": { + {Words(``, `\b`, "true", "false", "null"), KeywordConstant, nil}, + {`"(?:\\.|[^"])*"`, StringDouble, nil}, + {`'(?:\\.|[^'])*'`, StringSingle, nil}, + {`\d\d\d\d-\d\d-\d\d([T ]\d\d:\d\d:\d\d(\.\d+)?(Z|\s+[-+]\d+)?)?`, LiteralDate, nil}, + {`\b[+\-]?(0x[\da-f]+|0o[0-7]+|(\d+\.?\d*|\.?\d+)(e[\+\-]?\d+)?|\.inf|\.nan)\b`, Number, nil}, + {`\b[\w]+\b`, Text, nil}, + }, + "key": { + {`"[^"\n].*": `, Keyword, nil}, + {`(-)( )([^"\n{]*)(:)( )`, ByGroups(Punctuation, Whitespace, Keyword, Punctuation, Whitespace), nil}, + {`([^"\n{]*)(:)( )`, ByGroups(Keyword, Punctuation, Whitespace), nil}, + {`([^"\n{]*)(:)(\n)`, ByGroups(Keyword, Punctuation, Whitespace), nil}, + }, + "whitespace": { + {`\s+`, Whitespace, nil}, + {`\n+`, Whitespace, nil}, + }, + }, +)) diff --git a/vendor/github.com/alecthomas/chroma/lexers/y/yang.go b/vendor/github.com/alecthomas/chroma/lexers/y/yang.go new file mode 100644 index 0000000000..73edb71e63 --- /dev/null +++ b/vendor/github.com/alecthomas/chroma/lexers/y/yang.go @@ -0,0 +1,67 @@ +package y + +import ( + . "github.com/alecthomas/chroma" // nolint + "github.com/alecthomas/chroma/lexers/internal" +) + +var YANG = internal.Register(MustNewLexer( + &Config{ + Name: "YANG", + Aliases: []string{"yang"}, + Filenames: []string{"*.yang"}, + MimeTypes: []string{"application/yang"}, + }, + Rules{ + "root": { + {`\s+`, Whitespace, nil}, + {`[\{\}\;]+`, Punctuation, nil}, + {`(?<![\-\w])(and|or|not|\+|\.)(?![\-\w])`, Operator, nil}, + + {`"(?:\\"|[^"])*?"`, StringDouble, nil}, + {`'(?:\\'|[^'])*?'`, StringSingle, nil}, + + {`/\*`, CommentMultiline, Push("comments")}, + {`//.*?$`, CommentSingle, nil}, + + //match BNF stmt for `node-identifier` with [ prefix ":"] + {`(?:^|(?<=[\s{};]))([\w.-]+)(:)([\w.-]+)(?=[\s{};])`, ByGroups(KeywordNamespace, Punctuation, Text), nil}, + + //match BNF stmt `date-arg-str` + {`([0-9]{4}\-[0-9]{2}\-[0-9]{2})(?=[\s\{\}\;])`, LiteralDate, nil}, + {`([0-9]+\.[0-9]+)(?=[\s\{\}\;])`, NumberFloat, nil}, + {`([0-9]+)(?=[\s\{\}\;])`, NumberInteger, nil}, + + //TOP_STMTS_KEYWORDS + {Words(``, `(?=[^\w\-\:])`, `module`, `submodule`), Keyword, nil}, + //MODULE_HEADER_STMT_KEYWORDS + {Words(``, `(?=[^\w\-\:])`, `belongs-to`, `namespace`, `prefix`, `yang-version`), Keyword, nil}, + //META_STMT_KEYWORDS + {Words(``, `(?=[^\w\-\:])`, `contact`, `description`, `organization`, `reference`, `revision`), Keyword, nil}, + //LINKAGE_STMTS_KEYWORDS + {Words(``, `(?=[^\w\-\:])`, `import`, `include`, `revision-date`), Keyword, nil}, + //BODY_STMT_KEYWORDS + {Words(``, `(?=[^\w\-\:])`, `action`, `argument`, `augment`, `deviation`, `extension`, `feature`, `grouping`, `identity`, `if-feature`, `input`, `notification`, `output`, `rpc`, `typedef`), Keyword, nil}, + //DATA_DEF_STMT_KEYWORDS + {Words(``, `(?=[^\w\-\:])`, `anydata`, `anyxml`, `case`, `choice`, `config`, `container`, `deviate`, `leaf`, `leaf-list`, `list`, `must`, `presence`, `refine`, `uses`, `when`), Keyword, nil}, + //TYPE_STMT_KEYWORDS + {Words(``, `(?=[^\w\-\:])`, `base`, `bit`, `default`, `enum`, `error-app-tag`, `error-message`, `fraction-digits`, `length`, `max-elements`, `min-elements`, `modifier`, `ordered-by`, `path`, `pattern`, `position`, `range`, `require-instance`, `status`, `type`, `units`, `value`, `yin-element`), Keyword, nil}, + //LIST_STMT_KEYWORDS + {Words(``, `(?=[^\w\-\:])`, `key`, `mandatory`, `unique`), Keyword, nil}, + + //CONSTANTS_KEYWORDS - RFC7950 other keywords + {Words(``, `(?=[^\w\-\:])`, `add`, `current`, `delete`, `deprecated`, `false`, `invert-match`, `max`, `min`, `not-supported`, `obsolete`, `replace`, `true`, `unbounded`, `user`), NameClass, nil}, + + //RFC7950 Built-In Types + {Words(``, `(?=[^\w\-\:])`, `binary`, `bits`, `boolean`, `decimal64`, `empty`, `enumeration`, `identityref`, `instance-identifier`, `int16`, `int32`, `int64`, `int8`, `leafref`, `string`, `uint16`, `uint32`, `uint64`, `uint8`, `union`), NameClass, nil}, + + {`[^;{}\s\'\"]+`, Text, nil}, + }, + "comments": { + {`[^*/]`, CommentMultiline, nil}, + {`/\*`, CommentMultiline, Push("comment")}, + {`\*/`, CommentMultiline, Pop(1)}, + {`[*/]`, CommentMultiline, nil}, + }, + }, +)) |