Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ocaml] Fix infix definitions #3371

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
67 changes: 67 additions & 0 deletions OCaml/syntax_test_ml.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
(* SYNTAX TEST "Packages/OCaml/OCaml.sublime-syntax" *)

(* Function Definitions *)

let foo = function
(* <- meta.function.ocaml keyword.other.function-definition.ocaml *)
(*^^^^^^^ meta.function.ocaml *)
(* ^^^ entity.name.function.ocaml *)
(* ^ keyword.operator.ocaml *)
(* ^^^^^^^^ keyword.control.match-definition.ocaml *)
| [] -> None
(* ^^^^^^^^ meta.pattern-match.ocaml *)
(* ^ keyword.control.match-definition.ocaml *)
(* ^^ constant.language.pseudo-variable.ocaml *)
(* ^^ punctuation.separator.match-definition.ocaml *)
(* ^^^^ entity.name.type.variant.ocaml *)
| _ -> Some 23

let bar = function
(* <- meta.function.ocaml keyword.other.function-definition.ocaml *)
(*^^^^^^^ meta.function.ocaml *)
(* ^^^ entity.name.function.ocaml *)
(* ^ keyword.operator.ocaml *)
(* ^^^^^^^^ keyword.control.match-definition.ocaml *)
| [] -> None
(* ^^^^^^^^ meta.pattern-match.ocaml *)
(* ^ keyword.control.match-definition.ocaml *)
(* ^^ constant.language.pseudo-variable.ocaml *)
(* ^^ punctuation.separator.match-definition.ocaml *)
(* ^^^^ entity.name.type.variant.ocaml *)
| _ -> Some 42
(* ^^^^^^^ meta.pattern-match.ocaml *)
(* ^ keyword.control.match-definition.ocaml *)
(* ^ constant.language.universal-match.ocaml *)
(* ^^ punctuation.separator.match-definition.ocaml *)
(* ^^^^ entity.name.type.variant.ocaml *)
(* ^^ constant.numeric.value.ocaml *)

let open Core.Std
(*^^^ keyword.other.ocaml *)
(* ^^^^ keyword.control.import.ocaml *)
Expand All @@ -25,6 +61,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