2022-11-08 02:06:49 +08:00
|
|
|
"""
|
|
|
|
pygments.lexers.cplint
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Lexer for the cplint language
|
2024-03-04 01:15:23 +08:00
|
|
|
|
|
|
|
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
|
2022-11-08 02:06:49 +08:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from pygments.lexer import bygroups, inherit, words
|
|
|
|
from pygments.lexers import PrologLexer
|
2024-03-04 01:15:23 +08:00
|
|
|
from pygments.token import Operator, Keyword, Name, String, Punctuation
|
2022-11-08 02:06:49 +08:00
|
|
|
|
|
|
|
__all__ = ['CplintLexer']
|
|
|
|
|
|
|
|
|
|
|
|
class CplintLexer(PrologLexer):
|
|
|
|
"""
|
2024-03-04 01:15:23 +08:00
|
|
|
Lexer for cplint files, including CP-logic, Logic Programs with Annotated
|
|
|
|
Disjunctions, Distributional Clauses syntax, ProbLog, DTProbLog.
|
2022-11-08 02:06:49 +08:00
|
|
|
|
|
|
|
.. versionadded:: 2.12
|
|
|
|
"""
|
|
|
|
name = 'cplint'
|
|
|
|
url = 'https://cplint.eu'
|
|
|
|
aliases = ['cplint']
|
|
|
|
filenames = ['*.ecl', '*.prolog', '*.pro', '*.pl', '*.P', '*.lpad', '*.cpl']
|
|
|
|
mimetypes = ['text/x-cplint']
|
|
|
|
|
|
|
|
tokens = {
|
|
|
|
'root': [
|
2024-03-04 01:15:23 +08:00
|
|
|
(r'map_query', Keyword),
|
|
|
|
(words(('gaussian', 'uniform_dens', 'dirichlet', 'gamma', 'beta',
|
|
|
|
'poisson', 'binomial', 'geometric', 'exponential', 'pascal',
|
|
|
|
'multinomial', 'user', 'val', 'uniform', 'discrete',
|
|
|
|
'finite')), Name.Builtin),
|
|
|
|
# annotations of atoms
|
|
|
|
(r'([a-z]+)(:)', bygroups(String.Atom, Punctuation)),
|
2022-11-08 02:06:49 +08:00
|
|
|
(r':(-|=)|::?|~=?|=>', Operator),
|
|
|
|
(r'\?', Name.Builtin),
|
|
|
|
inherit,
|
|
|
|
],
|
|
|
|
}
|