comment: This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain the license from this directory, - - - This file is based on the Prolog grammar files for Sublime, by Patrick Schmidt, for TextMate, Michael Sheets at TexMate, and for atom.io, maintained by Jake Prather and colleagues. It also refers to the impressive Logtalk editing support, developed by Paulo Moura and the Logtalk community. I also used the excellent Matt Morrison's Python and Matthew Alexander's Swift language files. Thanks! - - The goals were: * support atom.io, vscode, Sublime, and TextMate * support YAP Prolog files: yap and yss suffixes * improved reading for online documentation * structured editing, so that as much actual Prolog * syntax as possible is available. - The language will support more than what it should. It may also support less than it should. - Implementation: I use Sublime YAML format (property lists). Sublime generates the TM format, from there you cn use atm to convert to atom, and the VScode format. fileTypes: [yap, yss, prolog, pl, pro, P] firstLineMatch: ^(#!/.*\byap|\%.*prolog.*) foldingStartMarker: ^(([a-z]\w*|\'\$\w\')\(|\s*\(|\s*\/\*) foldingStopMarker: (\)|\.|\*\/)\s*$ name: Prolog scopeName: source.prolog uuid: f6546674-e459-11e5-8f80-60f81db5ed04 patterns: - include: '#comments' - begin: ^(:-)\s*(([a-z]\w*:)?([a-z]\w*|\'\$\w*\'))(?=(\(|\s)) # directives are terms of the form ":- directive arguments end: (\.)(\s|$) beginCaptures: '1': {name: keyword.control.directive.begin.prolog} '2': {name: entity.directivesss.prolog} endCaptures: '2': {name: keyword.control.directive.end.prolog} name: meta.directive.prolog patterns: - {include: '#functor'} - {include: '#atom'} - {include: '#variable'} - {include: '#constants'} - match: . - begin: ^\s*(([a-z]\w*)(:))?([a-z]\w*|\'\$\w*\')\( beginCaptures: '0': {name: meta.clause.prolog.head} '2': {name: entity.name.module.clause.prolog} '3': {name: keyword.control.module.prolog} '4': {name: entity.name.predicate.prolog} end: ((\.)(\s|$)) endCaptures: '2': {name: keyword.control.clause.end.prolog} name: meta.clause.prolog patterns: - {include: '#clause_head_arguments'} - {include: '#clause_body'} - begin: ^\s*(([a-z]\w*)(:))?([a-z]\w*|\'\$\w*\')\s* beginCaptures: '0': {name: meta.clause.prolog.head} '2': {name: entity.name.module.clause.prolog} '3': {name: keyword.control.module.prolog} '4': {name: entity.name.predicate.prolog} end: ((\.)(\s|$)) endCaptures: '2': {name: keyword.control.clause.end.prolog} name: meta.clause.prolog patterns: - {include: '#clause_body'} repository: clause_head_arguments: begin: (?<=\() end: (\))\s*(?=(:-|-->|\.)) name: meta.clause.prolog.head patterns: - include: '#args' clause_body: begin: (:-|-->) beginCaptures: '1': {name: keyword.control.clause.neck.prolog} end: (?=((\.)(\s|$))) name: meta.clause.prolog.body patterns: - include: '#conj' - include: '#conj' - include: '#base_call' conj: name: meta.clause.body.conjunction begin: \, beginCaptures: '0': {name: keyword.control.and.prolog} end: (?=(\,|\)|\}|\]|\.)) patterns: - include: '#disj' - include: '#conj' - include: '#base_call' disj: name: meta.clause.disjunction begin: ((\;)|(->)) beginCaptures: '2': {name: keyword.control.or.prolog} '3': { name: keyword.control.if.prolog } end: \s*(?=(\,|\;|\.|\)|\}|\|\.\])) patterns: - include: '#disj' - include: '#base_call' op_infix: match: (same|\^|\*\*|rem|mod|\>\>| \<\<|\/\/|\/|\*|xor|div|rdiv|\#| ><|\\\/|\/\\|\\-|\\+|:|as|>=|=<| >|<|=\\=|=:=|\\=@=|=@=|@>=|@=<|@>|@<| \\==|==|=\.\.|is|\\=|=|->|\;|\,|\||-->|\?-) name: keyword.control.op.infix.prolog op_prefix: match: (spy|nospy|block|\\|\-|\+|not|\\\+|uncutable| table|discontiguous|module_transparent|meta_predicate|multifile| public|mode|volatile|initialization|thread_local| dynamic|\?-|\?-) name: keyword.control.op.prefix.prolog crlbrackets: name: curly.brackets begin: (\{) end: (\}) patterns: - include: '#comments' - match: \s*\,\s* - include: '#term' sqrbrackets: name: sqr.brackets begin: (\[) end: (\]) patterns: - include: '#comments' - match: \s*(\,|\|)\s* - include: '#term' args: name: meta.term.arguments patterns: - include: '#term' - match: \, term: name: meta.term.prolog patterns: - include: '#comments' - include: '#op_infix' - include: '#op_prefix' - {include: '#atom'} - {include: '#variable'} - {include: '#constants'} - include: '#brackets' - include: '#sqrbrackets' - include: '#crlbrackets' - match: \s atom: patterns: - {match: '\[\]', name: constant.other.atom.emptylist.prolog} - {match: '\b[a-z]\w*\b', name: support.atom.simple.prolog} - begin: (?