Skip to content

Commit

Permalink
simplify attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nsidorenco committed Jul 29, 2024
1 parent 5a9e0c5 commit eb415fe
Show file tree
Hide file tree
Showing 11 changed files with 362,665 additions and 362,779 deletions.
13 changes: 7 additions & 6 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ module.exports = grammar({
$._record_type_defn_inner,
$._union_type_defn_inner,
$._then_expression,
$._attribute_target,
],

supertypes: ($) => [
Expand Down Expand Up @@ -188,17 +189,17 @@ module.exports = grammar({
//
// Attributes (BEGIN)
//
attributes: ($) => prec.left(repeat1($.attribute_set)),
attribute_set: ($) =>
attributes: ($) => prec.left(repeat1($._attribute_set)),
_attribute_set: ($) =>
seq(
"[<",
$.attribute,
prec(PREC.SEQ_EXPR + 1, repeat(seq($._newline, $.attribute))),
">]",
),
attribute: ($) =>
seq(optional(seq($.attribute_target, ":")), $.object_construction),
attribute_target: (_) =>
seq(optional(seq($._attribute_target, ":")), $._object_construction),
_attribute_target: (_) =>
choice(
"assembly",
"module",
Expand All @@ -211,7 +212,7 @@ module.exports = grammar({
"event",
),

object_construction: ($) =>
_object_construction: ($) =>
prec.left(PREC.SEQ_EXPR + 1, seq($.type, optional($._expression))),

//
Expand Down Expand Up @@ -529,7 +530,7 @@ module.exports = grammar({
prec(PREC.NEW_EXPR, seq("new", $._base_call, $._object_expression_inner)),

_base_call: ($) =>
seq($.object_construction, optional(seq("as", $.identifier))),
seq($._object_construction, optional(seq("as", $.identifier))),

prefixed_expression: ($) =>
seq(
Expand Down
69 changes: 39 additions & 30 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@

(primary_constr_args (_) @variable.parameter)

(class_as_reference
(_) @variable.parameter.builtin)


((identifier_pattern (long_identifier (identifier) @character.special))
(#match? @character.special "^\_.*"))

((long_identifier
(identifier)+
.
(identifier) @variable.member))

;; ----------------------------------------------------------------------------
;; Punctuation

Expand Down Expand Up @@ -60,6 +59,9 @@
.
(_) @variable)

(optional_pattern
"?" @character.special)

(fsi_directive_decl . (string) @module)

(import_decl . (_) @module)
Expand All @@ -84,17 +86,13 @@
(identifier) @property))

(dot_expression
base: (_) @module
field: (_) @variable.member)
base: (_)? @module)

(value_declaration_left . (_) @variable)

(function_declaration_left
. (_) @function
[
(argument_patterns)
(argument_patterns (long_identifier (identifier)))
] @variable.parameter)
. (_)* @variable_parameter)

(member_defn
(method_or_prop_defn
Expand All @@ -108,14 +106,7 @@

(application_expression
.
[
(long_identifier_or_op [
(long_identifier (identifier)* (identifier) @function.call)
(identifier) @function.call
])
(typed_expression . (long_identifier_or_op (long_identifier (identifier)* . (identifier) @function.call)))
(dot_expression base: (_) @variable.member field: (_) @function.call)
] @function.call)
(_) @function.call)

((infix_expression
.
Expand Down Expand Up @@ -170,6 +161,9 @@

(compiler_directive_decl) @keyword.directive

(preproc_line
"#line" @keyword.directive)

(attribute) @attribute

[
Expand All @@ -183,9 +177,12 @@
"|]"
"{|"
"|}"
] @punctuation.bracket

[
"[<"
">]"
] @punctuation.bracket
] @punctuation.special

(format_string_eval
[
Expand Down Expand Up @@ -279,17 +276,11 @@
"type"
"inherit"
"interface"
"struct"
"and"
"class"
"struct"
] @keyword.type

(try_expression
[
"try"
"with"
"finally"
] @keyword.exception)

((identifier) @keyword.exception
(#any-of? @keyword.exception "failwith" "failwithf" "raise" "reraise"))

Expand Down Expand Up @@ -327,6 +318,13 @@

(match_expression "with" @keyword.conditional)

(try_expression
[
"try"
"with"
"finally"
] @keyword.exception)

((type
(long_identifier (identifier) @type.builtin))
(#any-of? @type.builtin "bool" "byte" "sbyte" "int16" "uint16" "int" "uint" "int64" "uint64" "nativeint" "unativeint" "decimal" "float" "double" "float32" "single" "char" "string" "unit"))
Expand All @@ -346,8 +344,19 @@
.
(identifier)))

(long_identifier_or_op
(op_identifier) @operator)
(op_identifier) @operator

((identifier) @module.builtin
(#any-of? @module.builtin "Array" "Async" "Directory" "File" "List" "Option" "Path" "Map" "Set" "Lazy" "Seq" "Task" "String" "Result" ))

((value_declaration
(attributes
(attribute
(type
(long_identifier
(identifier) @attribute_name))))
(function_or_value_defn
(value_declaration_left
.
(_) @constant)))
(#eq? @attribute_name "Literal"))
17 changes: 9 additions & 8 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit eb415fe

Please sign in to comment.