<commit_before># -*- coding: utf-8 -*-
"""
    pygments.lexers.modeling
    ~~~~~~~~~~~~~~~~~~~~~~~~

    Lexers for modeling languages.

    :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

import re

from pygments.lexer import RegexLexer, include, bygroups, using
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
    Number, Punctuation

from pygments.lexers.html import HtmlLexer
from pygments.lexers import _stan_builtins

__all__ = ['ModelicaLexer', 'BugsLexer', 'JagsLexer', 'StanLexer']


class ModelicaLexer(RegexLexer):
    """
    For `Modelica <http://www.modelica.org/>`_ source code.

    .. versionadded:: 1.1
    """
    name = 'Modelica'
    aliases = ['modelica']
    filenames = ['*.mo']
    mimetypes = ['text/x-modelica']

    flags = re.IGNORECASE | re.DOTALL

    tokens = {
        'whitespace': [
            (r'\n', Text),
            (r'\s+', Text),
            (r'\\\n', Text), # line continuation
            (r'//(\n|(.|\n)*?[^\\]\n)', Comment),
            (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment),
        ],
        'statements': [
            (r'"', String, 'string'),
            (r'(\d+\.\d*|\.\d+|\d+|\d.)[eE][+-]?\d+[lL]?', Number.Float),
            (r'(\d+\.\d*|\.\d+)', Number.Float),
            (r'\d+[Ll]?', Number.Integer),
            (r'[~!%^&*+=|?:<>/-]', Operator),
            (r'(true|false|NULL|Real|Integer|Boolean)\b', Name.Builtin),
            (r'([a-z_][\w]*|\'[^\']+\')'
             r'([\[\d,:\]]*)'
             r'(\.([a-z_][\w]*|\'[^\']+\'))+'
             r'([\[\d,:\]]*)', Name.Class),
            (r'(\'[\w\+\-\*\/\^]+\'|\w+)', Name),
            (r'[()\[\]{},.;]', Punctuation),
            (r'\'', Name, 'quoted_ident'),
        ],
        'root': [
            include('whitespace'),
            include('classes'),
            include('functions'),
            include('keywords'),
            include('operators'),
            (r'("<html>|<html>)', Name.Tag, 'html-content'),
            include('statements'),
        ],
        'keywords': [
            (r'(algorithm|annotation|break|connect|constant|constrainedby|'
            r'discrete|each|end|else|elseif|elsewhen|encapsulated|enumeration|'
            r'equation|exit|expandable|extends|'
            r'external|false|final|flow|for|if|import|impure|in|initial\sequation|'
            r'inner|input|loop|nondiscrete|outer|output|parameter|partial|'
            r'protected|public|pure|redeclare|replaceable|stream|time|then|true|'
            r'when|while|within)\b', Keyword),
        ],
        'functions': [
            (r'(abs|acos|acosh|asin|asinh|atan|atan2|atan3|ceil|cos|cosh|'
             r'cross|diagonal|div|exp|fill|floor|getInstanceName|identity|'
             r'linspace|log|log10|matrix|mod|max|min|ndims|ones|outerProduct|'
             r'product|rem|scalar|semiLinear|skew|sign|sin|sinh|size|'
             r'spatialDistribution|sum|sqrt|symmetric|tan|tanh|transpose|'
             r'vector|zeros)\b', Name.Function),
        ],
        'operators': [
            (r'(actualStream|and|assert|backSample|cardinality|change|Clock|'
             r'delay|der|edge|hold|homotopy|initial|inStream|noClock|noEvent|'
             r'not|or|pre|previous|reinit|return|sample|smooth|'
             r'spatialDistribution|shiftSample|subSample|superSample|terminal|'
             r'terminate)\b', Name.Builtin),
        ],
        'classes': [
            (r'(operator)?(\s+)?(block|class|connector|end|function|model|'
             r'operator|package|record|type)(\s+)'
             r'((?!if|for|when|while)[a-z_]\w*|\'[^\']+\')([;]?)',
             bygroups(Keyword, Text, Keyword, Text, Name.Class, Text))
        ],
        'quoted_ident': [
            (r'\'', Name, '#pop'),
            (r'[^\']+', Name), # all other characters
        ],
        'string': [
            (r'"', String, '#pop'),
            (r'\\([\\abfnrtv"\']|x[a-f0-9]{2,4}|[0-7]{1,3})',
             String.Escape),
            (r'[^\\"\n]+', String), # all other characters
            (r'\\\n', String), # line continuation
            (r'\\', String), # stray backslash
        ],
        'html-content': [
            (r'<\s*/\s*html\s*>"', Name.Tag, '#pop'),
            (r'.+?(?=<\s*/\s*html\s*>)', using(HtmlLexer)),
        ]
    }


class BugsLexer(RegexLexer):
    """
    Pygments Lexer for `OpenBugs <http://www.openbugs.info/w/>`_ and WinBugs
    models.

    .. versionadded:: 1.6
    """

    name = 'BUGS'
    aliases = ['bugs', 'winbugs', 'openbugs']
    filenames = ['*.bug']

    _FUNCTIONS = (
        # Scalar functions
        'abs', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctanh',
        'cloglog', 'cos', 'cosh', 'cumulative', 'cut', 'density', 'deviance',
        'equals', 'expr', 'gammap', 'ilogit', 'icloglog', 'integral', 'log',
        'logfact', 'loggam', 'logit', 'max', 'min', 'phi', 'post.p.value',
        'pow', 'prior.p.value', 'probit', 'replicate.post', 'replicate.prior',
        'round', 'sin', 'sinh', 'solution', 'sqrt', 'step', 'tan', 'tanh',
        'trunc',<commit_msg>Fix link for OpenBugs.<commit_after># -*- coding: utf-8 -*-
"""
    pygments.lexers.modeling
    ~~~~~~~~~~~~~~~~~~~~~~~~

    Lexers for modeling languages.

    :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

