Skip to content

Commit

Permalink
[OCaml] Fix infix operator definition
Browse files Browse the repository at this point in the history
Fixes sublimehq#1756

This commit partly applies the proposed change of the mentioned issue
to fix infix operator definitions as it seems safe enough not to break
something.
  • Loading branch information
deathaxe committed May 6, 2022
1 parent faa4b2c commit 617d7d7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
7 changes: 5 additions & 2 deletions OCaml/OCaml.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,14 @@ contexts:
- include: variables
- include: main
module-signature:
- match: '(val)\s+([a-z_][a-zA-Z0-9_'']*)\s*(:)'
- match: '(val)\s+(?:([a-z_][a-zA-Z0-9_'']*)|(\()([^\s)]+)(\)))\s*(:)'
captures:
1: keyword.other.ocaml
2: entity.name.type.value-signature.ocaml
3: punctuation.separator.type-constraint.ocaml
3: punctuation.section.parens.begin.ocaml
4: entity.name.type.value-signature.ocaml
5: punctuation.section.parens.end.ocaml
6: punctuation.separator.type-constraint.ocaml
push:
- meta_scope: meta.module.signature.val.ocaml
- match: (?=\b(type|val|external|class|module|end)\b)|^\s*$
Expand Down
31 changes: 31 additions & 0 deletions OCaml/syntax_test_ml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,37 @@
(*^^^ keyword.other.ocaml *)
(* ^^^^ variable.other.constant.ocaml *)

(* Module Signatures *)

val foo : 'a -> 'a
(*^^^^^^^^^^^^^^^^^^^^^ meta.module.signature.val.ocaml *)
(*^^^ keyword.other.ocaml *)
(* ^^^ entity.name.type.value-signature.ocaml *)
(* ^ punctuation.separator.type-constraint.ocaml *)
(* ^^ storage.type.ocaml *)
(* ^^ punctuation.separator.function-return.ocaml *)
(* ^^ storage.type.ocaml *)

val (<*<) : 'a -> 'a
(*^^^^^^^^^^^^^^^^^^^^^ meta.module.signature.val.ocaml *)
(*^^^ keyword.other.ocaml *)
(* ^ punctuation.section.parens.begin.ocaml *)
(* ^^^ entity.name.type.value-signature.ocaml *)
(* ^ punctuation.section.parens.end.ocaml *)
(* ^ punctuation.separator.type-constraint.ocaml *)
(* ^^ storage.type.ocaml *)
(* ^^ punctuation.separator.function-return.ocaml *)
(* ^^ storage.type.ocaml *)

val bar : 'a -> 'a
(*^^^^^^^^^^^^^^^^^^^^^ meta.module.signature.val.ocaml *)
(*^^^ keyword.other.ocaml *)
(* ^^^ entity.name.type.value-signature.ocaml *)
(* ^ punctuation.separator.type-constraint.ocaml *)
(* ^^ storage.type.ocaml *)
(* ^^ punctuation.separator.function-return.ocaml *)
(* ^^ storage.type.ocaml *)


(* Integers *)

Expand Down

0 comments on commit 617d7d7

Please sign in to comment.