Skip to content

Commit

Permalink
fixed array support
Browse files Browse the repository at this point in the history
  • Loading branch information
urbit-pilled committed Mar 28, 2024
1 parent 16f4d8a commit c432a14
Show file tree
Hide file tree
Showing 6 changed files with 65,119 additions and 64,589 deletions.
22 changes: 22 additions & 0 deletions crates/core/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13010,6 +13010,28 @@ fn php_rewrite_arrow_function() {
.unwrap();
}

#[test]
fn php_array() {
run_test_expected(
TestArgExpected {
pattern: r#"
|language php
|
|`^a=>^_` => `^a=>24`
|"#
.trim_margin()
.unwrap(),
source: r#"$fn1 = array("a"=>1, "b"=>2, "c"=>3);"#
.trim_margin().
unwrap(),
expected: r#"$fn1 = array("a"=>24, "b"=>24, "c"=>24);"#
.trim_margin()
.unwrap(),
}
)
.unwrap();
}


#[test]
fn css_property_value() {
Expand Down
2 changes: 2 additions & 0 deletions crates/language/src/php.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ impl Language for Php {
("$", ";"),
("class GRIT_CLASS {", "}"),
("class GRIT_CLASS { ", " function GRIT_FN(); }"),
(" GRIT_FN(", ") { }"),
("[", "];"),
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1259,8 +1259,8 @@ module.exports = function defineGrammar(dialect) {
)),

array_creation_expression: $ => choice(
seq(keyword('array'), '(', commaSep($.array_element_initializer), optional(','), ')'),
seq('[', commaSep($.array_element_initializer), optional(','), ']'),
seq(keyword('array'), '(', field('array_element', commaSep($.array_element_initializer)), optional(','), ')'),
seq('[', field('array_element', commaSep($.array_element_initializer)), optional(','), ']'),
),

attribute_group: $ => seq(
Expand Down Expand Up @@ -1475,7 +1475,7 @@ module.exports = function defineGrammar(dialect) {

array_element_initializer: $ => prec.right(choice(
choice($.by_ref, $._expression),
seq($._expression, '=>', choice($.by_ref, $._expression)),
seq(field('expression_l', $._expression), '=>', field('expression_r', choice($.by_ref, $._expression))),
$.variadic_unpacking,
)),

Expand Down

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

Loading

0 comments on commit c432a14

Please sign in to comment.