%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Logtalk
file_extensions:
  - lgt
  - logtalk
scope: source.logtalk
contexts:
  main:
    - match: /\*
      captures:
        0: punctuation.definition.comment.logtalk
      push:
        - meta_scope: comment.block.logtalk
        - match: \*/
          captures:
            0: punctuation.definition.comment.logtalk
          pop: true
    - match: (%).*$\n?
      scope: comment.line.percentage.logtalk
      captures:
        1: punctuation.definition.comment.logtalk
    - match: '((:-)\s(object|protocol|category|module))(?:\()([^(,)]+)'
      captures:
        1: storage.type.opening.logtalk
        2: punctuation.definition.storage.type.logtalk
        4: entity.name.type.logtalk
    - match: '(:-)\s(end_(object|protocol|category))(?=[.])'
      scope: storage.type.closing.logtalk
      captures:
        1: punctuation.definition.storage.type.logtalk
    - match: '\b(complements|extends|i(nstantiates|mp(orts|lements))|specializes)(?=[(])'
      scope: storage.type.relations.logtalk
    - match: '(:-)\s(e(lse|ndif)|built_in|dynamic|synchronized|threaded)(?=[.])'
      scope: storage.modifier.others.logtalk
      captures:
        1: punctuation.definition.storage.modifier.logtalk
    - match: '(:-)\s(c(alls|oinductive)|e(lif|n(coding|sure_loaded)|xport)|i(f|n(clude|itialization|fo))|reexport|set_(logtalk|prolog)_flag|uses)(?=[(])'
      scope: storage.modifier.others.logtalk
      captures:
        1: punctuation.definition.storage.modifier.logtalk
    - match: '(:-)\s(alias|info|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|ode|ultifile)|p(ublic|r(otected|ivate))|op|use(s|_module)|synchronized)(?=[(])'
      scope: storage.modifier.others.logtalk
      captures:
        1: punctuation.definition.storage.modifier.logtalk
    - match: (:|::|\^\^)
      scope: keyword.operator.message-sending.logtalk
    - match: "([{}])"
      scope: keyword.operator.external-call.logtalk
    - match: (\?|@)
      scope: keyword.operator.mode.logtalk
    - match: (@=<|@<|@>|@>=|==|\\==)
      scope: keyword.operator.comparison.term.logtalk
    - match: (=<|<|>|>=|=:=|=\\=)
      scope: keyword.operator.comparison.arithmetic.logtalk
    - match: (<<|>>|/\\|\\/|\\)
      scope: keyword.operator.bitwise.logtalk
    - match: '\b(e|pi|mod|rem|div)\b(?![-!(^~])'
      scope: keyword.operator.evaluable.logtalk
    - match: (\*\*|\+|-|\*|/|//)
      scope: keyword.operator.evaluable.logtalk
    - match: (:-|!|\\+|,|;|-->|->|=|\=|\.|=\.\.|\^|\bas\b|\bis\b)
      scope: keyword.operator.misc.logtalk
    - match: '\b(a(bs|cos|sin|tan|tan2)|c(eiling|os)|div|exp|flo(at(_(integer|fractional)_part)?|or)|log|m(ax|in|od)|r(em|ound)|s(i(n|gn)|qrt)|t(an|runcate)|xor)(?=[(])'
      scope: support.function.evaluable.logtalk
    - match: '\b(true|fa(il|lse)|repeat|(instantiation|system)_error)\b(?![-!(^~])'
      scope: support.function.control.logtalk
    - match: '\b(ca(ll|tch)|ignore|throw|once)(?=[(])'
      scope: support.function.control.logtalk
    - match: '\b((uninstantiation|type|domain|existence|permission|representation|evaluation|resource|syntax)_error)(?=[(])'
      scope: support.function.control.logtalk
    - match: '\b((get|p(eek|ut))_(c(har|ode)|byte)|nl)(?=[(])'
      scope: support.function.chars-and-bytes-io.logtalk
    - match: \bnl\b
      scope: support.function.chars-and-bytes-io.logtalk
    - match: '\b(atom_(length|c(hars|o(ncat|des)))|sub_atom|char_code|number_c(har|ode)s)(?=[(])'
      scope: support.function.atom-term-processing.logtalk
    - match: '\b(var|atom(ic)?|integer|float|c(allable|ompound)|n(onvar|umber)|ground|acyclic_term)(?=[(])'
      scope: support.function.term-testing.logtalk
    - match: '\b(compare)(?=[(])'
      scope: support.function.term-comparison.logtalk
    - match: '\b(read(_term)?|write(q|_(canonical|term))?|(current_)?(char_conversion|op))(?=[(])'
      scope: support.function.term-io.logtalk
    - match: '\b(arg|copy_term|functor|numbervars|term_variables)(?=[(])'
      scope: support.function.term-creation-and-decomposition.logtalk
    - match: '\b(subsumes_term|unify_with_occurs_check)(?=[(])'
      scope: support.function.term-unification.logtalk
    - match: '\b((se|curren)t_(in|out)put|open|close|flush_output|stream_property|at_end_of_stream|set_stream_position)(?=[(])'
      scope: support.function.stream-selection-and-control.logtalk
    - match: \b(flush_output|at_end_of_stream)\b
      scope: support.function.stream-selection-and-control.logtalk
    - match: '\b((se|curren)t_prolog_flag)(?=[(])'
      scope: support.function.prolog-flags.logtalk
    - match: '\b(logtalk_(compile|l(ibrary_path|oad|oad_context)|make(_target_action)?))(?=[(])'
      scope: support.function.compiling-and-loading.logtalk
    - match: \b(logtalk_make)\b
      scope: support.function.compiling-and-loading.logtalk
    - match: '\b((abolish|define)_events|current_event)(?=[(])'
      scope: support.function.event-handling.logtalk
    - match: '\b((create|current|set)_logtalk_flag|halt)(?=[(])'
      scope: support.function.implementation-defined-hooks.logtalk
    - match: \b(halt)\b
      scope: support.function.implementation-defined-hooks.logtalk
    - match: '\b((key)?(sort))(?=[(])'
      scope: support.function.sorting.logtalk
    - match: '\b((c(reate|urrent)|abolish)_(object|protocol|category))(?=[(])'
      scope: support.function.entity-creation-and-abolishing.logtalk
    - match: '\b((object|protocol|category)_property|co(mplements_object|nforms_to_protocol)|extends_(object|protocol|category)|imp(orts_category|lements_protocol)|(instantiat|specializ)es_class)(?=[(])'
      scope: support.function.reflection.logtalk
    - match: '\b((for|retract)all)(?=[(])'
      scope: support.function.logtalk
    - match: '\b(context|parameter|se(lf|nder)|this)(?=[(])'
      scope: support.function.execution-context.logtalk
    - match: '\b(a(bolish|ssert(a|z))|clause|retract(all)?)(?=[(])'
      scope: support.function.database.logtalk
    - match: '\b((bag|set)of|f(ind|or)all)(?=[(])'
      scope: support.function.all-solutions.logtalk
    - match: '\b(threaded(_(ca(ll|ncel)|once|ignore|exit|peek|wait|notify))?)(?=[(])'
      scope: support.function.multi-threading.logtalk
    - match: '\b(threaded_engine(_(create|destroy|self|next|next_reified|yield|post|fetch))?)(?=[(])'
      scope: support.function.engines.logtalk
    - match: '\b(current_predicate|predicate_property)(?=[(])'
      scope: support.function.reflection.logtalk
    - match: '\b(before|after)(?=[(])'
      scope: support.function.event-handler.logtalk
    - match: '\b(forward)(?=[(])'
      scope: support.function.message-forwarding-handler.logtalk
    - match: '\b(expand_(goal|term)|(goal|term)_expansion|phrase)(?=[(])'
      scope: support.function.grammar-rule.logtalk
    - match: "'"
      captures:
        0: punctuation.definition.string.begin.logtalk
      push:
        - meta_scope: string.quoted.single.logtalk
        - match: "'"
          captures:
            0: punctuation.definition.string.end.logtalk
          pop: true
        - match: '\\([\\abfnrtv"'']|(x[a-fA-F0-9]+|[0-7]+)\\)'
          scope: constant.character.escape.logtalk
    - match: '"'
      captures:
        0: punctuation.definition.string.begin.logtalk
      push:
        - meta_scope: string.quoted.double.logtalk
        - match: '"'
          captures:
            0: punctuation.definition.string.end.logtalk
          pop: true
        - match: \\.
          scope: constant.character.escape.logtalk
    - match: '\b(0b[0-1]+|0o[0-7]+|0x\h+)\b'
      scope: constant.numeric.logtalk
    - match: '\b(0''[\\]?.|0''''|0''")'
      scope: constant.numeric.logtalk
    - match: \b(\d+\.?\d*((e|E)(\+|-)?\d+)?)\b
      scope: constant.numeric.logtalk
    - match: '\b([A-Z_][A-Za-z0-9_]*)\b'
      scope: variable.other.logtalk
