Additions to the grammar

This currently fails the testsuite because of ambiguities
This commit is contained in:
Emmanuel Briot 2022-10-21 14:11:41 +02:00
parent bb4c5973e6
commit 51a69f0fb4
5 changed files with 716 additions and 184 deletions

10
.gitignore vendored
View File

@ -1,11 +1,13 @@
binding.gyp binding.gyp
bindings/node/binding.cc
bindings/node/index.js
bindings/rust/build.rs
bindings/rust/lib.rs
Cargo.lock
Cargo.toml Cargo.toml
log.html
node_modules/ node_modules/
src/grammar.json src/grammar.json
src/node-types.json src/node-types.json
src/parser.c src/parser.c
src/tree_sitter/parser.h src/tree_sitter/parser.h
bindings/node/binding.cc
bindings/node/index.js
bindings/rust/build.rs
bindings/rust/lib.rs

View File

@ -1,16 +1,12 @@
================================================================================ ================================================================================
packages with clauses
================================================================================ ================================================================================
with Ada.Text_IO; with Ada.Text_IO, System; -- multiple names, and fully qualified
package P1 is limited with Ada; -- limited with
package Nested is private with Ada;
end Nested; limited private with Ada;
end P1; use Ada.Text_IO, System;
PriVaTe PACKAGE P2 is -- comment to be ignored
private
end;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -25,57 +21,174 @@ end;
(identifier))) (identifier)))
(selector_name (selector_name
(direct_name (direct_name
(identifier)))))))) (identifier)))))
(name
(direct_name
(identifier))))))
(comment)
(compilation_unit (compilation_unit
(package_specification (with_clause
(identifier) (name_list
(package_specification (name
(identifier) (direct_name
(identifier)) (identifier))))))
(comment)
(compilation_unit
(with_clause
(name_list
(name
(direct_name
(identifier))))))
(compilation_unit
(with_clause
(name_list
(name
(direct_name
(identifier))))))
(compilation_unit
(use_clause
(name_list
(name
(selected_component
(name
(direct_name
(identifier))) (identifier)))
(compilation_unit (selector_name
(package_specification (direct_name
(identifier) (identifier)))))
(comment)))) (name
(direct_name
(identifier)))))))
================================================================================ =====
Types Case insensitive
================================================================================ =====
package P is PACkaGe P1 Is
type A is range 1 .. 2; enD;
type B is new Integer;
end P;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(compilation (compilation
(compilation_unit (compilation_unit
(package_specification (package_specification
(identifier) (name))))
(type_declaration
(full_type_declaration ================================================================================
(identifier) multiple compilation units
(type_definition ================================================================================
(integer_type_definition
(signed_integer_type_definition package P1 is
(simple_expression package Nested is
(term end Nested;
(factor end P1;
(primary
(numeric_literal))))) private package Child.P2 is -- comment to be ignored
(simple_expression private
(term end;
(factor
(primary --------------------------------------------------------------------------------
(numeric_literal))))))))))
(type_declaration (compilation
(full_type_declaration (compilation_unit
(identifier) (package_specification
(type_definition (name
(derived_type_definition (direct_name
(subtype_indication (identifier)))
(package_specification
(name
(direct_name
(identifier)))
(name
(direct_name
(identifier))))
(name
(direct_name
(identifier)))))
(compilation_unit
(package_specification
(name
(selected_component
(name
(direct_name
(identifier)))
(selector_name
(direct_name
(identifier)))))
(comment))))
=========
body
=========
package body Child.P2 is
package body Nested is
begin
null;
end Nested;
begin
null;
end Child.P2;
---
(compilation
(compilation_unit
(proper_body
(package_body
(name
(selected_component
(name
(direct_name
(identifier)))
(selector_name
(direct_name
(identifier)))))
(non_empty_declarative_part
(declarative_item_pragma
(proper_body
(package_body
(name
(direct_name
(identifier)))
(handled_sequence_of_statements
(sequence_of_statements
(statement
(simple_statement
(null_statement)))))
(name
(direct_name
(identifier)))))))
(handled_sequence_of_statements
(sequence_of_statements
(statement
(simple_statement
(null_statement)))))
(name
(selected_component
(name
(direct_name
(identifier)))
(selector_name
(direct_name
(identifier)))))))))
================================================================================
separate
================================================================================
separate (Child) package body P2 is
end;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(subunit
(name
(direct_name
(identifier)))
(proper_body
(package_body
(name (name
(direct_name (direct_name
(identifier)))))))) (identifier))))))))
(identifier))))

