fix member methods

pull/625/head
Nikolaj Sidorenco 2023-02-23 18:38:04 +07:00
parent 15fee71ac7
commit e7097bd370
7 changed files with 650688 additions and 601615 deletions

@ -0,0 +1,138 @@
================================================================================
top-level module attribute
================================================================================
[<AutoOpen>]
module test =
let x = 4
--------------------------------------------------------------------------------
(file
(module_defn
(attributes
(attribute_set
(attribute
(object_construction
(type
(long_identifier
(identifier)))))))
(identifier)
(value_declaration
(function_or_value_defn
(value_declaration_left
(identifier_pattern
(long_identifier
(identifier))))
(const (int))))))
================================================================================
top-level module attributes repeated
================================================================================
[<A;B;C>]
module test =
let x = 4
--------------------------------------------------------------------------------
(file
(module_defn
(attributes
(attribute_set
(attribute
(object_construction
(type
(long_identifier
(identifier)))))
(attribute
(object_construction
(type
(long_identifier
(identifier)))))
(attribute
(object_construction
(type
(long_identifier
(identifier)))))))
(identifier)
(value_declaration
(function_or_value_defn
(value_declaration_left
(identifier_pattern
(long_identifier
(identifier))))
(const
(int))))))
================================================================================
top-level module attributes separate
================================================================================
[<A>]
[<B;C>]
module test =
let x = 4
--------------------------------------------------------------------------------
(file
(module_defn
(attributes
(attribute_set
(attribute
(object_construction
(type
(long_identifier
(identifier))))))
(attribute_set
(attribute
(object_construction
(type
(long_identifier
(identifier)))))
(attribute
(object_construction
(type
(long_identifier
(identifier)))))))
(identifier)
(value_declaration
(function_or_value_defn
(value_declaration_left
(identifier_pattern
(long_identifier
(identifier))))
(const
(int))))))
================================================================================
top-level class attribute
================================================================================
[<Route("test")>]
type A() =
do ()
--------------------------------------------------------------------------------
(file
(type_definition
(attributes
(attribute_set
(attribute
(object_construction
(type
(long_identifier
(identifier)))
(paren_expression
(const
(string)))))))
(anon_type_defn
(type_name
(identifier))
(primary_constr_args)
(class_type_body
(class_function_or_value_defn
(const
(unit)))))))

@ -101,3 +101,26 @@ let y = 5
(identifier))))
body: (const
(int))))))
================================================================================
namespace open
================================================================================
namespace Test.A
open B
open X.Y
--------------------------------------------------------------------------------
(file
(namespace
(long_identifier
(identifier)
(identifier))
(import_decl
(long_identifier (identifier)))
(import_decl
(long_identifier
(identifier)
(identifier)))))

