Skip to content
Open
7 changes: 7 additions & 0 deletions language/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Language Grammars And Syntax Tests

Workflow grammar assets live in `language/syntaxes/`.

For syntax-highlighting triage guidance and fixture-based regression test patterns, see:

- `src/workflow/syntax/README.md`
127 changes: 94 additions & 33 deletions language/syntaxes/expressions.tmGrammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,76 @@
"injectionSelector": "L:source.github-actions-workflow",
"patterns": [
{
"include": "#expression"
"include": "#block-inline-expression"
},
{
"include": "#block-if-expression"
},
{
"include": "#if-expression"
}
],
"repository": {
"expression": {
"match": "[|-]?\\$\\{\\{(.*?)\\}\\}",
"block-inline-expression": {
"name": "meta.embedded.block.github-actions-expression",
"captures": {
"begin": "[|-]?\\$\\{\\{",
"end": "\\}\\}",
"patterns": [
{
"include": "#expression"
}
]
},
"block-if-expression": {
"contentName": "meta.embedded.block.github-actions-expression",
"begin": "^\\s*\\b(if:)\\s+(?:(\\|)|(>))([1-9])?([-+])?(.*\\n?)",
"beginCaptures": {
"1": {
"patterns": [
{
"include": "#function-call"
},
{
"include": "#context"
},
{
"include": "#string"
},
"include": "source.github-actions-workflow"
}
]
},
"2": {
"name": "keyword.control.flow.block-scalar.literal.yaml"
},
"3": {
"name": "keyword.control.flow.block-scalar.folded.yaml"
},
"4": {
"name": "constant.numeric.indentation-indicator.yaml"
},
"5": {
"name": "storage.modifier.chomping-indicator.yaml"
},
"6": {
"patterns": [
{
"include": "#number"
"include": "#comment"
},
{
"include": "#boolean"
},
"match": ".+",
"name": "invalid.illegal.expected-comment-or-newline.yaml"
}
]
}
},
"end": "^(?=\\S)|(?!\\G)",
"patterns": [
{
"begin": "^([ ]+)(?! )",
"end": "^(?!\\1|\\s*$)",
"patterns": [
{
"include": "#null"
"include": "#expression"
}
]
}
}
]
},
"if-expression": {
"match": "\\b(if:) (.*?)$",
"match": "\\b(if:)\\s+((?:'(?:''|[^'])*'|[^#\\n])+?)(\\s+#.*)?$",
"contentName": "meta.embedded.block.github-actions-expression",
"captures": {
"1": {
Expand All @@ -52,27 +85,47 @@
"2": {
"patterns": [
{
"include": "#function-call"
},
{
"include": "#context"
},
{
"include": "#string"
},
{
"include": "#number"
},
{
"include": "#boolean"
},
"include": "#expression"
}
]
},
"3": {
"patterns": [
{
"include": "#null"
"include": "source.github-actions-workflow"
}
]
}
}
},
"expression": {
"patterns": [
{
"include": "#function-call"
},
{
"include": "#context"
},
{
"include": "#string"
},
{
"include": "#op-comparison"
},
{
"include": "#op-logical"
},
{
"include": "#number"
},
{
"include": "#boolean"
},
{
"include": "#null"
}
]
},
"function-call": {
"patterns": [
{
Expand All @@ -98,6 +151,14 @@
"begin": "'",
"end": "'"
},
"op-comparison": {
"name": "keyword.operator.comparison.github-actions-expression",
"match": "(==|!=)"
},
"op-logical": {
"name": "keyword.operator.logical.github-actions-expression",
"match": "(&&|\\|\\|)"
},
"number": {
"name": "constant.numeric.github-actions-expression",
"match": "\\b[0-9]+(?:.[0-9]+)?\\b"
Expand Down
40 changes: 40 additions & 0 deletions language/syntaxes/github-script-embedded.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "GitHub Actions github-script embedded JavaScript",
"scopeName": "source.github-actions-workflow.github-script-embedded",
"injectionSelector": "L:source.github-actions-workflow - meta.github-actions.github-script.context",
"patterns": [
{
"name": "meta.github-actions.github-script.context",
"begin": "(?=^\\s*(?:-\\s+)?uses\\s*:\\s*(?:\\\"actions\\/github-script(?:\\@[A-Za-z0-9._-]+)?\\\"|'actions\\/github-script(?:\\@[A-Za-z0-9._-]+)?'|actions\\/github-script(?:\\@[A-Za-z0-9._-]+)?)(?:\\s+#.*)?$)",
"end": "^(?=\\s*-\\s|\\S|\\z)",
"patterns": [
{
"contentName": "meta.embedded.block.javascript",
"begin": "^(\\s+)(script)(\\s*:\\s*)([>|][-+0-9\\s]*\\s*)(?:#.*)?$",
"beginCaptures": {
"2": {
"name": "entity.name.tag.yaml"
},
"3": {
"name": "punctuation.separator.key-value.mapping.yaml"
},
"4": {
"name": "string.unquoted.block.yaml"
}
},
"end": "^(?!(?:\\1\\s+|\\s*$))",
"patterns": [
{
"include": "source.js"
}
]
},
{
"include": "source.github-actions-workflow"
}
]
}
],
"repository": {}
}
Loading