name: OCaml fileTypes:

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:

foldingStopMarker: (bend(s+in)?[ t]*(;{1,2}|=)?|bdone;?|^s*;;|^s*in)[ t]*$ keyEquivalent: ^~O