cplint.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """
  2. pygments.lexers.cplint
  3. ~~~~~~~~~~~~~~~~~~~~~~
  4. Lexer for the cplint language
  5. :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
  6. :license: BSD, see LICENSE for details.
  7. """
  8. from pygments.lexer import bygroups, inherit, words
  9. from pygments.lexers import PrologLexer
  10. from pygments.token import Operator, Keyword, Name, String, Punctuation
  11. __all__ = ['CplintLexer']
  12. class CplintLexer(PrologLexer):
  13. """
  14. Lexer for cplint files, including CP-logic, Logic Programs with Annotated
  15. Disjunctions, Distributional Clauses syntax, ProbLog, DTProbLog.
  16. .. versionadded:: 2.12
  17. """
  18. name = 'cplint'
  19. url = 'https://cplint.eu'
  20. aliases = ['cplint']
  21. filenames = ['*.ecl', '*.prolog', '*.pro', '*.pl', '*.P', '*.lpad', '*.cpl']
  22. mimetypes = ['text/x-cplint']
  23. tokens = {
  24. 'root': [
  25. (r'map_query', Keyword),
  26. (words(('gaussian', 'uniform_dens', 'dirichlet', 'gamma', 'beta',
  27. 'poisson', 'binomial', 'geometric', 'exponential', 'pascal',
  28. 'multinomial', 'user', 'val', 'uniform', 'discrete',
  29. 'finite')), Name.Builtin),
  30. # annotations of atoms
  31. (r'([a-z]+)(:)', bygroups(String.Atom, Punctuation)),
  32. (r':(-|=)|::?|~=?|=>', Operator),
  33. (r'\?', Name.Builtin),
  34. inherit,
  35. ],
  36. }