View File

@ -1,50 +1,9 @@
================================================================================ ================================================================================
packages Range type
================================================================================
with Ada.Text_IO;
package P1 is
package Nested is
end Nested;
end P1;
PriVaTe PACKAGE P2 is -- comment to be ignored
private
end;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(with_clause
(name_list
(name
(selected_component
(name
(direct_name
(identifier)))
(selector_name
(direct_name
(identifier))))))))
(compilation_unit
(package_specification
(identifier)
(package_specification
(identifier)
(identifier))
(identifier)))
(compilation_unit
(package_specification
(identifier)
(comment))))
================================================================================
Types
================================================================================ ================================================================================
package P is package P is
type A is range 1 .. 2; type A is range 1 .. 2;
type B is new Integer;
end P; end P;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -52,7 +11,9 @@ end P;
(compilation (compilation
(compilation_unit (compilation_unit
(package_specification (package_specification
(identifier) (name
(direct_name
(identifier)))
(type_declaration (type_declaration
(full_type_declaration (full_type_declaration
(identifier) (identifier)
@ -69,6 +30,26 @@ end P;
(factor (factor
(primary (primary
(numeric_literal)))))))))) (numeric_literal))))))))))
(name
(direct_name
(identifier))))))
================================================================================
Derived type
================================================================================
package P is
type B is new Integer;
end P;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(package_specification
(name
(direct_name
(identifier)))
(type_declaration (type_declaration
(full_type_declaration (full_type_declaration
(identifier) (identifier)
@ -78,4 +59,6 @@ end P;
(name (name
(direct_name (direct_name
(identifier)))))))) (identifier))))))))
(identifier)))) (name
(direct_name
(identifier))))))

View File

