//WindTerm Cmd Lexer
//Version: 1.0
{
	"name": "Cmd",
	"scopeName": "source.cmd",
	"patterns" : [
		{
			"begin": "(?m)^([^\\n\\\\>]*+\\\\[^\\n>]*+)(>)",
			"captures": {
				"1": {
					"name": "entity.name.filename.find-in-files.cmd"
				},
				"2": {
					"name": "keyword.control.directive.diagnostic.cmd"
				}
			},
			"end": "\\n",
			"name": "prompt.line.cmd",
			"patterns": [
				{
					"include": "#path"
				},
				{
					"include": "#command"
				},
				{
					"include": "#option"
				},
				{
					"include": "#operator"
				},
				{
					"include": "#string"
				},
				{
					"include": "#ip"
				},
				{
					"include": "#number"
				}
			]
		},
		{
			"include": "#keyword"
		},
		{
			"include": "#option"
		},
		{
			"include": "#operator"
		},
		{
			"include": "#string"
		},
		{
			"include": "#ip"
		},
		{
			"include": "#datetime"
		},
		{
			"include": "#number"
		},
		{
			"include": "#url"
		},
		{
			"include": "#email"
		}
	],
	"repository": {
		"command": {
			"match": "(?-m)(?<=[\\|>])[^\\n\\S]{0,99}(\\w++(\\.\\w+)?)(?!:)\\b",
			"captures": {
				"1": {
					"name": "support.function.cmd"
				}
			}
		},
		"datetime": {
			"patterns": [
				{
					"match": "\\b\\d{4}[/-]\\d{1,2}[/-]\\d{1,2}\\b",
					"name": "markup.heading.cmd"
				},
				{
					"match": "(?i)\\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sept?|Oct|Nov|Dec)\\b",
					"name": "markup.heading.cmd"
				},
				{
					"match": "(?i)\\b(Mon|Tues|Wed|Thur|Fri|Sat|Sun)\\b",
					"name": "markup.heading.cmd"
				},
				{
					"match": "\\b\\d{1,2}(:\\d{2}){1,2}\\b",
					"name": "markup.heading.cmd"
				}
			]
		},
		"email": {
			"match": "[\\w-]++@[\\w-]++(\\.[\\w-]++)++",
			"name": "support.constant.cmd"
		},
		"ip": {
			"match": "\\b(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\b",
			"name": "markup.heading.cmd"
		},
		"keyword": {
			"patterns": [
				{
					"match": "(?i)\\b(bad|cannot( \\w++)?|debug|denied|deprecated|errors?|fail(ed)?|failure|important|info|incorrect|invalid|no|(do )?not( \\w++)?|pass(ed)?|refused|success|unknown|unsupported|warning|wrong)\\b",
					"name": "token.error-token.cmd"
				},
				{
					"match": "(?i)\\b(closed|exited|disconnected|stopped|terminated)\\b",
					"name": "token.warn-token.cmd"
				},
				{
					"match": "(?i)\\b(access|authentication|connection|disconnection|login|operation|password|permission)\\b",
					"name": "token.info-token.cmd"
				}
			]
		},
		"number": {
			"patterns": [
				{
					"match": "(?<!\\w)(?<![_/\\d\\.-])\\d++(\\.\\d++)*+%?(?![_-])(?=\\b|\\s)",
					"name": "constant.numeric.cmd"
				}
			]
		},
		"operator": {
			"match": "[()\\[\\]{}=;|\\?\\*\\$<>&+-]|:(?!\\\\)",
			"name": "markup.heading.cmd"
		},
		"option": {
			"patterns": [
				{
					"match": "(?<=\\[)(-\\w+|--\\w[-\\w]++)(?=]|\\s)",
					"name": "variable.parameter.cmd"
				},
				{
					"match": "(?<=\\s)(?:-\\w|--\\w[-\\w]++(?:(=)(\\w++))?)\\b",
					"name": "variable.parameter.cmd",
					"captures": {
						"1": {
							"name": "meta.diff.cmd"
						},
						"2": {
							"name": "token.info-token.cmd"
						}
					}
				}
			]
		},
		"path": {
			"match": "(?<n>[\\x21-\\xff\\._-]++){0}(\\.\\.?[\\\\/]|\\b[a-zA-Z]:[\\\\/]|//)(\\g<n>[\\\\/]?)*+|\\b[a-zA-Z]:",
			"name": "entity.name.filename.find-in-files.cmd"
		},
		"string": {
			"patterns": [
				{
					"begin": "(['\"])",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.string.begin.cmd"
						}
					},
					"end": "(?=\r|\n)|\\1",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.string.end.cmd"
						}
					},
					"name": "string.quoted.double.cmd",
					"patterns": [
						{
							"include": "#string_placeholder"
						}
					]
				}
			]
		},
		"string_placeholder": {
			"patterns": [
				{
					"match": "(?x) %\n(\\d+\\$)?                           # field (argument #)\n[#0\\- +']*                          # flags\n[,;:_]?                              # separator character (AltiVec)\n((-?\\d+)|\\*(-?\\d+\\$)?)?          # minimum field width\n(\\.((-?\\d+)|\\*(-?\\d+\\$)?)?)?    # precision\n(hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)? # length modifier\n[diouxXDOUeEfFgGaACcSspn%]           # conversion type",
					"name": "constant.other.placeholder.cmd"
				},
				{
					"match": "(%)(?!\"\\s*(PRI|SCN))",
					"captures": {
						"1": {
							"name": "invalid.illegal.placeholder.cmd"
						}
					}
				}
			]
		},
		"url": {
			"match": "(?i)\\b(https?|ftps?|file|scp|sftp)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]",
			"name": "support.constant.cmd"
		}
	}
}
