remove node from class expression

pull/625/head
Nikolaj Sidorenco 2023-02-26 13:42:08 +07:00
parent 7264d90bef
commit bc2d334d70
7 changed files with 552336 additions and 599982 deletions

@ -122,17 +122,10 @@ type A() =
(attribute_set
(attribute
(object_construction
(type
(long_identifier
(identifier)))
(type (long_identifier (identifier)))
(paren_expression
(const
(string)))))))
(const (string)))))))
(anon_type_defn
(type_name
(identifier))
(type_name (identifier))
(primary_constr_args)
(class_type_body
(class_function_or_value_defn
(const
(unit)))))))
(const (unit)))))

@ -6,21 +6,6 @@ basic compiler directive
--------------------------------------------------------------------------------
(ERROR
(UNEXPECTED 'w')
(UNEXPECTED 'n'))
================================================================================
multiple compiler directive
================================================================================
#identhere "hello" "test"
--------------------------------------------------------------------------------
(ERROR
(UNEXPECTED 'r')
(UNEXPECTED 'h')
(UNEXPECTED '"')
(UNEXPECTED 'e')
(UNEXPECTED '"'))
(file
(compiler_directive_decl
(string)))

@ -92,13 +92,9 @@ type A() =
(file
(type_definition
(anon_type_defn
(type_name
(identifier))
(type_name (identifier))
(primary_constr_args)
(class_type_body
(class_function_or_value_defn
(const
(unit)))))))
(const (unit)))))
================================================================================
class inherit definition
@ -114,11 +110,9 @@ type A() =
(anon_type_defn
(type_name (identifier))
(primary_constr_args)
(class_type_body
(class_inherits_decl
(type
(long_identifier (identifier)))
(const (unit)))))))
(class_inherits_decl
(type (long_identifier (identifier)))
(const (unit))))))
================================================================================
basic class member definition
@ -132,18 +126,15 @@ type A() =
(file
(type_definition
(anon_type_defn
(type_name
(identifier))
(type_name (identifier))
(primary_constr_args)
(class_type_body
(type_defn_elements
(member_defn
(method_or_prop_defn
(property_or_ident
(identifier)
(identifier))
(const_pattern (unit))
(const (unit)))))))))
(member_defn
(method_or_prop_defn
(property_or_ident
(identifier)
(identifier))
(const_pattern (unit))
(const (unit)))))))
================================================================================
basic class interface implementation definition
@ -158,22 +149,50 @@ type A() =
(file
(type_definition
(anon_type_defn
(type_name
(identifier))
(type_name (identifier))
(primary_constr_args)
(class_type_body
(type_defn_elements
(interface_implementation
(type (long_identifier (identifier)))
(object_members
(member_defns
(member_defn
(method_or_prop_defn
(property_or_ident
(identifier)
(identifier))
(const_pattern (unit))
(const (unit))))))))))))
(interface_implementation
(type (long_identifier (identifier)))
(member_defn
(method_or_prop_defn
(property_or_ident
(identifier)
(identifier))
(const_pattern (unit))
(const (unit))))))))
================================================================================
basic class interface implementation definition with two members
================================================================================
type A() =
interface A with
member _.B() = ()
member _.C() = ()
--------------------------------------------------------------------------------
(file
(type_definition
(anon_type_defn
(type_name (identifier))
(primary_constr_args)
(interface_implementation
(type (long_identifier (identifier)))
(member_defn
(method_or_prop_defn
(property_or_ident
(identifier)
(identifier))
(const_pattern (unit))
(const (unit))))
(member_defn
(method_or_prop_defn
(property_or_ident
(identifier)
(identifier))
(const_pattern (unit))
(const (unit))))))))
================================================================================
class inherit and do definition
@ -188,17 +207,12 @@ type A() =
(file
(type_definition
(anon_type_defn
(type_name
(identifier))
(type_name (identifier))
(primary_constr_args)
(class_type_body
(class_inherits_decl
(type
(long_identifier
(identifier)))
(const (unit)))
(class_function_or_value_defn
(const (unit)))))))
(class_inherits_decl
(type (long_identifier (identifier)))
(const (unit)))
(const (unit)))))
================================================================================
class inherit and member method definition
@ -213,26 +227,18 @@ type A() =
(file
(type_definition
(anon_type_defn
(type_name
(identifier))
(type_name (identifier))
(primary_constr_args)
(class_type_body
(class_inherits_decl
(type
(long_identifier
(identifier)))
(const
(unit)))
(type_defn_elements
(member_defn
(method_or_prop_defn
(property_or_ident
(identifier)
(identifier))
(const_pattern
(unit))
(const
(unit)))))))))
(class_inherits_decl
(type (long_identifier (identifier)))
(const (unit)))
(member_defn
(method_or_prop_defn
(property_or_ident
(identifier)
(identifier))
(const_pattern (unit))
(const (unit)))))))
================================================================================
class member then interface impl. test
@ -250,27 +256,22 @@ type A() =
(anon_type_defn
(type_name (identifier))
(primary_constr_args)
(class_type_body
(type_defn_elements
(member_defn
(method_or_prop_defn
(property_or_ident
(identifier)
(identifier))
(const_pattern (unit))
(const (unit)))))
(type_defn_elements
(interface_implementation
(type (long_identifier (identifier)))
(object_members
(member_defns
(member_defn
(method_or_prop_defn
(property_or_ident
(identifier)
(identifier))
(const_pattern (unit))
(const (unit))))))))))))
(member_defn
(method_or_prop_defn
(property_or_ident
(identifier)
(identifier))
(const_pattern (unit))
(const (unit))))
(interface_implementation
(type (long_identifier (identifier)))
(member_defn
(method_or_prop_defn
(property_or_ident
(identifier)
(identifier))
(const_pattern (unit))
(const (unit))))))))
================================================================================
Mutual type definition

