You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Prolog.sublime-syntax 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. %YAML 1.2
  2. ---
  3. # http://www.sublimetext.com/docs/3/syntax.html
  4. name: SWI-Prolog
  5. 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/.
  6. file_extensions:
  7. - pro
  8. scope: source.prolog
  9. contexts:
  10. main:
  11. - include: comments
  12. - match: (?<=:-)\s*
  13. push:
  14. - meta_scope: meta.clause.body.prolog
  15. - match: (\.)
  16. captures:
  17. 1: keyword.control.clause.bodyend.prolog
  18. pop: true
  19. - include: comments
  20. - include: builtin
  21. - include: controlandkeywords
  22. - include: atom
  23. - include: variable
  24. - include: constants
  25. - match: .
  26. scope: meta.clause.body.prolog
  27. - match: '^\s*([a-z][a-zA-Z0-9_]*)(\(?)(?=.*:-.*)'
  28. captures:
  29. 1: entity.name.function.clause.prolog
  30. 2: punctuation.definition.parameters.begin
  31. push:
  32. - meta_scope: meta.clause.head.prolog
  33. - match: ((\)?))\s*(:-)
  34. captures:
  35. 1: punctuation.definition.parameters.end
  36. 3: keyword.control.clause.bodybegin.prolog
  37. pop: true
  38. - include: atom
  39. - include: variable
  40. - include: constants
  41. - match: '^\s*([a-z][a-zA-Z0-9_]*)(\(?)(?=.*-->.*)'
  42. captures:
  43. 1: entity.name.function.dcg.prolog
  44. 2: punctuation.definition.parameters.begin
  45. push:
  46. - meta_scope: meta.dcg.head.prolog
  47. - match: ((\)?))\s*(-->)
  48. captures:
  49. 1: punctuation.definition.parameters.end
  50. 3: keyword.control.dcg.bodybegin.prolog
  51. pop: true
  52. - include: atom
  53. - include: variable
  54. - include: constants
  55. - match: (?<=-->)\s*
  56. push:
  57. - meta_scope: meta.dcg.body.prolog
  58. - match: (\.)
  59. captures:
  60. 1: keyword.control.dcg.bodyend.prolog
  61. pop: true
  62. - include: comments
  63. - include: controlandkeywords
  64. - include: atom
  65. - include: variable
  66. - include: constants
  67. - match: .
  68. scope: meta.dcg.body.prolog
  69. - match: '^\s*([a-zA-Z][a-zA-Z0-9_]*)(\(?)(?!.*(:-|-->).*)'
  70. captures:
  71. 1: entity.name.function.fact.prolog
  72. 2: punctuation.definition.parameters.begin
  73. push:
  74. - meta_scope: meta.fact.prolog
  75. - match: ((\)?))\s*(\.)(?!\d+)
  76. captures:
  77. 1: punctuation.definition.parameters.end
  78. 3: keyword.control.fact.end.prolog
  79. pop: true
  80. - include: atom
  81. - include: variable
  82. - include: constants
  83. atom:
  84. - match: '(?<![a-zA-Z0-9_])[a-z][a-zA-Z0-9_]*(?!\s*\(|[a-zA-Z0-9_])'
  85. scope: constant.other.atom.simple.prolog
  86. - match: "'.*?'"
  87. scope: constant.other.atom.quoted.prolog
  88. - match: '\[\]'
  89. scope: constant.other.atom.emptylist.prolog
  90. builtin:
  91. - match: \b(op|findall|write|nl|writeln|fail|use_module|module)\b
  92. scope: keyword.other
  93. comments:
  94. - match: "%.*"
  95. scope: comment.line.percent-sign.prolog
  96. - match: /\*
  97. captures:
  98. 0: punctuation.definition.comment.prolog
  99. push:
  100. - meta_scope: comment.block.prolog
  101. - match: \*/
  102. captures:
  103. 0: punctuation.definition.comment.prolog
  104. pop: true
  105. constants:
  106. - match: '(?<![a-zA-Z]|/)(\d+|(\d+\.\d+))'
  107. scope: constant.numeric.integer.prolog
  108. - match: '".*?"'
  109. scope: string.quoted.double.prolog
  110. controlandkeywords:
  111. - match: (->)
  112. captures:
  113. 1: keyword.control.if.prolog
  114. push:
  115. - meta_scope: meta.if.prolog
  116. - match: (;)
  117. captures:
  118. 1: keyword.control.else.prolog
  119. pop: true
  120. - include: main
  121. - include: builtin
  122. - include: comments
  123. - include: atom
  124. - include: variable
  125. - match: .
  126. scope: meta.if.body.prolog
  127. - match: "!"
  128. scope: keyword.control.cut.prolog
  129. - match: (\s(is)\s)|=:=|=?\\?=|\\\+|@?>|@?=?<|\+|\*|\-
  130. scope: keyword.operator.prolog
  131. variable:
  132. - match: "(?<![a-zA-Z0-9_])[A-Z][a-zA-Z0-9_]*"
  133. scope: variable.parameter.uppercase.prolog
  134. - match: (?<!\w)_
  135. scope: variable.language.anonymous.prolog