Skip to content

Commit

Permalink
Add Prolog Syntax Highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
laalsaas committed Feb 5, 2024
1 parent 033a859 commit 101078d
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,6 @@
[submodule "assets/syntaxes/02_Extra/vscode-wgsl"]
path = assets/syntaxes/02_Extra/vscode-wgsl
url = https://github.com/PolyMeilex/vscode-wgsl.git
[submodule "assets/syntaxes/02_Extra/Prolog"]
path = assets/syntaxes/02_Extra/Prolog
url = https://github.com/alnkpa/sublimeprolog
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

- `cmd-help`: scope subcommands followed by other terms, and other misc improvements, see #2819 (@victor-gp)
- Upgrade JQ syntax, see #2820 (@dependabot[bot])
- Add Prolog syntax, see #1409

## Themes

Expand Down
1 change: 1 addition & 0 deletions assets/syntaxes/02_Extra/Prolog
Submodule Prolog added at 9e8e14
138 changes: 138 additions & 0 deletions assets/syntaxes/02_Extra/Prolog.sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: SWI-Prolog
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 one at http://mozilla.org/MPL/2.0/.
file_extensions:
- pl
- pro
- prolog
- swiplrc
scope: source.prolog
contexts:
main:
- include: comments
- match: (?<=:-)\s*
push:
- meta_scope: meta.clause.body.prolog
- match: (\.)
captures:
1: keyword.control.clause.bodyend.prolog
pop: true
- include: comments
- include: builtin
- include: controlandkeywords
- include: atom
- include: variable
- include: constants
- match: .
scope: meta.clause.body.prolog
- match: '^\s*([a-z][a-zA-Z0-9_]*)(\(?)(?=.*:-.*)'
captures:
1: entity.name.function.clause.prolog
2: punctuation.definition.parameters.begin
push:
- meta_scope: meta.clause.head.prolog
- match: ((\)?))\s*(:-)
captures:
1: punctuation.definition.parameters.end
3: keyword.control.clause.bodybegin.prolog
pop: true
- include: atom
- include: variable
- include: constants
- match: '^\s*([a-z][a-zA-Z0-9_]*)(\(?)(?=.*-->.*)'
captures:
1: entity.name.function.dcg.prolog
2: punctuation.definition.parameters.begin
push:
- meta_scope: meta.dcg.head.prolog
- match: ((\)?))\s*(-->)
captures:
1: punctuation.definition.parameters.end
3: keyword.control.dcg.bodybegin.prolog
pop: true
- include: atom
- include: variable
- include: constants
- match: (?<=-->)\s*
push:
- meta_scope: meta.dcg.body.prolog
- match: (\.)
captures:
1: keyword.control.dcg.bodyend.prolog
pop: true
- include: comments
- include: controlandkeywords
- include: atom
- include: variable
- include: constants
- match: .
scope: meta.dcg.body.prolog
- match: '^\s*([a-zA-Z][a-zA-Z0-9_]*)(\(?)(?!.*(:-|-->).*)'
captures:
1: entity.name.function.fact.prolog
2: punctuation.definition.parameters.begin
push:
- meta_scope: meta.fact.prolog
- match: ((\)?))\s*(\.)(?!\d+)
captures:
1: punctuation.definition.parameters.end
3: keyword.control.fact.end.prolog
pop: true
- include: atom
- include: variable
- include: constants
atom:
- match: '(?<![a-zA-Z0-9_])[a-z][a-zA-Z0-9_]*(?!\s*\(|[a-zA-Z0-9_])'
scope: constant.other.atom.simple.prolog
- match: "'.*?'"
scope: constant.other.atom.quoted.prolog
- match: '\[\]'
scope: constant.other.atom.emptylist.prolog
builtin:
- match: \b(op|findall|write|nl|writeln|fail|use_module|module)\b
scope: keyword.other
comments:
- match: "%.*"
scope: comment.line.percent-sign.prolog
- match: /\*
captures:
0: punctuation.definition.comment.prolog
push:
- meta_scope: comment.block.prolog
- match: \*/
captures:
0: punctuation.definition.comment.prolog
pop: true
constants:
- match: '(?<![a-zA-Z]|/)(\d+|(\d+\.\d+))'
scope: constant.numeric.integer.prolog
- match: '".*?"'
scope: string.quoted.double.prolog
controlandkeywords:
- match: (->)
captures:
1: keyword.control.if.prolog
push:
- meta_scope: meta.if.prolog
- match: (;)
captures:
1: keyword.control.else.prolog
pop: true
- include: main
- include: builtin
- include: comments
- include: atom
- include: variable
- match: .
scope: meta.if.body.prolog
- match: "!"
scope: keyword.control.cut.prolog
- match: (\s(is)\s)|=:=|=?\\?=|\\\+|@?>|@?=?<|\+|\*|\-
scope: keyword.operator.prolog
variable:
- match: "(?<![a-zA-Z0-9_])[_A-Z][a-zA-Z0-9_]*"
scope: variable.parameter.uppercase.prolog
- match: (?<!\w)_
scope: variable.language.anonymous.prolog
Loading

0 comments on commit 101078d

Please sign in to comment.