{
	"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
	"name": "Vector Remap Language",
	"scopeName": "source.vrl",
	"patterns": [
		{
			"include": "#bare-punctuation"
		},
		{
			"include": "#comment"
		},
		{
			"include": "#control"
		},
		{
			"include": "#function"
		},
		{
			"include": "#operator"
		},
		{
			"include": "#path"
		},
		{
			"include": "#reserved"
		},
		{
			"include": "#value"
		},
		{
			"include": "#variable"
		}
	],
	"repository": {
		"array": {
			"comment": "Array value",
			"name": "meta.structure.array.vrl",
			"begin": "\\[",
			"beginCaptures": {
				"0": {
					"name": "punctuation.definition.array.begin.vrl"
				}
			},
			"end": "\\]",
			"endCaptures": {
				"0": {
					"name": "punctuation.definition.array.end.vrl"
				}
			},
			"patterns": [
				{
					"include": "#value"
				},
				{
					"include": "#comma"
				},
				{
					"comment": "Illegal separator",
					"name": "invalid.illegal.array-separator.vrl",
					"match": "[^\\s\\]]"
				},
				{
					"comment": "Comment",
					"include": "#comment"
				},
				{
					"comment": "Variable",
					"include": "#variable"
				}
			]
		},
		"bare-punctuation": {
			"patterns": [
				{
					"include": "#comma"
				}
			]
		},
		"boolean": {
			"comment": "Boolean value",
			"name": "constant.language.boolean.vrl",
			"match": "\\b(true|false)\\b"
		},
		"comma": {
			"comment": "Comma",
			"name": "punctuation.definition.separator.vrl",
			"match": ","
		},
		"comment": {
			"comment": "Comment",
			"name": "comment.vrl",
			"match": "(\\s+)?#(.*)$"
		},
		"control": {
			"comment": "Flow control",
			"name": "keyword.control.vrl",
			"match": "\\b(if|else)\\b"
		},
		"control-block": {
			"comment": "if block",
			"name": ""
		},
		"function": {
			"comment": "Function call",
			"name": "meta.function.method.vrl",
			"begin": "(abort|append|array|assert|assert_eq|bool|ceil|compact|contains|decode_base64|decode_percent|del|downcase|encode_base64|encode_json|encode_key_value|encode_logfmt|encode_percent|ends_with|exists|flatten|float|floor|format_int|format_number|format_timestamp|get_env_var|get_hostname|includes|int|ip_aton|ip_cidr_contains|ip_ntoa|ip_subnet|ip_to_ipv6|ipv6_to_ipv4|is_array|is_boolean|is_float|is_integer|is_null|is_nullish|is_object|is_regex|is_string|is_timestamp|join|length|log|match|match_any|match_array|match_datadog_query|md5|merge|now|object|parse_apache_log|parse_aws_alb_log|parse_aws_cloudwatch_log_subscription_message|parse_aws_vpc_flow_log|parse_common_log|parse_csv|parse_duration|parse_glog|parse_grok|parse_int|parse_json|parse_key_value|parse_klog|parse_linux_authorization|parse_logfmt|parse_nginx_log|parse_query_string|parse_regex|parse_regex_all|parse_ruby_hash|parse_syslog|parse_timestamp|parse_tokens|parse_url|parse_user_agent|parse_xml|push|redact|replace|round|sha1|sha2|sha3|slice|split|starts_with|string|strip_ansi_escape_codes|strip_whitespace|tag_types_externally|timestamp|to_bool|to_float|to_int|to_regex|to_string|to_syslog_facility|to_syslog_level|to_syslog_severity|to_timestamp|to_unix_timestamp|truncate|unnest|upcase|uuid_v4)([!]?)(\\()",
			"beginCaptures": {
				"1": {
					"name": "entity.name.function.vrl"
				},
				"2": {
					"name": "keyword.operator.logical.vrl"
				},
				"3": {
					"name": "punctuation.definition.args.begin.vrl"
				}
			},
			"end": "\\)",
			"endCaptures": {
				"0": {
					"name": "punctuation.definition.args.end.vrl"
				}
			},
			"patterns": [
				{
					"include": "#value"
				},
				{
					"comment": "Comment",
					"include": "#comment"
				},
				{
					"include": "#path"
				},
				{
					"include": "#comma"
				},
				{
					"include": "#variable"
				}
			]
		},
		"null": {
			"comment": "Null value",
			"name": "constant.language.null.vrl",
			"match": "\\b(null)\\b"
		},
		"number": {
			"patterns": [
				{
					"include": "#plain-integer-or-float"
				}
			]
		},
		"object": {
			"comment": "Object value",
			"name": "meta.structure.dictionary.vrl",
			"begin": "\\{",
			"beginCaptures": {
				"0": {
					"name": "punctuation.definition.dictionary.begin.vrl"
				}
			},
			"end": "\\}",
			"endCaptures": {
				"0": {
					"name": "punctuation.definition.dictionary.end.vrl"
				}
			},
			"patterns": [
				{
					"comment": "Object key",
					"include": "#object-key"
				},
				{
					"comment": "Object value",
					"include": "#object-value"
				},
				{
					"match": "[^\\s\\}]",
					"name": "invalid.illegal.expected-dictionary-separator.vrl"
				},
				{
					"comment": "Comment",
					"include": "#comment"
				}
			]
		},
		"object-key": {
			"begin": "\"",
			"beginCaptures": {
				"0": {
					"name": "punctuation.support.type.property-name.begin.vrl"
				}
			},
			"end": "\"",
			"endCaptures": {
				"0": {
					"name": "punctuation.support.type.property-name.end.vrl"
				}
			},
			"patterns": [
				{
					"include": "#string-content"
				}
			]
		},
		"object-value": {
			"name": "meta.structure.dictionary.value.vrl",
			"begin": ":",
			"beginCaptures": {
				"0": {
					"name": "punctuation.separator.dictionary.key-value.vrl"
				}
			},
			"end": "(,)|(?=\\})",
			"endCaptures": {
				"1": {
					"name": "punctuation.separator.dictionary.pair.vrl"
				}
			},
			"patterns": [
				{
					"include": "#function"
				},
				{
					"include": "#value"
				},
				{
					"include": "#variable"
				},
				{
					"match": "[^\\s,]",
					"name": "invalid.illegal.expected-dictionary-separator.vrl"
				},
				{
					"include": "#comment"
				}
			]
		},
		"operator": {
			"patterns": [
				{
					"comment": "Assignment",
					"name": "keyword.operator.assignment.vrl",
					"match": "=|\\|=|\\?\\?"
				},
				{
					"comment": "Comparison",
					"name": "keyword.operator.comparison.vrl",
					"match": "(<|>)(=)?|==|!="
				},
				{
					"comment": "Logical",
					"name": "keyword.operator.logical.vrl",
					"match": "&&|\\|\\|"
				}
			]
		},
		"path": {
			"comment": "Event path",
			"name": "variable.language.path.vrl",
			"match": "\\.(\\w+)?"
		},
		"plain-integer-or-float": {
			"comment": "Plain integer or float value",
			"name": "constant.numeric.vrl",
			"match": "([+-]?([0-9]*[.])?[0-9]+)"
		},
		"regex": {
			"patterns": [
				{
					"comment": "Single-quoted regex value",
					"name": "string.regexp.vrl",
					"begin": "r'",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.regexp.begin.vrl"
						}
					},
					"end": "'",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.regexp.end.vrl"
						}
					}
				}
			]
		},
		"reserved": {
			"comment": "Forbidden reserved terms",
			"name": "invalid.illegal.reserved.vrl",
			"match": "(as|break|continue|for|impl|in|let|loop|return|self|std|then|this|type|until|use|while)"
		},
		"string": {
			"patterns": [
				{
					"comment": "Single-quoted string value",
					"name": "string.quoted.single.vrl",
					"begin": "'",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.string.begin.vrl"
						}
					},
					"end": "'",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.string.end.vrl"
						}
					},
					"patterns": [
						{
							"include": "#string-content"
						}
					]
				},
				{
					"comment": "Double-quoted string value",
					"name": "string.quoted.double.vrl",
					"begin": "\"",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.string.begin.vrl"
						}
					},
					"end": "\"",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.string.end.vrl"
						}
					},
					"patterns": [
						{
							"include": "#string-content"
						}
					]
				},
				{
					"comment": "Single-quoted string literal value",
					"name": "string.quoted.double.vrl",
					"begin": "s'",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.string.begin.vrl"
						}
					},
					"end": "'",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.string.end.vrl"
						}
					},
					"patterns": [
						{
							"include": "#string-content"
						}
					]
				},
				{
					"comment": "Double-quoted string literal value",
					"name": "string.quoted.double.vrl",
					"begin": "s\"",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.string.begin.vrl"
						}
					},
					"end": "\"",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.string.end.vrl"
						}
					},
					"patterns": [
						{
							"include": "#string-content"
						}
					]
				}
			]
		},
		"string-content": {
			"patterns": [
				{
					"match": "(\\w+)",
					"name": "string.vrl"
				}
			]
		},
		"timestamp": {
			"patterns": [
				{
					"comment": "Single-quoted timestamp value",
					"name": "string.quoted.double.vrl",
					"begin": "t'",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.string.begin.vrl"
						}
					},
					"end": "'",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.string.end.vrl"
						}
					},
					"patterns": [
						{
							"include": "#string-content"
						}
					]
				}
			]
		},
		"value": {
			"patterns": [
				{
					"include": "#array"
				},
				{
					"include": "#boolean"
				},
				{
					"include": "#null"
				},
				{
					"include": "#number"
				},
				{
					"include": "#object"
				},
				{
					"include": "#regex"
				},
				{
					"include": "#string"
				},
				{
					"include": "#timestamp"
				}
			]
		},
		"variable": {
			"comment": "Variable",
			"name": "variable.vrl",
			"match": "(?<![.])(\\w+)"
		}
	}
}