import re

from pygments.lexer import RegexLexer, include, bygroups, using
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
    Number, Punctuation

from pygments.lexers.html import HtmlLexer
from pygments.lexers import _stan_builtins

__all__ = ['ModelicaLexer', 'BugsLexer', 'JagsLexer', 'StanLexer']


class ModelicaLexer(RegexLexer):
    """
    For `Modelica <http://www.modelica.org/>`_ source code.

    .. versionadded:: 1.1
    """
    name = 'Modelica'
    aliases = ['modelica']
    filenames = ['*.mo']
    mimetypes = ['text/x-modelica']

    flags = re.IGNORECASE | re.DOTALL

    tokens = {
        'whitespace': [
            (r'\n', Text),
            (r'\s+', Text),
            (r'\\\n', Text), # line continuation
            (r'//(\n|(.|\n)*?[^\\]\n)', Comment),
            (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment),
        ],
        'statements': [
            (r'"', String, 'string'),
            (r'(\d+\.\d*|\.\d+|\d+|\d.)[eE][+-]?\d+[lL]?', Number.Float),
            (r'(\d+\.\d*|\.\d+)', Number.Float),
            (r'\d+[Ll]?', Number.Integer),
            (r'[~!%^&*+=|?:<>/-]', Operator),
            (r'(true|false|NULL|Real|Integer|Boolean)\b', Name.Builtin),
            (r'([a-z_][\w]*|\'[^\']+\')'
             r'([\[\d,:\]]*)'
             r'(\.([a-z_][\w]*|\'[^\']+\'))+'
             r'([\[\d,:\]]*)', Name.Class),
            (r'(\'[\w\+\-\*\/\^]+\'|\w+)', Name),
            (r'[()\[\]{},.;]', Punctuation),
            (r'\'', Name, 'quoted_ident'),
        ],
        'root': [
            include('whitespace'),
            include('classes'),
            include('functions'),
            include('keywords'),
            include('operators'),
            (r'("<html>|<html>)', Name.Tag, 'html-content'),
            include('statements'),
        ],
        'keywords': [
            (r'(algorithm|annotation|break|connect|constant|constrainedby|'
            r'discrete|each|end|else|elseif|elsewhen|encapsulated|enumeration|'
            r'equation|exit|expandable|extends|'
            r'external|false|final|flow|for|if|import|impure|in|initial\sequation|'
            r'inner|input|loop|nondiscrete|outer|output|parameter|partial|'
            r'protected|public|pure|redeclare|replaceable|stream|time|then|true|'
            r'when|while|within)\b', Keyword),
        ],
        'functions': [
            (r'(abs|acos|acosh|asin|asinh|atan|atan2|atan3|ceil|cos|cosh|'
             r'cross|diagonal|div|exp|fill|floor|getInstanceName|identity|'
             r'linspace|log|log10|matrix|mod|max|min|ndims|ones|outerProduct|'
             r'product|rem|scalar|semiLinear|skew|sign|sin|sinh|size|'
             r'spatialDistribution|sum|sqrt|symmetric|tan|tanh|transpose|'
             r'vector|zeros)\b', Name.Function),
        ],
        'operators': [
            (r'(actualStream|and|assert|backSample|cardinality|change|Clock|'
             r'delay|der|edge|hold|homotopy|initial|inStream|noClock|noEvent|'
             r'not|or|pre|previous|reinit|return|sample|smooth|'
             r'spatialDistribution|shiftSample|subSample|superSample|terminal|'
             r'terminate)\b', Name.Builtin),
        ],
        'classes': [
            (r'(operator)?(\s+)?(block|class|connector|end|function|model|'
             r'operator|package|record|type)(\s+)'
             r'((?!if|for|when|while)[a-z_]\w*|\'[^\']+\')([;]?)',
             bygroups(Keyword, Text, Keyword, Text, Name.Class, Text))
        ],
        'quoted_ident': [
            (r'\'', Name, '#pop'),
            (r'[^\']+', Name), # all other characters
        ],
        'string': [
            (r'"', String, '#pop'),
            (r'\\([\\abfnrtv"\']|x[a-f0-9]{2,4}|[0-7]{1,3})',
             String.Escape),
            (r'[^\\"\n]+', String), # all other characters
            (r'\\\n', String), # line continuation
            (r'\\', String), # stray backslash
        ],
        'html-content': [
            (r'<\s*/\s*html\s*>"', Name.Tag, '#pop'),
            (r'.+?(?=<\s*/\s*html\s*>)', using(HtmlLexer)),
        ]
    }


class BugsLexer(RegexLexer):
    """
    Pygments Lexer for `OpenBugs <http://www.openbugs.net/>`_ and WinBugs
    models.

    .. versionadded:: 1.6
    """

    name = 'BUGS'
    aliases = ['bugs', 'winbugs', 'openbugs']
    filenames = ['*.bug']

    _FUNCTIONS = (
        # Scalar functions
        'abs', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctanh',
        'cloglog', 'cos', 'cosh', 'cumulative', 'cut', 'density', 'deviance',
        'equals', 'expr', 'gammap', 'ilogit', 'icloglog', 'integral', 'log',
        'logfact', 'loggam', 'logit', 'max', 'min', 'phi', 'post.p.value',
        'pow', 'prior.p.value', 'probit', 'replicate.post', 'replicate.prior',
        'round', 'sin', 'sinh', 'solution', 'sqrt', 'step', 'tan', 'tanh',
        'trunc',
{'fraction_non_alphanumeric': 0.22753792298716452, 'fraction_numerical': 0.0048619214313496695, 'mean_word_length': 2.3458035133376707, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2822831', 'n_tokens_mistral': 3716, 'n_tokens_neox': 3557, 'n_words': 520}