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
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
uses: tree-sitter/workflows/.github/workflows/release.yml@main
with:
generate: true
attestations: true
npm:
uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main
secrets:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/common.mak
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $(error Windows is not supported)
endif

HOMEPAGE_URL := https://github.com/tree-sitter/tree-sitter-php
VERSION := 0.25.0
VERSION := 0.25.1

# repository
SRC_DIR := src
Expand Down
40 changes: 24 additions & 16 deletions common/define-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ const OTHER_RESERVED_KEYWORD_SET = [
'never', 'null', 'object', 'string', 'true', 'void',
].map(r => keyword(r, false));

/**
* The types a value can be cast to, e.g. `(int) $x`.
*
* @see https://www.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting
*/
const CAST_TYPES = [
'array', 'binary', 'bool', 'boolean', 'double', 'float',
'int', 'integer', 'object', 'real', 'string', 'unset',
];

module.exports = function defineGrammar(dialect) {
if (dialect !== 'php' && dialect !== 'php_only') {
throw new Error(`Unknown dialect ${dialect}`);
Expand All @@ -90,6 +100,7 @@ module.exports = function defineGrammar(dialect) {

[$.namespace_name],
[$.heredoc_body],
[$.parenthesized_expression, $.argument],
],

externals: $ => [
Expand Down Expand Up @@ -640,20 +651,7 @@ module.exports = function defineGrammar(dialect) {
keyword('void', false),
),

cast_type: _ => choice(
keyword('array', false),
keyword('binary', false),
keyword('bool', false),
keyword('boolean', false),
keyword('double', false),
keyword('float', false),
keyword('int', false),
keyword('integer', false),
keyword('object', false),
keyword('real', false),
keyword('string', false),
keyword('unset', false),
),
cast_type: _ => choice(...CAST_TYPES.map(type => keyword(type, false))),

_return_type: $ => seq(':', field('return_type', choice($.type, $.bottom_type))),

Expand Down Expand Up @@ -995,7 +993,13 @@ module.exports = function defineGrammar(dialect) {

error_suppression_expression: $ => prec(PREC.INC, seq('@', $.expression)),

clone_expression: $ => seq(keyword('clone'), $.primary_expression),
clone_expression: $ => seq(
keyword('clone'),
choice(
$.primary_expression,
field('arguments', $.arguments),
),
),

primary_expression: $ => choice(
$._variable,
Expand Down Expand Up @@ -1278,14 +1282,18 @@ module.exports = function defineGrammar(dialect) {
$.variadic_unpacking,
$.expression,
$.argument_placeholder,
prec(-1, alias(
choice(...CAST_TYPES.map(type => keyword(type, false))),
$.name,
)),
),
),

_argument_name: $ => seq(
field('name', alias(
choice(
reserved('nothing', $.name),
keyword('array', false),
...CAST_TYPES.map(type => keyword(type, false)),
keyword('fn', false),
keyword('function', false),
keyword('match', false),
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 148 additions & 2 deletions php/src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions php/src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading