Skip to content

Commit

Permalink
Merge pull request Wilfred#12 from postsolar/kind-declarations
Browse files Browse the repository at this point in the history
Kind declarations
  • Loading branch information
Maskhjarna authored Sep 25, 2023
2 parents 6f14212 + 4131c3f commit 7b59bdf
Show file tree
Hide file tree
Showing 7 changed files with 282,636 additions and 281,109 deletions.
2 changes: 2 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ module.exports = grammar({
$._decl_foreign,
alias($.decl_deriving, $.deriving_declaration),
$._decl,
$._decl_kind,
$._decl_kind_value,
alias($.decl_pattern, $.pattern_synonym),
$.top_splice,
),
Expand Down
2 changes: 0 additions & 2 deletions grammar/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module.exports = {
$.data_constructor,
),


decl_data: $ => seq(
'data',
$._simpletype,
Expand All @@ -44,7 +43,6 @@ module.exports = {
$._atype,
),


decl_newtype: $ => seq(
'newtype',
'=',
Expand Down
23 changes: 22 additions & 1 deletion grammar/decl.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,27 @@ module.exports = {
$._type,
),


_decl_foreign: $ => alias($.decl_foreign_import, $.foreign_import),

// ------------------------------------------------------------------------
// kinds and kind values
// ------------------------------------------------------------------------

decl_new_kind: $ => seq(
'data',
$._simpletype,
),

decl_new_kind_value: $ => seq(
'foreign',
'import',
'data',
$._simpletype,
$._colon2,
$._type,
),

_decl_kind: $ => alias($.decl_new_kind, $.kind),
_decl_kind_value: $ => alias($.decl_new_kind_value, $.kind_value),

}
68 changes: 68 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@
"type": "SYMBOL",
"name": "_decl"
},
{
"type": "SYMBOL",
"name": "_decl_kind"
},
{
"type": "SYMBOL",
"name": "_decl_kind_value"
},
{
"type": "ALIAS",
"content": {
Expand Down Expand Up @@ -6351,6 +6359,66 @@
"named": true,
"value": "foreign_import"
},
"decl_new_kind": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "data"
},
{
"type": "SYMBOL",
"name": "_simpletype"
}
]
},
"decl_new_kind_value": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "foreign"
},
{
"type": "STRING",
"value": "import"
},
{
"type": "STRING",
"value": "data"
},
{
"type": "SYMBOL",
"name": "_simpletype"
},
{
"type": "SYMBOL",
"name": "_colon2"
},
{
"type": "SYMBOL",
"name": "_type"
}
]
},
"_decl_kind": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "decl_new_kind"
},
"named": true,
"value": "kind"
},
"_decl_kind_value": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "decl_new_kind_value"
},
"named": true,
"value": "kind_value"
},
"_pattern_type": {
"type": "SEQ",
"members": [
Expand Down
164 changes: 164 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -7720,6 +7720,162 @@
"named": true,
"fields": {}
},
{
"type": "kind",
"named": true,
"fields": {
"name": {
"multiple": true,
"required": false,
"types": [
{
"type": "(",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": "constructor_operator",
"named": true
},
{
"type": "type",
"named": true
},
{
"type": "type_operator",
"named": true
}
]
}
},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "annotated_type_variable",
"named": true
},
{
"type": "type_infix",
"named": true
},
{
"type": "type_variable",
"named": true
}
]
}
},
{
"type": "kind_value",
"named": true,
"fields": {
"name": {
"multiple": true,
"required": false,
"types": [
{
"type": "(",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": "constructor_operator",
"named": true
},
{
"type": "type",
"named": true
},
{
"type": "type_operator",
"named": true
}
]
}
},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "annotated_type_variable",
"named": true
},
{
"type": "context",
"named": true
},
{
"type": "forall",
"named": true
},
{
"type": "fun",
"named": true
},
{
"type": "promoted",
"named": true
},
{
"type": "quasiquote",
"named": true
},
{
"type": "record_fields",
"named": true
},
{
"type": "splice",
"named": true
},
{
"type": "type_apply",
"named": true
},
{
"type": "type_infix",
"named": true
},
{
"type": "type_literal",
"named": true
},
{
"type": "type_name",
"named": true
},
{
"type": "type_parens",
"named": true
},
{
"type": "type_star",
"named": true
},
{
"type": "type_unboxed_sum",
"named": true
},
{
"type": "type_unboxed_tuple",
"named": true
},
{
"type": "type_variable",
"named": true
}
]
}
},
{
"type": "let",
"named": true,
Expand Down Expand Up @@ -9561,6 +9717,14 @@
"type": "instance",
"named": true
},
{
"type": "kind",
"named": true
},
{
"type": "kind_value",
"named": true
},
{
"type": "newtype",
"named": true
Expand Down
Loading

0 comments on commit 7b59bdf

Please sign in to comment.