@ -42,6 +42,130 @@ type Test =
(const
(string)))))))
================================================================================
basic class definition
================================================================================
type A() =
do ()
--------------------------------------------------------------------------------
(file
(type_definition
(anon_type_defn
(type_name
(identifier))
(primary_constr_args)
(class_type_body
(class_function_or_value_defn
(const
(unit)))))))
================================================================================
class inherit definition
================================================================================
type A() =
inherit ControllerBase()
--------------------------------------------------------------------------------
(file
(type_definition
(anon_type_defn
(type_name (identifier))
(primary_constr_args)
(class_type_body
(class_inherits_decl
(type
(long_identifier (identifier)))
(const (unit)))))))
================================================================================
basic class member definition
================================================================================
type A() =
member this.Post() = ()
--------------------------------------------------------------------------------
(file
(type_definition
(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)))))))))
================================================================================
class inherit and do definition
================================================================================
type A() =
inherit ControllerBase()
do ()
--------------------------------------------------------------------------------
(file
(type_definition
(anon_type_defn
(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 inherit and member method definition
================================================================================
type A() =
inherit ControllerBase()
member ctx.Index() = ()
--------------------------------------------------------------------------------
(file
(type_definition
(anon_type_defn
(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)))))))))
================================================================================
Recursive type definition
================================================================================
@ -69,7 +193,8 @@ and 'T maybe = Maybe<'T>
(UNEXPECTED 'B')
(UNEXPECTED 'T'))
(union_type_case
(identifier))))
(identifier)))
(UNEXPECTED 'a'))
(type
(type
(type_argument

@ -389,11 +389,11 @@ module.exports = grammar({
)),
call_expression: $ =>
prec(PREC.PAREN_APP,
prec.right(PREC.PAREN_APP+100,
seq(
$._expression,
imm("("),
$._expression,
optional($._expression),
")",
)
),
@ -659,11 +659,11 @@ module.exports = grammar({
)),
declaration_expression: $ =>
prec(PREC.LET_EXPR,
prec.right(PREC.LET_EXPR,
seq(
choice(
seq(choice("use", "use!"), $.identifier, "=", $._virtual_open_aligned, $._expression, $._virtual_end_section),
$.function_or_value_defn,
seq(choice("use", "use!"), $.identifier, "=", $._virtual_open_aligned, $._expression, $._virtual_end_section),
$.function_or_value_defn,
),
$._virtual_open_aligned,
field("in", $._expression),
@ -1099,9 +1099,9 @@ module.exports = grammar({
$.record_type_defn,
$.union_type_defn,
$.anon_type_defn,
$.class_type_defn,
$.struct_type_defn,
$.interface_type_defn,
// $.class_type_defn,
// $.struct_type_defn,
// $.interface_type_defn,
$.enum_type_defn,
$.type_abbrev_defn,
$.type_extension,
@ -1143,35 +1143,35 @@ module.exports = grammar({
$.type,
),
class_type_defn: $ =>
seq(
$.type_name,
optional($.primary_constr_args),
"=",
"class",
$.class_type_body,
"end",
),
struct_type_defn: $ =>
seq(
$.type_name,
optional($.primary_constr_args),
"=",
"struct",
$.class_type_body,
"end",
),
interface_type_defn: $ =>
seq(
$.type_name,
optional($.primary_constr_args),
"=",
"interface",
$.class_type_body,
"end",
),
// class_type_defn: $ =>
// seq(
// $.type_name,
// optional($.primary_constr_args),
// "=",
// "class",
// $.class_type_body,
// "end",
// ),
//
// struct_type_defn: $ =>
// seq(
// $.type_name,
// optional($.primary_constr_args),
// "=",
// "struct",
// $.class_type_body,
// "end",
// ),
//
// interface_type_defn: $ =>
// seq(
// $.type_name,
// optional($.primary_constr_args),
// "=",
// "interface",
// $.class_type_body,
// "end",
// ),
_class_type_body_inner: $ =>
choice(
@ -1353,7 +1353,7 @@ module.exports = grammar({
property_or_ident: $ =>
choice(
seq($.identifier, ".", $.identifier),
seq(field("instance", $.identifier), ".", $.identifier),
$.identifier
),
@ -1361,6 +1361,7 @@ module.exports = grammar({
prec(3,
choice(
seq($.property_or_ident, "with", $._function_or_value_defns),
seq($.property_or_ident, $._pattern, "=", $._expression),
seq($.property_or_ident, "=", $._expression),
seq($.property_or_ident, "=", $._expression, "with", "get"),
seq($.property_or_ident, "=", $._expression, "with", "set"),
@ -1400,7 +1401,9 @@ module.exports = grammar({
seq(
"inherit",
$.type,
$._virtual_open_section,
optional($._expression),
$._virtual_end_section,
)
),

@ -1391,8 +1391,8 @@
}
},
"call_expression": {
"type": "PREC",
"value": 23,
"type": "PREC_RIGHT",
"value": 123,
"content": {
"type": "SEQ",
"members": [
@ -1408,8 +1408,16 @@
}
},
{
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
@ -2461,7 +2469,7 @@
}
},
"declaration_expression": {
"type": "PREC",
"type": "PREC_RIGHT",
"value": 6,
"content": {
"type": "SEQ",
@ -4028,18 +4036,6 @@
"type": "SYMBOL",
"name": "anon_type_defn"
},
{
"type": "SYMBOL",
"name": "class_type_defn"
},
{
"type": "SYMBOL",
"name": "struct_type_defn"
},
{
"type": "SYMBOL",
"name": "interface_type_defn"
},
{
"type": "SYMBOL",
"name": "enum_type_defn"
@ -4165,117 +4161,6 @@
}
]
},
"class_type_defn": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "type_name"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "primary_constr_args"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "="
},
{
"type": "STRING",
"value": "class"
},
{
"type": "SYMBOL",
"name": "class_type_body"
},
{
"type": "STRING",
"value": "end"
}
]
},
"struct_type_defn": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "type_name"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "primary_constr_args"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "="
},
{
"type": "STRING",
"value": "struct"
},
{
"type": "SYMBOL",
"name": "class_type_body"
},
{
"type": "STRING",
"value": "end"
}
]
},
"interface_type_defn": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "type_name"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "primary_constr_args"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "="
},
{
"type": "STRING",
"value": "interface"
},
{
"type": "SYMBOL",
"name": "class_type_body"
},
{
"type": "STRING",
"value": "end"
}
]
},
"_class_type_body_inner": {
"type": "CHOICE",
"members": [
@ -5183,8 +5068,12 @@
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
"type": "FIELD",
"name": "instance",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "STRING",
@ -5225,6 +5114,27 @@
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "property_or_ident"
},
{
"type": "SYMBOL",
"name": "_pattern"
},
{
"type": "STRING",
"value": "="
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
},
{
"type": "SEQ",
"members": [
@ -5544,6 +5454,10 @@
"type": "SYMBOL",
"name": "type"
},
{
"type": "SYMBOL",
"name": "_virtual_open_section"
},
{
"type": "CHOICE",
"members": [
@ -5555,6 +5469,10 @@
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_virtual_end_section"
}
]
}
@ -6037,6 +5955,19 @@
"type": "PATTERN",
"value": "\\r?\\n"
},
"unit": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "STRING",
"value": ")"
}
]
},
"const": {
"type": "CHOICE",
"members": [
@ -6125,17 +6056,8 @@
"value": "true"
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "STRING",
"value": ")"
}
]
"type": "SYMBOL",
"name": "unit"
}
]
},

