Skip to content

Commit

Permalink
fix: final modifier with constant visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdw committed Jan 24, 2024
1 parent 0d931c1 commit df72fdc
Show file tree
Hide file tree
Showing 6 changed files with 6,080 additions and 6,062 deletions.
4 changes: 2 additions & 2 deletions common/define-grammar.js
Expand Up @@ -355,11 +355,11 @@ module.exports = function defineGrammar(dialect) {

const_declaration: $ => $._const_declaration,

_class_const_declaration: $ => seq(
_class_const_declaration: $ => prec(1, seq(
optional(field('attributes', $.attribute_list)),
optional(field('modifier', $.final_modifier)),
$._const_declaration,
),
)),

_const_declaration: $ => seq(
optional($.visibility_modifier),
Expand Down
6 changes: 6 additions & 0 deletions common/test/corpus/class.txt
Expand Up @@ -182,6 +182,7 @@ class Foo {
protected const C = 3;
private const D = 4;
final const E = 5;
final public const F = 6;
}

---
Expand Down Expand Up @@ -210,6 +211,11 @@ class Foo {
(final_modifier)
(const_element (name) (integer))
)
(const_declaration
(final_modifier)
(visibility_modifier)
(const_element (name) (integer))
)
)
)
)
Expand Down
78 changes: 41 additions & 37 deletions php/src/grammar.json
Expand Up @@ -1464,45 +1464,49 @@
"name": "_const_declaration"
},
"_class_const_declaration": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "attributes",
"content": {
"type": "SYMBOL",
"name": "attribute_list"
"type": "PREC",
"value": 1,
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "attributes",
"content": {
"type": "SYMBOL",
"name": "attribute_list"
}
},
{
"type": "BLANK"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "modifier",
"content": {
"type": "SYMBOL",
"name": "final_modifier"
]
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "modifier",
"content": {
"type": "SYMBOL",
"name": "final_modifier"
}
},
{
"type": "BLANK"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_const_declaration"
}
]
]
},
{
"type": "SYMBOL",
"name": "_const_declaration"
}
]
}
},
"_const_declaration": {
"type": "SEQ",
Expand Down

0 comments on commit df72fdc

Please sign in to comment.