Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
"styling": {
"eyebrows": "breadcrumbs",
"codeblocks": {
"theme": "dracula"
"theme": "dracula",
"languages": {
"custom": [
"/languages/rego.json"
]
}
}
},
"background": {
Expand Down Expand Up @@ -135,6 +140,12 @@
"pages": [
"tutorials/unauthorized_iac_changes"
]
},
{
"group": "Evaluation",
"pages": [
"tutorials/evaluate_trails_with_opa"
]
}
]
},
Expand Down Expand Up @@ -410,6 +421,18 @@
}
]
},
{
"item": "Policy Reference",
"icon": "scroll",
"groups": [
{
"group": "Policies",
"pages": [
"policy-reference/rego_policy"
]
}
]
},
{
"item": "API Reference",
"icon": "code",
Expand Down
286 changes: 286 additions & 0 deletions languages/rego.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
{
"fileTypes": [
"rego"
],
"name": "rego",
"patterns": [
{
"include": "#comment"
},
{
"include": "#keyword"
},
{
"include": "#comparison-operators"
},
{
"include": "#assignment-operators"
},
{
"include": "#term"
}
],
"repository": {
"call": {
"captures": {
"1": {
"name": "support.function.any-method.rego"
}
},
"match": "([a-zA-Z_][a-zA-Z0-9_]*)\\(",
"name": "meta.function-call.rego"
},
"comment": {
"patterns": [
{
"match": "(#)\\s*(METADATA)\\s*$\\n?",
"captures": {
"1": {
"name": "punctuation.definition.comment.rego"
},
"2": {
"name": "strong"
}
},
"name": "comment.line.number-sign.rego"
},
{
"match": "(#)\\s*(scope|title|description|related_resources|authors|organizations|schemas|entrypoint|custom):.*$\\n?",
"captures": {
"1": {
"name": "punctuation.definition.comment.rego"
},
"2": {
"name": "strong"
}
},
"name": "comment.line.number-sign.rego"
},
{
"captures": {
"1": {
"name": "punctuation.definition.comment.rego"
}
},
"match": "(#).*$\\n?",
"name": "comment.line.number-sign.rego"
}
]
},
"constant": {
"match": "\\b(?:true|false|null)\\b",
"name": "constant.language.rego"
},
"root-document": {
"match": "(?<!\\.)\\b(?:input|data)\\b",
"name": "variable.other.constant.rego support.constant.rego variable.language.rego"
},
"keyword": {
"match": "(^|\\s+)(?:(default|not|package|import|as|with|else|some|in|every|if|contains))(?=\\s|$)",
"name": "keyword.other.rego"
},
"number": {
"match": "(?x: # turn on extended mode\n -? # an optional minus\n (?:\n 0 # a zero\n | # ...or...\n [1-9] # a 1-9 character\n \\d* # followed by zero or more digits\n )\n (?:\n (?:\n \\. # a period\n \\d+ # followed by one or more digits\n )?\n (?:\n [eE] # an e character\n [+-]? # followed by an option +/-\n \\d+ # followed by one or more digits\n )? # make exponent optional\n )? # make decimal portion optional\n )",
"name": "constant.numeric.rego"
},
"comparison-operators": {
"match": "\\=\\=|\\!\\=|>|<|<\\=|>\\=|\\+|-|\\*|%|/|\\||&",
"name": "keyword.operator.comparison.rego"
},
"assignment-operators": {
"match": ":\\=|\\=",
"name": "keyword.operator.assignment.rego"
},
"interpolated-string-double": {
"begin": "(\\$)(\")",
"beginCaptures": {
"1": {
"name": "punctuation.definition.template-expression.begin.rego"
},
"2": {
"name": "punctuation.definition.string.begin.rego"
}
},
"end": "\"",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.rego"
}
},
"name": "string.template.rego",
"patterns": [
{
"include": "#interpolation-expression"
},
{
"include": "#string-escape"
},
{
"include": "#interpolation-escape"
},
{
"include": "#string-escape-invalid"
}
]
},
"interpolated-string-raw": {
"begin": "(\\$)(`)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.template-expression.begin.rego"
},
"2": {
"name": "punctuation.definition.string.begin.rego"
}
},
"end": "`",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.rego"
}
},
"name": "string.template.rego",
"patterns": [
{
"include": "#interpolation-expression"
}
]
},
"interpolation-expression": {
"begin": "(?<!\\\\)\\{",
"beginCaptures": {
"0": {
"name": "punctuation.section.embedded.rego"
}
},
"end": "\\}",
"endCaptures": {
"0": {
"name": "punctuation.section.embedded.rego"
}
},
"name": "meta.embedded.expression.rego",
"patterns": [
{
"include": "#interpolation-expression-contents"
}
]
},
"interpolation-expression-contents": {
"patterns": [
{
"include": "#comment"
},
{
"include": "#constant"
},
{
"include": "#string"
},
{
"include": "#number"
},
{
"include": "#call"
},
{
"include": "#root-document"
},
{
"include": "#variable"
},
{
"include": "#comparison-operators"
}
]
},
"string-escape": {
"match": "(?x: # turn on extended mode\n\t\t\t\\\\ # a literal backslash\n\t\t\t(?: # ...followed by...\n\t\t\t\t[\"\\\\/bfnrt] # one of these characters\n\t\t\t\t| # ...or...\n\t\t\t\tu # a u\n\t\t\t\t[0-9a-fA-F]{4} # and four hex digits\n\t\t\t)\n\t\t\t)",
"name": "constant.character.escape.rego"
},
"interpolation-escape": {
"match": "\\\\[{}]",
"name": "constant.character.escape.rego"
},
"string-escape-invalid": {
"match": "\\\\.",
"name": "invalid.illegal.unrecognized-string-escape.rego"
},
"string": {
"patterns": [
{
"include": "#interpolated-string-double"
},
{
"include": "#interpolated-string-raw"
},
{
"begin": "\"",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.rego"
}
},
"end": "\"",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.rego"
}
},
"name": "string.quoted.double.rego",
"patterns": [
{
"include": "#string-escape"
},
{
"include": "#string-escape-invalid"
}
]
},
{
"begin": "`",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.rego"
}
},
"end": "`",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.rego"
}
},
"name": "string.other.raw.rego"
}
]
},
"term": {
"patterns": [
{
"include": "#constant"
},
{
"include": "#string"
},
{
"include": "#number"
},
{
"include": "#call"
},
{
"include": "#root-document"
},
{
"include": "#variable"
}
]
},
"variable": {
"match": "\\b[[:alpha:]_][[:alnum:]_]*\\b",
"name": "meta.identifier.rego"
}
},
"scopeName": "source.rego",
"uuid": "165D3571-322B-4C57-ABAD-9EB3922FB004"
}
Loading