Skip to content

Commit

Permalink
Highlight await and concurrent (#144)
Browse files Browse the repository at this point in the history
* Remove obsolete syntax

Remove support for `array` literals, `&` reference syntax, `@` error
suppression syntax, `declare` and `endfor` (along with the other
`endfoo` keywords).

* Add await/concurrent as control keywords
  • Loading branch information
Wilfred authored Aug 31, 2022
1 parent 2bf3bde commit a14c481
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 52 deletions.
60 changes: 8 additions & 52 deletions syntaxes/hack.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,7 @@
"name": "support.type.php",
"patterns": [
{
"match": "\\barray\\b",
"name": "support.type.array.php"
},
{
"match": "\\b(?:bool|int|float|string|array|resource|mixed|arraykey|nonnull|dict|vec|keyset)\\b",
"match": "\\b(?:bool|int|float|string|resource|mixed|arraykey|nonnull|dict|vec|keyset)\\b",
"name": "support.type.php"
},
{
Expand Down Expand Up @@ -410,16 +406,13 @@
"include": "#type-annotation"
},
{
"begin": "(?xi)\n\\s*(&)? # Reference\n\\s*((\\$+)[a-z_\\x{7f}-\\x{ff}][a-z0-9_\\x{7f}-\\x{ff}]*) # The variable name",
"begin": "(?xi)((\\$+)[a-z_\\x{7f}-\\x{ff}][a-z0-9_\\x{7f}-\\x{ff}]*) # The variable name",
"end": "(?xi)\n\\s*(?=,|\\)|$) # A closing parentheses (end of argument list) or a comma",
"beginCaptures": {
"1": {
"name": "storage.modifier.reference.php"
},
"2": {
"name": "variable.other.php"
},
"3": {
"2": {
"name": "punctuation.definition.variable.php"
}
},
Expand Down Expand Up @@ -902,7 +895,7 @@
"name": "keyword.control.php"
}
},
"match": "\\s*\\b((break|c(ase|ontinue)|d(e(clare|fault)|o)|e(lse|nd(declare|for(each)?|switch|while))|for(each)?|if|return|switch|use|while))\\b"
"match": "\\s*\\b(await|break|c(ase|ontinue)|concurrent|default|do|else|for(each)?|if|return|switch|use|while)\\b"
},
{
"begin": "(?i)\\b((?:require|include)(?:_once)?)\\b\\s*",
Expand Down Expand Up @@ -973,13 +966,10 @@
"name": "keyword.control.exception.php"
},
{
"begin": "(?i)\\b(function)\\s*(&\\s*)?(?=\\()",
"begin": "(?i)\\b(function)\\s*(?=\\()",
"beginCaptures": {
"1": {
"name": "storage.type.function.php"
},
"2": {
"name": "storage.modifier.reference.php"
}
},
"end": "\\{|\\)",
Expand Down Expand Up @@ -1042,7 +1032,7 @@
]
},
{
"begin": "(?x)\n\\s*((?:(?:final|abstract|public|private|protected|static|async)\\s+)*)\n(function)\n(?:\\s+|(\\s*&\\s*))\n(?:\n (__(?:call|construct|destruct|get|set|isset|unset|tostring|clone|set_state|sleep|wakeup|autoload|invoke|callStatic|dispose|disposeAsync)(?=[^a-zA-Z0-9_\\x7f-\\xff]))\n |\n ([a-zA-Z0-9_]+)\n)",
"begin": "(?x)\n\\s*((?:(?:final|abstract|public|private|protected|static|async)\\s+)*)\n(function)\n(?:\\s+)\n(?:\n (__(?:call|construct|destruct|get|set|isset|unset|tostring|clone|set_state|sleep|wakeup|autoload|invoke|callStatic|dispose|disposeAsync)(?=[^a-zA-Z0-9_\\x7f-\\xff]))\n |\n ([a-zA-Z0-9_]+)\n)",
"beginCaptures": {
"1": {
"patterns": [
Expand All @@ -1056,15 +1046,12 @@
"name": "storage.type.function.php"
},
"3": {
"name": "storage.modifier.reference.php"
},
"4": {
"name": "support.function.magic.php"
},
"5": {
"4": {
"name": "entity.name.function.php"
},
"6": {
"5": {
"name": "meta.function.generics.php"
}
},
Expand Down Expand Up @@ -1227,10 +1214,6 @@
"match": "\\|>",
"name": "keyword.operator.pipe.php"
},
{
"match": "(@)",
"name": "keyword.operator.error-control.php"
},
{
"match": "(!==|!=|===|==)",
"name": "keyword.operator.comparison.php"
Expand Down Expand Up @@ -1428,33 +1411,6 @@
"match": "=",
"name": "keyword.operator.assignment.php"
},
{
"match": "&(?=\\s*\\$)",
"name": "storage.modifier.reference.php"
},
{
"begin": "(array)\\s*(\\()",
"beginCaptures": {
"1": {
"name": "support.function.construct.php"
},
"2": {
"name": "punctuation.definition.array.begin.php"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.definition.array.end.php"
}
},
"name": "meta.array.php",
"patterns": [
{
"include": "#parameter-default-types"
}
]
},
{
"include": "#instantiation"
},
Expand Down
10 changes: 10 additions & 0 deletions syntaxes/test/async.hack
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
async function gen_foo(): Awaitable<int> {
return 1;
}

async function gen_bar(): Awaitable<void> {
concurrent {
$x = await gen_foo(1);
$y = await gen_foo(2);
}
}

0 comments on commit a14c481

Please sign in to comment.