name: OCaml fileTypes:
-
ml
-
mli
scopeName: source.ocaml repository:
moduleref: patterns: - name: meta.module-reference.ocaml beginCaptures: "1": name: support.other.module.ocaml "2": name: punctuation.separator.module-reference.ocaml match: \b([A-Z][a-zA-Z0-9'_]*)(\.) variables: patterns: - name: variable.parameter.unit.ocaml match: \(\) - include: "#constants" - include: "#moduleref" - name: variable.parameter.labeled.ocaml begin: (~)([a-z][a-zA-Z0-9'_]*)(\s*:\s*)? beginCaptures: "1": name: punctuation.definition.labeled-parameter.ocaml "2": name: entity.name.tag.label.ocaml "3": name: punctuation.separator.label.ocaml end: \s patterns: - include: "#variables" - name: variable.parameter.optional.ocaml captures: "1": name: punctuation.definition.optional-parameter.ocaml "2": name: entity.name.tag.label.optional.ocaml match: (\?)([a-z][a-zA-Z0-9_]*) - name: variable.parameter.optional.ocaml endCaptures: "1": name: punctuation.definition.optional-parameter.ocaml begin: (\?)(\()([a-z_][a-zA-Z0-9'_]*)\s*(=) beginCaptures: "1": name: punctuation.definition.optional-parameter.ocaml "2": name: punctuation.definition.optional-parameter.ocaml "3": name: entity.name.tag.label.optional.ocaml "4": name: punctuation.separator.optional-parameter-assignment.ocaml end: (\)) patterns: - include: $self - name: meta.parameter.type-constrained.ocaml endCaptures: "1": name: punctuation.section.type-constraint.ocaml begin: (\()(?=(~[a-z][a-zA-Z0-9_]*:|("(\\"|[^"])*")|[^\(\)~"])+(?<!:)(:>|:(?![:=]))) beginCaptures: "1": name: punctuation.section.type-constraint.ocaml end: (\)) patterns: - name: storage.type.ocaml begin: (?<!:)(:>|:(?![:=])) beginCaptures: "1": name: punctuation.separator.type-constraint.ocaml end: (?=\)) patterns: - name: meta.paren.group begin: \( end: \) - include: "#variables" - include: "#comments" - name: meta.paren-group.ocaml begin: \( end: \) patterns: - include: "#variables" - name: variable.parameter.tuple.ocaml endCaptures: "1": name: punctuation.definition.tuple.ocaml begin: (\() beginCaptures: "1": name: punctuation.definition.tuple.ocaml end: (\)) patterns: - include: "#matchpatterns" - include: "#variables" - name: punctuation.separator.tuple.ocaml match: "," - name: variable.parameter.record.ocaml endCaptures: "1": name: punctuation.definition.record.ocaml begin: (\{) beginCaptures: "1": name: punctuation.definition.record.ocaml end: (\}) patterns: - include: "#moduleref" - name: meta.recordfield.match.ocaml endCaptures: "1": name: punctuation.separator.record.ocaml begin: \b([a-z][a-zA-Z0-9'_]*)\s*(=) beginCaptures: "1": name: entity.name.tag.record.ocaml "2": name: punctuation.separator.record.field-assignment.ocaml end: (;)|(?=\}) patterns: - include: "#matchpatterns" - include: "#storagetypes" - name: variable.parameter.ocaml match: \b[a-z_][a-zA-Z0-9'_]* typedefs: patterns: - name: punctuation.separator.variant-definition.ocaml match: \| - include: "#comments" - name: meta.paren-group.ocaml begin: \( end: \) patterns: - include: "#typedefs" - name: keyword.other.ocaml match: \bof\b - include: "#storagetypes" - name: storage.type.ocaml match: (?<=\s|\()['a-z_][a-zA-Z0-9_]*\b - name: meta.module.type.ocaml captures: "1": name: support.other.module.ocaml "2": name: storage.type.module.ocaml match: \b((?:[A-Z][a-zA-Z0-9'_]*)(?:\.[A-Z][a-zA-Z0-9'_]+)*)(\.[a-zA-Z0-9'_]+) - name: meta.polymorphic-variant.definition.ocaml endCaptures: "1": name: punctuation.definition.polymorphic-variant.ocaml begin: (\[(>|<)?) beginCaptures: "1": name: punctuation.definition.polymorphic-variant.ocaml end: (\]) patterns: - include: "#typedefs" - include: $self - name: punctuation.separator.algebraic-type.ocaml match: \| storagetypes: patterns: - name: storage.type.ocaml match: \b(int|char|float|string|list|array|bool|unit|exn|option|int32|int64|nativeint|format4|lazy_t)\b - name: storage.type.variant.polymorphic.ocaml match: "#[a-z_][a-zA-Z0-9_]*" module-signature: patterns: - name: meta.module.signature.val.ocaml begin: (val)\s+([a-z_][a-zA-Z0-9_']*)\s*(:) beginCaptures: "1": name: keyword.other.ocaml "2": name: entity.name.type.value-signature.ocaml "3": name: punctuation.separator.type-constraint.ocaml end: (?=\b(type|val|external|class|module|end)\b)|^\s*$ patterns: - name: variable.parameter.optional.ocaml captures: "1": name: punctuation.definition.optional-parameter.ocaml "2": name: entity.name.tag.label.optional.ocaml "3": name: punctuation.separator.optional-parameter.ocaml match: (\?)([a-z][a-zA-Z0-9_]*)\s*(:) - name: variable.parameter.labeled.ocaml begin: (~)([a-z][a-zA-Z0-9'_]*)\s*(:)\s* beginCaptures: "1": name: punctuation.definition.labeled-parameter.ocaml "2": name: entity.name.tag.label.ocaml "3": name: punctuation.separator.label.ocaml end: \s patterns: - include: "#variables" - include: "#typedefs" - name: meta.module.signature.external.ocaml begin: (external)\s+([a-z_][a-zA-Z0-9_']*)\s*(:) beginCaptures: "1": name: keyword.other.ocaml "2": name: entity.name.type.external-signature.ocaml "3": name: punctuation.separator.type-constraint.ocaml end: (?=\b(type|val|external|class|module|end)\b)|^\s*$ patterns: - name: variable.parameter.optional.ocaml captures: "1": name: punctuation.definition.optional-parameter.ocaml "2": name: entity.name.tag.label.optional.ocaml "3": name: punctuation.separator.optional-parameter.ocaml match: (\?)([a-z][a-zA-Z0-9_]*)\s*(:) - name: variable.parameter.labeled.ocaml begin: (~)([a-z][a-zA-Z0-9'_]*)\s*(:)\s* beginCaptures: "1": name: punctuation.definition.labeled-parameter.ocaml "2": name: entity.name.tag.label.ocaml "3": name: punctuation.separator.label.ocaml end: \s patterns: - include: "#variables" - include: "#strings" - include: "#typedefs" matchpatterns: patterns: - name: constant.language.universal-match.ocaml match: \b_\b - name: punctuation.separator.match-pattern.ocaml match: \|(?=\s*\S) - name: meta.match-option.ocaml endCaptures: "1": name: punctuation.definition.match-option.ocaml begin: (\()(?=(?!=.*?->).*?\|) beginCaptures: "1": name: punctuation.definition.match-option.ocaml end: (\)) patterns: - name: punctuation.separator.match-option.ocaml match: \| - include: "#matchpatterns" - include: "#moduleref" - include: "#constants" - include: "#variables" - include: $self comments: patterns: - name: comment.block.ocaml captures: "1": name: comment.block.empty.ocaml match: \(\*\*?(\*)\) - name: comment.block.ocaml begin: \(\* end: \*\) patterns: - include: "#comments" - name: comment.block.ocamlyacc begin: /\* end: \*/ patterns: - include: "#comments" - name: comment.block.string.quoted.double.ocaml begin: (?=[^\\])(") end: "\"" patterns: - name: comment.block.string.constant.character.escape.ocaml match: \\(x[a-fA-F0-9][a-fA-F0-9]|[0-2]\d\d|[bnrt'"\\]) lists: patterns: - name: meta.list.ocaml endCaptures: "1": name: punctuation.definition.list.end.ocaml begin: (\[)(?!\||<|>) beginCaptures: "1": name: punctuation.definition.list.begin.ocaml end: (?<!\||>)(]) patterns: - include: "#lists" - include: $self strings: patterns: - name: string.quoted.double.ocaml endCaptures: "1": name: punctuation.definition.string.end.ocaml begin: (?=[^\\])(") beginCaptures: "1": name: punctuation.definition.string.begin.ocaml end: (") patterns: - name: punctuation.separator.string.ignore-eol.ocaml match: \\$[ \t]* - name: constant.character.string.escape.ocaml match: \\(x[a-fA-F0-9][a-fA-F0-9]|[0-2]\d\d|[bnrt'"\\]) - name: constant.character.regexp.escape.ocaml match: \\[\|\(\)1-9$^.*+?\[\]] - name: invalid.illegal.character.string.escape match: \\(?!(x[a-fA-F0-9][a-fA-F0-9]|[0-2]\d\d|[bnrt'"\\]|[\|\(\)1-9$^.*+?\[\]]|$[ \t]*))(?:.) constants: patterns: - name: constant.language.pseudo-variable.ocaml captures: "1": name: meta.empty-typing-pair.ocaml "2": name: meta.empty-typing-pair.parens.ocaml "3": name: meta.empty-typing-pair.ocaml match: (?:\[\s*(\])|\((\))|\(\s*(\))) - name: constant.language.boolean.ocaml match: \b(true|false)\b - name: constant.numeric.floating-point.ocaml match: \b-?[0-9][0-9_]*((\.([0-9][0-9_]*([eE][+-]??[0-9][0-9_]*)?)?)|([eE][+-]??[0-9][0-9_]*)) - name: constant.numeric.integer.nativeint.ocaml match: \b(-?((0(x|X)[0-9a-fA-F][0-9a-fA-F_]*)|(0(o|O)[0-7][0-7_]*)|(0(b|B)[01][01_]*)|([0-9][0-9_]*)))n - name: constant.numeric.integer.int64.ocaml match: \b(-?((0(x|X)[0-9a-fA-F][0-9a-fA-F_]*)|(0(o|O)[0-7][0-7_]*)|(0(b|B)[01][01_]*)|([0-9][0-9_]*)))L - name: constant.numeric.integer.int32.ocaml match: \b(-?((0(x|X)[0-9a-fA-F][0-9a-fA-F_]*)|(0(o|O)[0-7][0-7_]*)|(0(b|B)[01][01_]*)|([0-9][0-9_]*)))l - name: constant.numeric.integer.ocaml match: \b(-?((0(x|X)[0-9a-fA-F][0-9a-fA-F_]*)|(0(o|O)[0-7][0-7_]*)|(0(b|B)[01][01_]*)|([0-9][0-9_]*))) - name: constant.character.ocaml match: "'(.|\\\\(x[a-fA-F0-9][a-fA-F0-9]|[0-2]\\d\\d|[bnrt'\"\\\\]))'" arrays: patterns: - name: meta.array.ocaml endCaptures: "1": name: punctuation.definition.array.end.ocaml begin: (\[\|) beginCaptures: "1": name: punctuation.definition.array.begin.ocaml end: (\|]) patterns: - include: "#arrays" - include: $self
uuid: F816FA69-6EE8-11D9-BF2D-000D93589AF6 foldingStartMarker: (b(module|class|)s.*?=s*$|bbegin|sig|struct|(object(s*(_?[a-z]+))?)s*$|bwhiles.*?bdos*$|^let(?:s+rec)?s+[a-z_][a-zA-Z0-9_]*s+(?!=)S) patterns:
-
name: meta.module.binding captures:
"1": name: keyword.other.module-binding.ocaml "2": name: keyword.other.module-definition.ocaml "3": name: support.other.module.ocaml "4": name: punctuation.separator.module-binding.ocmal
match: b(let)s+(module)s+([A-Z][a-zA-Z0-9'_]*)s*(=)
-
name: meta.function.ocaml endCaptures:
"1": name: punctuation.separator.function.type-constraint.ocaml "2": name: storage.type.ocaml "3": name: keyword.operator.ocaml "4": name: keyword.operator.ocaml
begin: b(let|and)s+(?!(*)((recs+)([a-z_][a-zA-Z0-9_’]*)b|([a-zA-Z0-9_’]*|(+))(?=s)((?=s*=s*(?=fun(?:ction)b))|(?!s*=))) beginCaptures:
"1": name: keyword.other.function-definition.ocaml "3": name: keyword.other.funtion-definition.ocaml "4": name: entity.name.function.ocaml "5": name: entity.name.function.ocaml
end: (?:(:)s*([^=]+))?(?:(=)|(=)s*(?=fun(?:ction)b)) patterns:
-
include: “#variables”
-
-
name: meta.function.anonymous.ocaml endCaptures:
"1": name: punctuation.definition.function.anonymous.ocaml
begin: (()(?=funs) beginCaptures:
"1": name: punctuation.definition.function.anonymous.ocaml
end: ()) patterns:
-
name: meta.function.anonymous.definition.ocaml endCaptures:
"1": name: punctuation.separator.function-definition.ocaml
begin: (?<=()(fun)s beginCaptures:
"1": name: keyword.other.function-definition.ocaml
end: (->) patterns:
-
include: “#variables”
-
-
include: $self
-
-
name: meta.type-definition-group.ocaml begin: ^s*(?=types) end: b(?=let|end)|^s*$ patterns:
-
name: meta.type-definition.ocaml begin: b(type|and)s+([^=]*)(=)? beginCaptures:
"1": name: keyword.other.type-definition.ocaml "2": name: storage.type.user-defined.ocaml "3": name: punctuation.separator.type-definition.ocaml
end: (?=b(type|and|let|end)b)|(?=^s*$) patterns:
-
include: “#typedefs”
-
-
-
name: meta.pattern-match.ocaml endCaptures:
"1": name: punctuation.separator.match-definition.ocaml "2": name: keyword.control.match-condition.ocaml
begin: b(with|function)(?=(s*$|.*->))b|((?<!|)(|)(?!|)(?=.*->)) beginCaptures:
"1": name: keyword.control.match-definition.ocaml "2": name: keyword.other.function-definition.ocaml "3": name: keyword.control.match-definition.ocaml
end: (?:(->)|b(when)b|s(?=|)) patterns:
-
include: “#matchpatterns”
-
-
name: meta.class.type-definition.ocaml captures:
"1": name: keyword.other.class-type-definition.ocaml "2": name: entity.name.type.class-type.ocaml "4": name: storage.type.user-defined.ocaml
match: ^[ t]*(classs+types+)(([s*(‘[A-Za-z][a-zA-Z0-9_’]*(?:s*,s*‘[a-zA-Z0-9_’]*)*)s*]s+)?[a-zA-Z0-9'_]*)
-
name: meta.class.ocaml endCaptures:
"1": name: keyword.operator.ocaml
begin: ^[ t]*(class)(?:s+(?!(?:virtual)s+))(([s*(‘[A-Za-z][a-zA-Z0-9_’]*(?:s*,s*‘[a-zA-Z0-9_’]*)*)s*]s+)?[a-zA-Z0-9'_]*) beginCaptures:
"1": name: keyword.other.class-definition.ocaml "2": name: entity.name.type.class.ocaml "4": name: storage.type.user-defined.ocaml
end: (=) patterns:
-
include: “#variables”
-
-
name: meta.class.virtual.ocaml endCaptures:
"1": name: keyword.operator.ocaml
begin: ^[ t]*(classs+virtuals+)(([s*(‘[A-Za-z][a-zA-Z0-9_’]*(?:s*,s*‘[a-zA-Z0-9_’]*)*)s*]s+)?[a-zA-Z0-9'_]*) beginCaptures:
"1": name: keyword.other.class-definition.ocaml "2": name: entity.name.type.class.ocaml "4": name: storage.type.user-defined.ocaml
end: (=) patterns:
-
include: “#variables”
-
-
name: meta.class.virtual.type-definition.ocaml captures:
"1": name: keyword.other.class-type-definition.ocaml "2": name: entity.name.type.class-type.ocaml "4": name: storage.type.user-defined.ocaml
match: ^[ t]*(classs+types+virtual)(([s*(‘[A-Za-z][a-zA-Z0-9_’]*(?:s*,s*‘[a-zA-Z0-9_’]*)*)s*]s+)?[a-zA-Z0-9'_]*)
-
name: meta.record.ocaml endCaptures:
"1": name: punctuation.definition.record.ocaml
begin: ({) beginCaptures:
"1": name: punctuation.definition.record.ocaml
end: (}) patterns:
-
name: keyword.other.language.ocaml match: bwithb
-
name: meta.record.definition.ocaml endCaptures:
"1": name: keyword.operator.ocaml
begin: (bmutables+)?b([a-z_][a-zA-Z0-9_']*)s*(:) beginCaptures:
"1": name: keyword.other.storage.modifier.ocaml "2": name: source.ocaml "3": name: punctuation.definition.record.ocaml
end: (;|(?=})) patterns:
-
include: “#typedefs”
-
-
include: $self
-
-
name: meta.object.ocaml endCaptures:
"1": name: keyword.control.object.ocaml "2": name: punctuation.terminator.expression.ocaml
begin: b(object)s*(?:(()(_?[a-z]+)()))?s*$ beginCaptures:
"1": name: keyword.other.object-definition.ocaml "2": name: punctuation.definition.self-binding.ocaml "3": name: entity.name.type.self-binding.ocaml "4": name: punctuation.definition.self-binding.ocaml
end: b(end)b patterns:
-
name: meta.method.ocaml endCaptures:
"1": name: keyword.operator.ocaml
begin: b(method)s+(virtuals+)?(privates+)?([a-z_][a-zA-Z0-9'_]*) beginCaptures:
"1": name: keyword.other.method-definition.ocaml "2": name: keyword.other.method-definition.ocaml "3": name: keyword.other.method-restriction.ocaml "4": name: entity.name.function.method.ocaml
end: (=|:) patterns:
-
include: “#variables”
-
-
name: meta.object.type-constraint.ocaml endCaptures:
"1": name: storage.type.polymorphic-variant.ocaml "2": name: storage.type.ocaml "3": name: storage.type.user-defined.ocaml
begin: (constraint)s+([a-zA-Z0-9'_]*)s+(=) beginCaptures:
"1": name: keyword.other.language.ocaml "2": name: storage.type.user-defined.ocaml "3": name: keyword.operator.ocaml
end: (#[a-z_]*)|(int|char|float|string|list|array|bool|unit|exn|option|int32|int64|nativeint|format4|lazy_t)|([a-zA-Z0-9'_]*)s*$
-
include: $self
-
-
name: meta.method-call.ocaml captures:
"1": name: punctuation.separator.method-call.ocaml
match: (?<=w|)|‘)(#)[a-zA-Z0-9'_]*
-
name: meta.module.ocaml captures:
"1": name: keyword.other.module-definition.ocaml "2": name: entity.name.type.module.ocaml "3": name: punctuation.separator.module-definition.ocaml "4": name: entity.name.type.module-type.ocaml
match: ^[ t]*(module)s+([A-Z_][a-zA-Z0-9’_]*)(?:s*(:)s*([a-zA-Z0-9'_]*)?)?
-
name: meta.module.type.ocaml captures:
"1": name: keyword.other.module-type-definition.ocaml "2": name: entity.name.type.module-type.ocaml
match: ^[ t]*(modules+types+)([A-Z][a-zA-Z0-9'_]*)
-
name: meta.module.signature.ocaml endCaptures:
"1": name: keyword.other.module.signature.ocaml "2": name: punctuation.terminator.expression.ocaml "3": name: keyword.operator.ocaml
begin: b(sig)b beginCaptures:
"1": name: keyword.other.module.signature.ocaml
end: b(end)b patterns:
-
include: “#module-signature”
-
include: $self
-
-
name: meta.module.structure.ocaml endCaptures:
"1": name: keyword.other.module.structure.ocaml
begin: b(struct)b beginCaptures:
"1": name: keyword.other.module.structure.ocaml
end: b(end)b patterns:
-
include: $self
-
-
include: “#moduleref”
-
name: meta.module.open.ocaml begin: b(open)s+([A-Z][a-zA-Z0-9’_]*)(?=(.[a-zA-Z0-9_]*)*) beginCaptures:
"1": name: keyword.other.ocaml "2": name: support.other.module.ocaml
end: (s|$) patterns:
-
name: support.other.module.ocaml captures:
"1": name: punctuation.separator.module-reference.ocaml
match: (.)([A-Z]*)
-
-
name: meta.exception.ocaml captures:
"1": name: keyword.other.ocaml "2": name: entity.name.type.exception.ocaml
match: b(exception)s+([A-Z][a-zA-Z0-9'_]*)b
-
name: source.camlp4.embedded.ocaml endCaptures:
"1": name: punctuation.definition.camlp4-stream.ocaml
begin: (?=([<)(?![^[]+?[^>]])) end: (>]) patterns:
-
include: source.camlp4.ocaml
-
-
include: “#strings”
-
include: “#constants”
-
include: “#comments”
-
include: “#lists”
-
include: “#arrays”
-
name: meta.type-constraint.ocaml endCaptures:
"1": name: punctuation.separator.type-constraint.ocaml "2": name: storage.type.ocaml "3": name: punctuation.section.type-constraint.ocaml
begin: (()(?=(~[a-z]*:|(“(\”|[^“])*”)|[^()~“])+(?<!:)(:>|:(?![:=]))) beginCaptures:
"1": name: punctuation.section.type-constraint.ocaml
end: (?<!:)(:>|:(?![:=]))(.*?)()) patterns:
-
include: $self
-
-
name: keyword.other.directive.ocaml match: ^[ t]*#[a-zA-Z]+
-
name: keyword.other.directive.line-number.ocaml match: ^[ t]#[0-9]
-
include: “#storagetypes”
-
name: keyword.other.storage.modifier.ocaml match: b(mutable|ref)b
-
name: entity.name.type.variant.polymorphic.ocaml match: “`[A-Za-z]*\b”
-
name: entity.name.type.variant.ocaml match: b[A-Z][a-zA-Z0-9'_]*b
-
name: keyword.operator.symbol.ocaml match: “!=|:=|>|<”
-
name: keyword.operator.infix.floating-point.ocaml match: “[*+/-]\.”
-
name: keyword.operator.prefix.floating-point.ocaml match: ~-.
-
name: punctuation.definition.list.constructor.ocaml match: “::”
-
name: punctuation.terminator.expression.ocaml match: ;;
-
name: punctuation.separator.ocaml match: ;
-
name: punctuation.separator.function-return.ocaml match: ->
-
name: keyword.operator.infix.ocaml match: “[=<>@^&+\-*/$%|][|!$%&*+./:<=>?@^~-]*”
-
name: keyword.operator.prefix.ocaml match: bnotb|!|[!?~][!$%&*+./:<=>?@^~-]+
-
name: entity.name.tag.label.ocaml captures:
"1": name: punctuation.separator.argument-label.ocaml
match: ~[a-z]*(:)?
-
name: meta.begin-end-group.ocaml endCaptures:
"1": name: keyword.control.begin-end.ocaml
begin: b(begin)b beginCaptures:
"1": name: keyword.control.begin-end.ocaml
end: b(end)b patterns:
-
include: $self
-
-
name: meta.for-loop.ocaml endCaptures:
"1": name: keyword.control.for-loop.ocaml
begin: b(for)b beginCaptures:
"1": name: keyword.control.for-loop.ocaml
end: b(done)b patterns:
-
name: keyword.control.loop.ocaml match: bdob
-
include: $self
-
-
name: meta.while-loop.ocaml endCaptures:
"1": name: keyword.control.while-loop.ocaml
begin: b(while)b beginCaptures:
"1": name: keyword.control.while-loop.ocaml
end: b(done)b patterns:
-
name: keyword.control.loop.ocaml match: bdob
-
include: $self
-
-
name: meta.paren-group.ocaml begin: ( end: ) patterns:
-
include: $self
-
-
name: keyword.operator.ocaml match: b(and|land|lor|lsl|lsr|lxor|mod|or)b
-
name: keyword.control.ocaml match: b(downto|if|else|match|then|to|when|with|try)b
-
name: keyword.other.ocaml match: b(as|assert|class|constraint|exception|functor|in|include|inherit|initializer|lazy|let|mod|module|mutable|new|object|open|private|rec|sig|struct|type|val|virtual)b
-
include: “#module-signature”
-
name: invalid.illegal.unrecognized-character.ocaml match: “(xE2x80x99|xE2x80x98|xE2x80x9C|xE2x80x9D)”
foldingStopMarker: (bend(s+in)?[ t]*(;{1,2}|=)?|bdone;?|^s*;;|^s*in)[ t]*$ keyEquivalent: ^~O