Fix support for Func(...).Value

Need to set associativity on selected_component
This commit is contained in:
Emmanuel Briot 2022-12-12 10:48:06 +01:00
parent 7bd8543b71
commit ec82f7b2cf
11 changed files with 38248 additions and 38063 deletions

View File

@ -106,10 +106,6 @@ module.exports = grammar({
[$._name, $.package_body_stub],
],
inline: $ => [
// To avoid conflicts
$.selected_component,
],
rules: {
compilation: $ => repeat(
@ -145,13 +141,17 @@ module.exports = grammar({
$.string_literal, // name of an operator. However, in a number of
// places using a string doesn't make sense.
),
selected_component: $ => seq( // RM 4.1.3
$.identifier,
selected_component: $ => prec.left(seq( // RM 4.1.3
field('prefix', $._name),
seq(
'.',
$._name,
field('selector_name', choice(
$.identifier,
$.character_literal,
$.string_literal,
)),
),
),
)),
target_name: $ => '@', // RM 5.2.1
_name_list: $ => prec.left(comma_separated_list_of($._name)),
_defining_identifier_list: $ => comma_separated_list_of($.identifier),

View File

@ -98,6 +98,7 @@
(comment) @spell ;; spell-check comments
(string_literal) @string
(string_literal) @spell ;; spell-check strings
(character_literal) @string
(identifier) @variable
(numeric_literal) @number
@ -141,6 +142,7 @@
(range_constraint "range" @type.definition)
(signed_integer_type_definition "range" @type.definition)
(index_subtype_definition "range" @type.definition)
(private_type_declaration "is" @type.definition "private" @type.definition)
;; Gray the body of expression functions
(expression_function_declaration

View File

@ -2,9 +2,11 @@
;; references. However, this is not yet supported by neovim
;; See https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables
(compilation) @scope
(package_specification) @scope
(procedure_specification) @scope
(function_specification) @scope
(package_body) @scope
(subprogram_declaration) @scope
(subprogram_body) @scope
(block_statement) @scope
(with_clause (identifier) @definition.import)

View File

@ -181,26 +181,51 @@
]
},
"selected_component": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "prefix",
"content": {
"type": "SYMBOL",
"name": "_name"
}
]
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "FIELD",
"name": "selector_name",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "character_literal"
},
{
"type": "SYMBOL",
"name": "string_literal"
}
]
}
}
]
}
]
}
},
"target_name": {
"type": "STRING",
@ -14609,9 +14634,7 @@
],
"precedences": [],
"externals": [],
"inline": [
"selected_component"
],
"inline": [],
"supertypes": []
}

File diff suppressed because it is too large Load Diff

75428
src/parser.c

File diff suppressed because it is too large Load Diff

View File

@ -70,15 +70,16 @@ end;
(identifier)
(expression
(term
(identifier)
(identifier)))))
(selected_component
(identifier)
(identifier))))))
(statement
(procedure_call_statement
(identifier)
(function_call
(selected_component
(identifier)
(actual_parameter_part
(parameter_association
(expression
(term
(numeric_literal))))))))))))
(identifier))
(actual_parameter_part
(parameter_association
(expression
(term
(numeric_literal)))))))))))

View File

@ -13,8 +13,9 @@ use Ada.Text_IO, System;
(compilation
(compilation_unit
(with_clause
(identifier)
(identifier)
(selected_component
(identifier)
(identifier))
(identifier)))
(comment)
(compilation_unit
@ -29,8 +30,9 @@ use Ada.Text_IO, System;
(identifier)))
(compilation_unit
(use_clause
(identifier)
(identifier)
(selected_component
(identifier)
(identifier))
(identifier))))
================================================================================
@ -72,8 +74,9 @@ end;
(identifier)))
(compilation_unit
(package_specification
(identifier)
(identifier)
(selected_component
(identifier)
(identifier))
(comment))))
================================================================================
@ -94,8 +97,9 @@ end Child.P2;
(compilation
(compilation_unit
(package_body
(identifier)
(identifier)
(selected_component
(identifier)
(identifier))
(non_empty_declarative_part
(package_body
(identifier)
@ -106,8 +110,9 @@ end Child.P2;
(handled_sequence_of_statements
(statement
(null_statement)))
(identifier)
(identifier))))
(selected_component
(identifier)
(identifier)))))
================================================================================
separate

View File

@ -33,8 +33,9 @@ end P;
(identifier))
(package_renaming_declaration
(identifier)
(identifier)
(identifier))
(selected_component
(identifier)
(identifier)))
(subprogram_renaming_declaration
(procedure_specification
(identifier)

View File

@ -101,13 +101,14 @@ end P;
(statement
(loop_statement
(iteration_scheme
(iterator_specification
(loop_parameter_specification
(identifier)
(identifier)
(identifier)
(tick)
(attribute_designator
(identifier))))
(range_g
(selected_component
(identifier)
(identifier))
(tick)
(range_attribute_designator))))
(statement
(goto_statement
(identifier)))
@ -472,8 +473,9 @@ end;
(term
(allocator
(subpool_specification
(identifier)
(identifier))
(selected_component
(identifier)
(identifier)))
(qualified_expression
(identifier)
(tick)
@ -542,9 +544,10 @@ end;
(handled_sequence_of_statements
(statement
(assignment_statement
(identifier)
(function_call
(identifier)
(selected_component
(identifier)
(identifier))
(actual_parameter_part
(parameter_association
(expression
@ -558,9 +561,10 @@ end;
(numeric_literal)))))
(statement
(assignment_statement
(identifier)
(function_call
(identifier)
(selected_component
(identifier)
(identifier))
(actual_parameter_part
(parameter_association
(expression

View File

@ -499,3 +499,28 @@ procedure Proc (A : access Integer);
(identifier)
(access_definition
(identifier))))))))
================================================================================
Subprogram and field access
================================================================================
V := Func (2).Value;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(statement
(assignment_statement
(identifier)
(expression
(term
(selected_component
(function_call
(identifier)
(actual_parameter_part
(parameter_association
(expression
(term
(numeric_literal))))))
(identifier))))))))