{
	"$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|<% for (var i = 0; i < functions.length; i++) { %><%= functions[i] %><% if (i < (functions.length -1)) { %>|<% } %><% } %>)([!]?)(\\()",
			"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+)"
		}
	}
}