{
	"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
	"name": "Dinoco",
	"scopeName": "source.dinoco",
	"patterns": [
		{ "include": "#comments" },
		{ "include": "#strings" },
		{ "include": "#model_declaration" },
		{ "include": "#config_declaration" },
		{ "include": "#enum_declaration" },
		{ "include": "#primitive_fields" },
		{ "include": "#custom_fields" },
		{ "include": "#model_decorators" },
		{ "include": "#decorators" },
		{ "include": "#named_parameters" },
		{ "include": "#functions" },
		{ "include": "#constants" }
	],
	"repository": {
		"comments": {
			"match": "#.*$",
			"name": "comment.line.number-sign.dinoco"
		},
		"strings": {
			"begin": "\"",
			"end": "\"",
			"name": "string.quoted.double.dinoco"
		},
		"model_declaration": {
			"match": "^\\s*(model)(\\s+([A-Za-z][a-zA-Z0-9_]*))?",
			"captures": {
				"1": { "name": "keyword.control.model.dinoco" },
				"2": { "name": "entity.name.type.class.dinoco" }
			}
		},
		"enum_declaration": {
			"match": "^\\s*(enum)(\\s+([A-Za-z][a-zA-Z_]*))?",
			"captures": {
				"1": { "name": "keyword.control.enum.dinoco" },
				"2": { "name": "entity.name.type.class.dinoco" }
			}
		},
		"config_declaration": {
			"match": "^\\s*(config)\\b",
			"name": "keyword.control.config.dinoco"
		},
		"primitive_fields": {
			"match": "^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s+(String|Integer|Boolean|Json|Float|Date|DateTime)\\b(\\[\\]|\\?)?",
			"captures": {
				"1": { "name": "variable.other.property.dinoco" },
				"2": { "name": "support.type.primitive.dinoco" },
				"3": { "name": "keyword.operator.modifier.dinoco" }
			}
		},
		"custom_fields": {
			"match": "^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s+([A-Za-z][a-zA-Z0-9_]*)\\b(\\[\\]|\\?)?",
			"captures": {
				"1": { "name": "variable.other.property.dinoco" },
				"2": { "name": "constant.language.dinoco" },
				"3": { "name": "keyword.operator.modifier.dinoco" }
			}
		},
		"model_decorators": {
			"patterns": [
				{
					"begin": "(@@)(ids)(\\s*\\()",
					"beginCaptures": {
						"1": { "name": "punctuation.definition.decorator.dinoco" },
						"2": { "name": "entity.name.function.decorator.dinoco" },
						"3": { "name": "punctuation.section.group.begin.dinoco" }
					},
					"end": "(\\))",
					"endCaptures": {
						"1": { "name": "punctuation.section.group.end.dinoco" }
					},
					"patterns": [
						{
							"match": "(\\[|\\]|,)",
							"name": "punctuation.separator.array.dinoco"
						},
						{
							"match": "\\b([A-Za-z_][A-Za-z0-9_]*)\\b",
							"name": "constant.language.dinoco"
						}
					]
				},
				{
					"begin": "(@@)(table_name)(\\s*\\()",
					"beginCaptures": {
						"1": { "name": "punctuation.definition.decorator.dinoco" },
						"2": { "name": "entity.name.function.decorator.dinoco" },
						"3": { "name": "punctuation.section.group.begin.dinoco" }
					},
					"end": "(\\))",
					"endCaptures": {
						"1": { "name": "punctuation.section.group.end.dinoco" }
					},
					"patterns": [
						{ "include": "#strings" }
					]
				},
				{
					"match": "(@@)([a-zA-Z_][a-zA-Z0-9_]*)",
					"captures": {
						"1": { "name": "punctuation.definition.decorator.dinoco" },
						"2": { "name": "entity.name.function.decorator.dinoco" }
					}
				}
			]
		},
		"decorators": {
			"match": "(@)([a-zA-Z_][a-zA-Z0-9_]*)",
			"captures": {
				"1": { "name": "punctuation.definition.decorator.dinoco" },
				"2": { "name": "entity.name.function.decorator.dinoco" }
			}
		},
		"named_parameters": {
			"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\s*(?=:)",
			"name": "variable.parameter"
		},
		"functions": {
			"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\s*(?=\\()",
			"name": "support.function.dinoco"
		},
		"constants": {
			"patterns": [
				{
					"match": "\\b(Cascade|SetNull|SetDefault)\\b",
					"name": "constant.language"
				},
				{
					"match": "\\b(true|false)\\b",
					"name": "constant.language.boolean"
				},
				{
					"match": "\\b\\d+(\\.\\d+)?\\b",
					"name": "constant.numeric"
				},
				{
					"match": ":\\s*\\[([a-zA-Z0-9_]+)\\]",
					"captures": {
						"1": {
							"name": "constant.language"
						}
					}
				},
				{
					"match": "\\((\\w+)\\)",
					"captures": {
						"1": {
							"name": "constant.language"
						}
					}
				}
			]
		}
	}
}