@ -14,6 +14,26 @@ function caseInsensitive (keyword) {
) )
} }
/**
* A list of rules
*/
function list_of(separator, rule) {
return seq(
rule,
repeat(seq(
separator,
rule,
)),
);
}
/**
* Handles comma-separated lists of rules
*/
function comma_separated_list_of(rule) {
return list_of(',', rule)
}
module.exports = grammar({ module.exports = grammar({
name: 'ada', name: 'ada',
@ -22,14 +42,45 @@ module.exports = grammar({
$.comment, $.comment,
], ],
// word: $ => $.keyword,
word: $ => $.identifier, word: $ => $.identifier,
conflicts: $ => [
// "name" can be either a simple name, or a defining_identifier_list
// [$.direct_name, $.defining_identifier_list],
// "function_specification is" could be either an expression function
// specification, or a function specification
// ??? Maybe we can merge both in the grammar
[$.expression_function_declaration, $.subprogram_specification],
// ??? Maybe we can merge these
[$.null_procedure_declaration, $.subprogram_specification],
// "'for' direct_name * 'use'" could also be "'for' name * 'use'" as
// specified in at_clause.
[$.at_clause, $.name],
// "procedure name is" could be either a procedure specification, or
// a generic_instantiation.
[$.generic_instantiation, $.procedure_specification],
// Same for "package_specification ;"
[$.generic_package_declaration, $._package_declaration],
[$.attribute_definition_clause, $.attribute_reference],
[$.record_extension_part, $.derived_type_definition],
],
rules: { rules: {
compilation: $ => repeat( compilation: $ => repeat(
$.compilation_unit, $.compilation_unit,
), ),
identifier: $ => /[a-zA-Z_]\w*/, keyword: $ => /[a-zA-Z]+/,
identifier: $ =>
/[a-zA-Z\u{80}-\u{10FFFF}][0-9a-zA-Z_\u{80}-\u{10FFFF}]*/u,
comment: $ => token(seq('--', /.*/)), comment: $ => token(seq('--', /.*/)),
string_literal: $ => token(/"[^"]*"/), string_literal: $ => token(/"[^"]*"/),
character_literal: $ => token(/'.'/), character_literal: $ => token(/'.'/),
@ -44,8 +95,11 @@ module.exports = grammar({
binary_adding_operator: $ => choice('+', '-', '&'), binary_adding_operator: $ => choice('+', '-', '&'),
unary_adding_operator: $ => choice('+', '-'), unary_adding_operator: $ => choice('+', '-'),
multiplying_operator: $ => choice('*', '/', 'mod', 'rem'), multiplying_operator: $ => choice('*', '/', 'mod', 'rem'),
tick: $ => choice(
'\'', // But is not the start of a character_literal
),
name_list: $ => repeat1($.name), name_list: $ => comma_separated_list_of($.name),
name: $ => choice( name: $ => choice(
$.direct_name, $.direct_name,
$.explicit_dereference, $.explicit_dereference,
@ -56,6 +110,7 @@ module.exports = grammar({
$.qualified_expression, $.qualified_expression,
'@', '@',
), ),
defining_identifier_list: $ => comma_separated_list_of($.identifier),
direct_name: $ => choice( direct_name: $ => choice(
$.identifier, $.identifier,
$.string_literal, $.string_literal,
@ -78,14 +133,14 @@ module.exports = grammar({
attribute_reference: $ => choice( attribute_reference: $ => choice(
seq( seq(
$.name, $.name,
'\'', $.tick,
$.attribute_designator, $.attribute_designator,
), ),
// $.reduction_attribute_reference, // $.reduction_attribute_reference,
), ),
// reduction_attribute_reference: $ => seq( // reduction_attribute_reference: $ => seq(
// $.value_sequence, // $.value_sequence,
// '\'', // $.tick,
// $.reduction_attribute_designator, // $.reduction_attribute_designator,
// ), // ),
reduction_attribute_designator: $ => seq( reduction_attribute_designator: $ => seq(
@ -178,7 +233,7 @@ module.exports = grammar({
), ),
qualified_expression: $ => seq( qualified_expression: $ => seq(
$.name, $.name,
'\'', $.tick,
$.aggregate, $.aggregate,
), ),
compilation_unit: $ => choice( compilation_unit: $ => choice(
@ -222,7 +277,7 @@ module.exports = grammar({
), ),
package_specification: $ => seq( package_specification: $ => seq(
caseInsensitive('package'), caseInsensitive('package'),
field('name', $.identifier), field('name', $.name), // $.defining_program_unit_name),
optional($.aspect_specification), optional($.aspect_specification),
caseInsensitive('is'), caseInsensitive('is'),
optional($._basic_declarative_item_list), optional($._basic_declarative_item_list),
@ -231,7 +286,7 @@ module.exports = grammar({
optional($._basic_declarative_item_list), optional($._basic_declarative_item_list),
)), )),
caseInsensitive('end'), caseInsensitive('end'),
field('endname', optional($.identifier)), field('endname', optional($.name)),
), ),
with_clause: $ => seq( with_clause: $ => seq(
field('is_limited', optional(caseInsensitive('limited'))), field('is_limited', optional(caseInsensitive('limited'))),
@ -240,6 +295,43 @@ module.exports = grammar({
field('names', $.name_list), field('names', $.name_list),
';', ';',
), ),
use_clause: $ => seq(
caseInsensitive('use'),
optional(seq(
field('is_all', optional(caseInsensitive('all'))),
field('is_type', caseInsensitive('type')),
)),
$.name_list,
';',
),
subunit: $ => seq(
caseInsensitive('separate'),
'(',
$.name,
')',
$.proper_body,
),
proper_body: $ => choice(
// $.subprogram_body,
$.package_body,
// $.task_body,
// $.protected_body,
),
package_body: $ => seq(
caseInsensitive('package'),
caseInsensitive('body'),
$.name,
optional($.aspect_specification),
caseInsensitive('is'),
optional($.non_empty_declarative_part),
optional(seq(
caseInsensitive('begin'),
$.handled_sequence_of_statements,
)),
caseInsensitive('end'),
optional($.name),
';',
),
subtype_indication: $ => seq( subtype_indication: $ => seq(
optional($.null_exclusion), optional($.null_exclusion),
$.name, $.name,
@ -362,38 +454,30 @@ module.exports = grammar({
$.name, $.name,
// $.allocator, // $.allocator,
), ),
access_definition: $ => choice( access_definition: $ => seq(
seq(
optional($.null_exclusion), optional($.null_exclusion),
caseInsensitive('access'), caseInsensitive('access'),
optional(caseInsensitive('constrant')), choice(
seq(
optional(caseInsensitive('constant')),
$.name, $.name,
), ),
seq( seq(
optional($.null_exclusion),
caseInsensitive('access'),
optional(caseInsensitive('protected')), optional(caseInsensitive('protected')),
caseInsensitive('procedure'), caseInsensitive('procedure'),
// $.parameter_profile, optional($.non_empty_parameter_profile),
), ),
seq( seq(
optional($.null_exclusion),
caseInsensitive('access'),
optional(caseInsensitive('protected')), optional(caseInsensitive('protected')),
caseInsensitive('function'), caseInsensitive('function'),
// $.parameter__and_result_profile, $.parameter_and_result_profile,
),
), ),
), ),
actual_parameter_part: $ => seq( actual_parameter_part: $ => seq(
'(', '(',
choice( choice(
seq( comma_separated_list_of($.parameter_association),
$.parameter_association,
repeat(seq(
',',
$.parameter_association,
)),
),
// $.conditional_expression, // $.conditional_expression,
// $.quantified_expression, // $.quantified_expression,
// $.declare_expression, // $.declare_expression,
@ -437,13 +521,7 @@ module.exports = grammar({
')', ')',
), ),
record_component_association_list: $ => choice( record_component_association_list: $ => choice(
// seq( // comma_separated_list_of($.record_component_association),
// $.record_component_association,
// repeat(seq(
// ',',
// $.record_component_association,
// )),
// ),
seq( seq(
caseInsensitive('null'), caseInsensitive('null'),
caseInsensitive('record'), caseInsensitive('record'),
@ -455,11 +533,7 @@ module.exports = grammar({
), ),
index_constraint: $ => seq( index_constraint: $ => seq(
'(', '(',
// $.discrete_range, // comma_separated_list_of($.discrete_range),
// repeat1(seq(
// ',',
// discrete_range,
// )),
')', ')',
), ),
digits_constraint: $ => seq( digits_constraint: $ => seq(
@ -477,12 +551,7 @@ module.exports = grammar({
), ),
_basic_declarative_item_pragma: $ => choice( _basic_declarative_item_pragma: $ => choice(
$._basic_declarative_item, $._basic_declarative_item,
// $.pragma_g, $.pragma_g,
),
_basic_declarative_item: $ => choice(
$._basic_declaration,
$.aspect_clause,
$.use_clause,
), ),
type_declaration: $ => choice( type_declaration: $ => choice(
$.full_type_declaration, $.full_type_declaration,
@ -570,16 +639,9 @@ module.exports = grammar({
':', ':',
$.component_definition, $.component_definition,
// optional($.assign_value), // optional($.assign_value),
// optional($.aspect_specification), optional($.aspect_specification),
';' ';'
), ),
defining_identifier_list: $ => seq(
$.identifier,
repeat(seq(
',',
$.identifier,
)),
),
component_definition: $ => seq( component_definition: $ => seq(
optional(caseInsensitive('aliased')), optional(caseInsensitive('aliased')),
choice( choice(
@ -589,27 +651,399 @@ module.exports = grammar({
), ),
// TODO abstract_subprogram_declaration: $ => seq(
optional($.overriding_indicator),
abstract_subprogram_declaration: $ => 'foo1', $.subprogram_specification,
aspect_clause: $ => "foo2", caseInsensitive('is'),
aspect_specification: $ => 'foo3', caseInsensitive('abstract'),
body_stub: $ => "foo6", $.aspect_specification,
entry_declaration: $ => 'foo7', ';',
exception_declaration: $ => 'foo8', ),
expression_function_declaration: $ => 'foo9', array_aggregate: $ => choice(
generic_declaration: $ => 'foo10', // $.position_array_aggregate,
generic_instantiation: $ => 'foo11', // $.null_array_aggregate,
null_procedure_declaration: $ => 'foo24', // $.named_array_aggregate,
number_declaration: $ => 'foo12', ),
object_declaration: $ => 'foo13', aspect_association: $ => seq(
proper_body: $ => "foo15", $.aspect_mark,
renaming_declaration: $ => 'foo16', optional(seq(
statement: $ => 'foo17', '=>',
subprogram_declaration: $ => 'foo18', $.aspect_definition,
subtype_declaration: $ => 'foo19', )),
subunit: $ => 'foo20', ),
use_clause: $ => "foo22", aspect_clause: $ => choice(
$.attribute_definition_clause,
$.enumeration_representation_clause,
$.record_representation_clause,
$.at_clause,
),
aspect_definition: $ => choice(
$.expression,
$.global_aspect_definition,
),
aspect_mark: $ => seq(
$.identifier,
optional(seq(
$.tick,
$.identifier,
)),
),
aspect_mark_list: $ => comma_separated_list_of($.aspect_association),
aspect_specification: $ => seq(
caseInsensitive('with'),
$.aspect_mark_list,
),
at_clause: $ => seq(
caseInsensitive('for'),
$.direct_name,
caseInsensitive('use'),
caseInsensitive('at'),
$.expression,
';',
),
attribute_definition_clause: $ => seq(
caseInsensitive('for'),
$.name,
$.tick,
$.attribute_designator,
caseInsensitive('use'),
$.expression,
';',
),
body_stub: $ => choice(
// $.subprogram_body_stub,
// $.package_body_stub,
// $.task_body_stub,
// $.protected_body_stub,
),
choice_parameter_specification: $ => $.identifier, // ??? inline
component_clause: $ => seq(
$.name,
caseInsensitive('at'),
field('position', $.expression),
caseInsensitive('range'),
field('first_bit', $.simple_expression),
'..',
field('last_bit', $.simple_expression),
';',
),
declarative_item_pragma: $ => choice(
$._declarative_item,
$.pragma_g,
),
non_empty_declarative_part: $ => repeat1(
$.declarative_item_pragma,
),
entry_declaration: $ => seq(
optional($.overriding_indicator),
caseInsensitive('entry'),
$.identifier,
optional(seq(
'(',
$.discrete_subtype_definition,
')',
)),
optional($.non_empty_parameter_profile),
optional($.aspect_specification),
';',
),
enumeration_aggregate: $ => $.array_aggregate, // ??? inline
enumeration_representation_clause: $ => seq(
caseInsensitive('for'),
$.name,
caseInsensitive('use'),
$.enumeration_aggregate,
';',
),
exception_choice_list: $ => list_of('|', $.exception_choice),
exception_choice: $ => choice(
$.name,
caseInsensitive('others'),
),
exception_declaration: $ => seq(
$.defining_identifier_list,
':',
caseInsensitive('exception'),
optional($.aspect_specification),
';',
),
exception_handler: $ => seq(
caseInsensitive('when'),
optional(seq(
$.choice_parameter_specification,
':',
)),
$.exception_choice_list,
'=>',
$.sequence_of_statements,
),
exception_handler_list: $ => repeat1(choice(
$.exception_handler,
$.pragma_g,
)),
expression_function_declaration: $ => seq(
optional($.overriding_indicator),
$.function_specification,
caseInsensitive('is'),
'(',
$.expression,
')',
optional($.aspect_specification),
';',
),
formal_part: $ => seq(
'(',
$.parameter_specification_list,
')',
),
function_specification: $ => seq(
caseInsensitive('function'),
$.name,
$.parameter_and_result_profile,
),
generic_declaration: $ => choice(
$.generic_subprogram_declaration,
$.generic_package_declaration,
),
generic_formal_part: $ => seq(
caseInsensitive('generic'),
repeat($.generic_formal_parameter_declaration),
),
generic_formal_parameter_declaration: $ => choice(
// $.formal_objet_declaration,
// $.formal_type_declaration,
// $.formal_subprogram_declaration,
// $.formal_package_declaration,
$.use_clause,
$.pragma_g,
),
generic_subprogram_declaration: $ => seq(
$.generic_formal_part,
$.subprogram_specification,
optional($.aspect_specification),
';',
),
generic_package_declaration: $ => seq(
$.generic_formal_part,
$.package_specification,
';',
),
generic_instantiation: $ => seq(
choice(
caseInsensitive('package'),
seq(
optional($.overriding_indicator),
choice(
caseInsensitive('procedure'),
caseInsensitive('function'),
),
),
),
$.name,
caseInsensitive('is'),
caseInsensitive('new'),
$.name, // includes the generic_actual_part
optional($.aspect_specification),
';',
),
global_aspect_definition: $ => choice(
seq(
$.global_mode,
// $.global_designator,
),
// $.extended_global_aspect_definition,
seq(
'(',
comma_separated_list_of($.global_aspect_element),
')',
),
),
global_aspect_element: $ => choice(
seq(
$.global_mode,
$.global_set,
),
// $.extended_global_aspect_definition,
),
global_mode: $ => choice(
$.non_empty_mode,
caseInsensitive('overriding'),
),
global_set: $ => prec.left(
comma_separated_list_of($.name), // ??? name_list
),
handled_sequence_of_statements: $ => seq(
$.sequence_of_statements,
optional(seq(
caseInsensitive('exception'),
$.exception_handler_list,
)),
),
label: $ => seq(
'<<',
field('statement_identifier', $.direct_name),
'>>',
),
mod_clause: $ => seq(
caseInsensitive('at'),
caseInsensitive('mod'),
$.expression,
';',
),
non_empty_mode: $ => choice(
caseInsensitive('in'),
seq(
caseInsensitive('in'),
caseInsensitive('out'),
),
caseInsensitive('out'),
),
null_procedure_declaration: $ => seq(
optional($.overriding_indicator),
$.procedure_specification,
caseInsensitive('is'),
caseInsensitive('null'),
// optional($.aspect_specification),
),
null_statement: $ => seq(
caseInsensitive('null'),
';',
),
number_declaration: $ => seq(
$.defining_identifier_list,
';',
caseInsensitive('constant'),
// $.assign_value,
';',
),
object_declaration: $ => choice(
seq(
$.defining_identifier_list,
':',
caseInsensitive('aliased'),
caseInsensitive('constant'),
choice(
$.subtype_indication,
$.access_definition,
// $.array_type_definition,
),
// optional($.assign_value),
optional($.aspect_specification),
';',
),
// $.single_task_declaration,
// $.single_protected_declaration,
),
overriding_indicator: $ => seq(
optional(caseInsensitive('not')),
caseInsensitive('overriding'),
),
non_empty_parameter_profile: $ => // ??? inline
$.formal_part,
parameter_and_result_profile: $ => seq(
optional($.formal_part),
$.result_profile,
),
parameter_specification: $ => seq(
$.defining_identifier_list,
':',
optional(caseInsensitive('aliased')),
optional($.non_empty_mode),
optional($.null_exclusion),
$.name,
// optional($.assign_value),
),
parameter_specification_list: $ => list_of(
';',
$.parameter_specification,
),
pragma_g: $ => seq(
caseInsensitive('pragma'),
$.identifier,
optional(seq(
'(',
choice(
// $.pragma_argument_association_list,
// $.conditional_quantified_expression,
),
')',
)),
';'
),
procedure_specification: $ => seq(
caseInsensitive('procedure'),
$.name,
optional($.non_empty_parameter_profile),
),
record_representation_clause: $ => prec.left(seq(
caseInsensitive('for'),
$.name,
caseInsensitive('use'),
caseInsensitive('record'),
optional($.mod_clause),
repeat($.component_clause),
caseInsensitive('end'),
caseInsensitive('record'),
optional($.name),
)),
renaming_declaration: $ => choice(
// $.object_renaming_declaration,
// $.exception_renaming_declaration,
// $.package_renaming_declaration,
// $.subprogram_renaming_declaration,
// $.generic_renaming_declaration,
),
result_profile: $ => seq(
caseInsensitive('return'),
choice(
seq(
optional($.null_exclusion),
$.name,
),
$.access_definition,
),
),
sequence_of_statements: $ => prec.left(seq(
repeat1($.statement),
repeat($.label),
)),
simple_statement: $ => choice(
$.null_statement,
// $.assignment_statement,
// $.exit_statement,
// $.goto_statement,
// $.procedure_call_statement,
// $.simple_return_statement,
// $.requeue_statement,
// $.delay_statement,
// $.abort_statement,
// $.raise_statement,
$.pragma_g,
),
statement: $ => seq(
repeat($.label),
choice(
$.simple_statement,
// $.compound_statement,
),
),
subprogram_declaration: $ => seq(
optional($.overriding_indicator),
$.subprogram_specification,
optional($.aspect_specification),
';',
),
subprogram_specification: $ => choice(
$.procedure_specification,
$.function_specification,
),
subtype_declaration: $ => seq(
caseInsensitive('subtype'),
$.identifier,
caseInsensitive('is'),
$.subtype_indication,
optional($.aspect_specification),
';',
),
} }
}); });

View File

@ -9,7 +9,7 @@
"scripts": { "scripts": {
"generate": "tree-sitter generate", "generate": "tree-sitter generate",
"test": "tree-sitter generate && tree-sitter test", "test": "tree-sitter generate && tree-sitter test",
"example1": "tree-sitter parse example1.adb" "update-test": "tree-sitter test --update"
}, },
"main": "bindings/node" "main": "bindings/node"
} }