Skip to content

Commit

Permalink
parse OTP 26 feature attribute
Browse files Browse the repository at this point in the history
Summary:
As title.

We lower it as part of the `FormList`, but not in HIR.
Note: ELP support for parsing `maybe` is always enabled, regardless of the feature flag.

Reviewed By: perehonchuk

Differential Revision: D49950781

fbshipit-source-id: ee2869e33203a8ffc6649b904513c982ece792f7
  • Loading branch information
alanz authored and facebook-github-bot committed Oct 5, 2023
1 parent 4a0ec79 commit f66f7cd
Show file tree
Hide file tree
Showing 5 changed files with 24,486 additions and 23,960 deletions.
9 changes: 9 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ module.exports = grammar({
$.export_type_attribute,
$.optional_callbacks_attribute,
$.compile_options_attribute,
$.feature_attribute,
$.file_attribute,
$.deprecated_attribute,
$.record_decl,
Expand Down Expand Up @@ -279,6 +280,14 @@ module.exports = grammar({
'.'
),

feature_attribute: $ => seq(
'-',
atom_const('feature'),
'(',
field("feature", $._expr), ',',
field("flag", $._expr),
')', '.'),

_deprecated_details: $ => choice(
$.deprecated_module,
$.deprecated_fa,
Expand Down
63 changes: 63 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"type": "SYMBOL",
"name": "compile_options_attribute"
},
{
"type": "SYMBOL",
"name": "feature_attribute"
},
{
"type": "SYMBOL",
"name": "file_attribute"
Expand Down Expand Up @@ -1279,6 +1283,65 @@
}
]
},
"feature_attribute": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "-"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "feature"
},
{
"type": "ALIAS",
"content": {
"type": "STRING",
"value": "'feature'"
},
"named": false,
"value": "feature"
}
]
},
{
"type": "STRING",
"value": "("
},
{
"type": "FIELD",
"name": "feature",
"content": {
"type": "SYMBOL",
"name": "_expr"
}
},
{
"type": "STRING",
"value": ","
},
{
"type": "FIELD",
"name": "flag",
"content": {
"type": "SYMBOL",
"name": "_expr"
}
},
{
"type": "STRING",
"value": ")"
},
{
"type": "STRING",
"value": "."
}
]
},
"_deprecated_details": {
"type": "CHOICE",
"members": [
Expand Down
34 changes: 34 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@
"type": "export_type_attribute",
"named": true
},
{
"type": "feature_attribute",
"named": true
},
{
"type": "file_attribute",
"named": true
Expand Down Expand Up @@ -1431,6 +1435,32 @@
}
}
},
{
"type": "feature_attribute",
"named": true,
"fields": {
"feature": {
"multiple": false,
"required": true,
"types": [
{
"type": "_expr",
"named": true
}
]
},
"flag": {
"multiple": false,
"required": true,
"types": [
{
"type": "_expr",
"named": true
}
]
}
}
},
{
"type": "field_expr",
"named": true,
Expand Down Expand Up @@ -3409,6 +3439,10 @@
"type": "export_type",
"named": false
},
{
"type": "feature",
"named": false
},
{
"type": "file",
"named": false
Expand Down
Loading

0 comments on commit f66f7cd

Please sign in to comment.