# -*- coding: utf-8 -*-
"""
    pygments.lexers.ncl
    ~~~~~~~~~~~~~~~~~~~

    Lexers for NCAR Command Language.

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

import re

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

__all__ = ['NCLLexer']


class NCLLexer(RegexLexer):
    """
    Lexer for NCL code.

    .. versionadded:: 2.2
    """
    name = 'NCL'
    aliases = ['ncl']
    filenames = ['*.ncl']
    mimetypes = ['text/ncl']
    flags = re.MULTILINE

    tokens = {
        'root': [
            (r';.*\n', Comment),
            include('strings'),
            include('core'),
            (r'[a-zA-Z_]\w*', Name),
            include('nums'),
            (r'[\s]+', Text),
        ],
        'core': [
            # Statements
            (words((
                'begin', 'break', 'continue', 'create', 'defaultapp', 'do',
                'else', 'end', 'external', 'exit', 'True', 'False', 'file', 'function',
                'getvalues', 'graphic', 'group', 'if', 'list', 'load', 'local',
                'new', '_Missing', 'Missing', 'noparent', 'procedure',
                'quit', 'QUIT', 'Quit', 'record', 'return', 'setvalues', 'stop',
                'then', 'while'), prefix=r'\b', suffix=r'\s*\b'),
             Keyword),