@ -767,29 +767,6 @@
]
}
},
{
"type": "class_type_defn",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "class_type_body",
"named": true
},
{
"type": "primary_constr_args",
"named": true
},
{
"type": "type_name",
"named": true
}
]
}
},
{
"type": "compiler_directive_decl",
"named": true,
@ -1758,29 +1735,6 @@
]
}
},
{
"type": "interface_type_defn",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "class_type_body",
"named": true
},
{
"type": "primary_constr_args",
"named": true
},
{
"type": "type_name",
"named": true
}
]
}
},
{
"type": "list_expression",
"named": true,
@ -1979,6 +1933,10 @@
"type": "_expression",
"named": true
},
{
"type": "_pattern",
"named": true
},
{
"type": "function_declaration_left",
"named": true
@ -2303,9 +2261,20 @@
{
"type": "property_or_ident",
"named": true,
"fields": {},
"fields": {
"instance": {
"multiple": false,
"required": false,
"types": [
{
"type": "identifier",
"named": true
}
]
}
},
"children": {
"multiple": true,
"multiple": false,
"required": true,
"types": [
{
@ -2620,29 +2589,6 @@
"named": true,
"fields": {}
},
{
"type": "struct_type_defn",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "class_type_body",
"named": true
},
{
"type": "primary_constr_args",
"named": true
},
{
"type": "type_name",
"named": true
}
]
}
},
{
"type": "symbolic_op",
"named": true,
@ -2851,10 +2797,6 @@
"type": "attributes",
"named": true
},
{
"type": "class_type_defn",
"named": true
},
{
"type": "delegate_type_defn",
"named": true
@ -2863,18 +2805,10 @@
"type": "enum_type_defn",
"named": true
},
{
"type": "interface_type_defn",
"named": true
},
{
"type": "record_type_defn",
"named": true
},
{
"type": "struct_type_defn",
"named": true
},
{
"type": "type_abbrev_defn",
"named": true
@ -3550,10 +3484,6 @@
"type": "begin",
"named": false
},
{
"type": "class",
"named": false
},
{
"type": "comparison",
"named": false

1251628
src/parser.c

File diff suppressed because it is too large Load Diff