fix(nim): minor improvements to queries and parser (#5784)

* fix(nim): bump parser again to include minor fix

* fix(nim): shifting around for precedence

* fix(nim): added new fields from recent parser version,
improved support for (conditional_declaration) and (variant_declaration)
This commit is contained in:
aMOPel 2023-12-18 17:32:06 +01:00 committed by GitHub
parent 25ddfde8d7
commit edacfa2eed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 51 deletions

View file

@ -12,6 +12,8 @@
(case) (case)
(if) (if)
(when) (when)
(conditional_declaration)
(variant_declaration)
(of_branch) (of_branch)
(elif_branch) (elif_branch)
(else_branch) (else_branch)

View file

@ -29,6 +29,28 @@
; (type_expression) @type ; (type_expression) @type
; and before @preproc and all literals ; and before @preproc and all literals
; constants/enums in array construction
(array_construction
(colon_expression
left: (_) @constant))
; NOTE: has to be before literals and punctuation etc.
; identifiers in "case" "of" branches have to be enums
(case
alternative:
(of_branch
values:
(expression_list (_) @constant)))
; NOTE: has to be before literals and punctuation etc.
; in variant objects with "case" "of"
(variant_declaration
alternative:
(of_branch
values:
(expression_list (_) @constant)))
; NOTE: has to be before literals and punctuation etc.
; ============================================================================= ; =============================================================================
; @comment ; line and block comments ; @comment ; line and block comments
@ -448,6 +470,7 @@
; when accessing and directly call elements from an array of routines ; when accessing and directly call elements from an array of routines
; eg `array_of_routines[index](arguments), but that is an uncommon case ; eg `array_of_routines[index](arguments), but that is an uncommon case
; dot_generic_call `v.call[:type, type]()
(dot_generic_call (dot_generic_call
generic_arguments: (_) @type) generic_arguments: (_) @type)
@ -643,16 +666,6 @@
; ============================================================================= ; =============================================================================
; @constant ; constant identifiers ; @constant ; constant identifiers
; identifiers in "case" "of" branches have to be enums
(case
(of_branch values:
(expression_list (_) @constant)))
; in variant objects with "case" "of"
(variant_declaration
(of_branch values:
(expression_list (_) @constant)))
; enum declaration ; enum declaration
(enum_field_declaration (enum_field_declaration
(symbol_declaration (symbol_declaration
@ -661,11 +674,6 @@
(accent_quoted (identifier) @constant) (accent_quoted (identifier) @constant)
])) ]))
; constants/enums in array construction
(array_construction
(colon_expression
left: (_) @constant))
; constant declaration ; constant declaration
(const_section (const_section
(variable_declaration (variable_declaration

View file

@ -193,28 +193,21 @@
; ============================================================================== ; ==============================================================================
; @definition.field ; fields or properties ; @definition.field ; fields or properties
(object_declaration ; object_declaration
(field_declaration_list ; variant_declaration
(field_declaration ; conditional_declaration
(symbol_declaration_list ; tuple_type inline
(symbol_declaration ; tuple_type multiline
name: [ (field_declaration
(identifier) @definition.field (symbol_declaration_list
(accent_quoted) @definition.field (symbol_declaration
(exported_symbol (identifier) @definition.field) name: [
(exported_symbol (accent_quoted) @definition.field) (identifier) @definition.field
])) (accent_quoted) @definition.field
type: (type_expression)? @definition.associated))) (exported_symbol (identifier) @definition.field)
(exported_symbol (accent_quoted) @definition.field)
(tuple_type ]))
(field_declaration type: (type_expression)? @definition.associated)
(symbol_declaration_list
(symbol_declaration
name: [
(identifier) @definition.field
(accent_quoted) @definition.field
]))
type: (type_expression)? @definition.associated))
; ============================================================================== ; ==============================================================================
; @definition.enum ; enumerations ; @definition.enum ; enumerations
@ -273,9 +266,9 @@
alternative: (else_branch)? @scope) alternative: (else_branch)? @scope)
(case (case
(of_branch)* @scope alternative: (of_branch)* @scope
(elif_branch)* @scope alternative: (elif_branch)* @scope
(else_branch)? @scope) alternative: (else_branch)? @scope)
(try (try
body: (statement_list) @scope body: (statement_list) @scope