@ -135,8 +135,7 @@ module.exports = grammar({
compiler_directive_decl: $ =>
seq(
imm("#"),
$.identifier,
"#nowarn",
repeat($.string),
),
@ -436,7 +435,7 @@ module.exports = grammar({
"new",
$._base_call,
$._virtual_open_section,
$.object_members,
$._object_members,
$.interface_implementations,
$._virtual_end_section,
)),
@ -1196,11 +1195,11 @@ module.exports = grammar({
_class_type_body_inner: $ =>
choice(
$.class_inherits_decl,
$.class_function_or_value_defn,
$.type_defn_elements,
$._class_function_or_value_defn,
$._type_defn_elements,
),
class_type_body: $ =>
_class_type_body: $ =>
seq(
$._virtual_open_section,
repeat1($._class_type_body_inner),
@ -1297,7 +1296,7 @@ module.exports = grammar({
$.type_name,
$.primary_constr_args,
"=",
$.class_type_body
$._class_type_body
),
primary_constr_args: $ =>
@ -1317,7 +1316,7 @@ module.exports = grammar({
seq($.simple_pattern, ":", $.type)
),
class_function_or_value_defn: $ =>
_class_function_or_value_defn: $ =>
seq(
optional($.attributes),
optional("static"),
@ -1331,11 +1330,11 @@ module.exports = grammar({
seq(
"with",
$._virtual_open_section,
$.type_defn_elements,
$._type_defn_elements,
$._virtual_end_section,
),
type_defn_elements: $ =>
_type_defn_elements: $ =>
choice(
$.member_defn,
$.interface_implementation,
@ -1348,19 +1347,18 @@ module.exports = grammar({
seq(
"interface",
$.type,
optional($.object_members),
optional($._object_members),
)),
object_members: $ =>
_object_members: $ =>
seq(
"with",
$._virtual_open_section,
$.member_defns,
$.member_defn,
repeat(seq($._virtual_end_decl, $.member_defn)),
$._virtual_end_section,
),
member_defns: $ => repeat1($.member_defn),
member_defn: $ =>
seq(
optional($.attributes),

@ -212,15 +212,8 @@
"type": "SEQ",
"members": [
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "#"
}
},
{
"type": "SYMBOL",
"name": "identifier"
"type": "STRING",
"value": "#nowarn"
},
{
"type": "REPEAT",
@ -1544,7 +1537,7 @@
},
{
"type": "SYMBOL",
"name": "object_members"
"name": "_object_members"
},
{
"type": "SYMBOL",
@ -4248,15 +4241,15 @@
},
{
"type": "SYMBOL",
"name": "class_function_or_value_defn"
"name": "_class_function_or_value_defn"
},
{
"type": "SYMBOL",
"name": "type_defn_elements"
"name": "_type_defn_elements"
}
]
},
"class_type_body": {
"_class_type_body": {
"type": "SEQ",
"members": [
{
@ -4684,7 +4677,7 @@
},
{
"type": "SYMBOL",
"name": "class_type_body"
"name": "_class_type_body"
}
]
},
@ -4788,7 +4781,7 @@
}
]
},
"class_function_or_value_defn": {
"_class_function_or_value_defn": {
"type": "SEQ",
"members": [
{
@ -4860,7 +4853,7 @@
},
{
"type": "SYMBOL",
"name": "type_defn_elements"
"name": "_type_defn_elements"
},
{
"type": "SYMBOL",
@ -4868,7 +4861,7 @@
}
]
},
"type_defn_elements": {
"_type_defn_elements": {
"type": "CHOICE",
"members": [
{
@ -4911,7 +4904,7 @@
"members": [
{
"type": "SYMBOL",
"name": "object_members"
"name": "_object_members"
},
{
"type": "BLANK"
@ -4921,7 +4914,7 @@
]
}
},
"object_members": {
"_object_members": {
"type": "SEQ",
"members": [
{
@ -4934,7 +4927,23 @@
},
{
"type": "SYMBOL",
"name": "member_defns"
"name": "member_defn"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_virtual_end_decl"
},
{
"type": "SYMBOL",
"name": "member_defn"
}
]
}
},
{
"type": "SYMBOL",
@ -4942,13 +4951,6 @@
}
]
},
"member_defns": {
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "member_defn"
}
},
"member_defn": {
"type": "SEQ",
"members": [

@ -375,7 +375,27 @@
"required": true,
"types": [
{
"type": "class_type_body",
"type": "_expression_inner",
"named": true
},
{
"type": "attributes",
"named": true
},
{
"type": "class_inherits_decl",
"named": true
},
{
"type": "function_or_value_defn",
"named": true
},
{
"type": "interface_implementation",
"named": true
},
{
"type": "member_defn",
"named": true
},
{
@ -732,29 +752,6 @@
"named": true,
"fields": {}
},
{
"type": "class_function_or_value_defn",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "_expression_inner",
"named": true
},
{
"type": "attributes",
"named": true
},
{
"type": "function_or_value_defn",
"named": true
}
]
}
},
{
"type": "class_inherits_decl",
"named": true,
@ -774,41 +771,14 @@
]
}
},
{
"type": "class_type_body",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "class_function_or_value_defn",
"named": true
},
{
"type": "class_inherits_decl",
"named": true
},
{
"type": "type_defn_elements",
"named": true
}
]
}
},
{
"type": "compiler_directive_decl",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"required": false,
"types": [
{
"type": "identifier",
"named": true
},
{
"type": "string",
"named": true
@ -1740,7 +1710,7 @@
"required": true,
"types": [
{
"type": "object_members",
"type": "member_defn",
"named": true
},
{
@ -1902,21 +1872,6 @@
]
}
},
{
"type": "member_defns",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "member_defn",
"named": true
}
]
}
},
{
"type": "member_signature",
"named": true,
@ -2138,11 +2093,11 @@
"named": true
},
{
"type": "object_construction",
"type": "member_defn",
"named": true
},
{
"type": "object_members",
"type": "object_construction",
"named": true
}
]
@ -2167,21 +2122,6 @@
]
}
},
{
"type": "object_members",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "member_defns",
"named": true
}
]
}
},
{
"type": "op_name",
"named": true,
@ -2815,25 +2755,6 @@
]
}
},
{
"type": "type_defn_elements",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "interface_implementation",
"named": true
},
{
"type": "member_defn",
"named": true
}
]
}
},
{
"type": "type_extension",
"named": true,
@ -2862,7 +2783,11 @@
"required": true,
"types": [
{
"type": "type_defn_elements",
"type": "interface_implementation",
"named": true
},
{
"type": "member_defn",
"named": true
}
]
@ -3254,6 +3179,10 @@
"type": "#",
"named": false
},
{
"type": "#nowarn",
"named": false
},
{
"type": "$",
"named": false

1151884
src/parser.c

File diff suppressed because it is too large Load Diff