Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow enums to use double quoted strings and here/nowdocs #199

Merged
merged 1 commit into from
Jan 11, 2024
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
2 changes: 1 addition & 1 deletion common/define-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ module.exports = function defineGrammar(dialect) {
optional(field('attributes', $.attribute_list)),
keyword('case'),
field('name', $.name),
optional(seq('=', field('value', choice($.string, $.integer)))),
optional(seq('=', field('value', choice($._string, $.integer)))),
$._semicolon,
),

Expand Down
16 changes: 8 additions & 8 deletions common/test/corpus/declarations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ class B {
name: (name)
parameters: (formal_parameters
(simple_parameter
attributes: (attribute_list
attributes: (attribute_list
(attribute_group (attribute (name)))
)
name: (variable_name (name))
Expand Down Expand Up @@ -651,8 +651,10 @@ enum Suit: string
{
case Hearts = 'H';
case Diamonds;
case Clubs = 'C';
case Spades = 'S';
case Clubs = "C";
case Spades = <<<TXT
S
TXT;

// Fulfills the interface contract.
public function color(): string {
Expand Down Expand Up @@ -688,14 +690,12 @@ enum Suit: string
(enum_declaration
(name)
(primitive_type)
(enum_declaration_list
(enum_declaration_list
(enum_case (name) (string (string_value)))
(enum_case (name))
(enum_case (name) (string (string_value)))
(enum_case (name) (string (string_value)))

(enum_case (name) (encapsed_string (string_value)))
(enum_case (name) (heredoc (heredoc_start) (heredoc_body (string_value)) (heredoc_end)))
(comment)

(method_declaration
(visibility_modifier)
(name)
Expand Down
2 changes: 1 addition & 1 deletion php/src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@
"members": [
{
"type": "SYMBOL",
"name": "string"
"name": "_string"
},
{
"type": "SYMBOL",
Expand Down
12 changes: 12 additions & 0 deletions php/src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -1833,10 +1833,22 @@
"multiple": false,
"required": false,
"types": [
{
"type": "encapsed_string",
"named": true
},
{
"type": "heredoc",
"named": true
},
{
"type": "integer",
"named": true
},
{
"type": "nowdoc",
"named": true
},
{
"type": "string",
"named": true
Expand Down
Loading