2014-12-01 06:10:30 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
pygments.lexers.iolang
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Lexers for the Io language.
|
|
|
|
|
2017-02-14 07:25:51 +00:00
|
|
|
:copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
|
2014-12-01 06:10:30 +00:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from pygments.lexer import RegexLexer
|
|
|
|
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
|
|
|
Number
|
|
|
|
|
|
|
|
__all__ = ['IoLexer']
|
|
|
|
|
|
|
|
|
|
|
|
class IoLexer(RegexLexer):
|
|
|
|
"""
|
|
|
|
For `Io <http://iolanguage.com/>`_ (a small, prototype-based
|
|
|
|
programming language) source.
|
|
|
|
|
|
|
|
.. versionadded:: 0.10
|
|
|
|
"""
|
|
|
|
name = 'Io'
|
|
|
|
filenames = ['*.io']
|
|
|
|
aliases = ['io']
|
|
|
|
mimetypes = ['text/x-iosrc']
|
|
|
|
tokens = {
|
|
|
|
'root': [
|
|
|
|
(r'\n', Text),
|
|
|
|
(r'\s+', Text),
|
|
|
|
# Comments
|
|
|
|
(r'//(.*?)\n', Comment.Single),
|
|
|
|
(r'#(.*?)\n', Comment.Single),
|
|
|
|
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
|
|
|
|
(r'/\+', Comment.Multiline, 'nestedcomment'),
|
|
|
|
# DoubleQuotedString
|
|
|
|
(r'"(\\\\|\\"|[^"])*"', String),
|
|
|
|
# Operators
|
|
|
|
(r'::=|:=|=|\(|\)|;|,|\*|-|\+|>|<|@|!|/|\||\^|\.|%|&|\[|\]|\{|\}',
|
|
|
|
Operator),
|
|
|
|
# keywords
|
|
|
|
(r'(clone|do|doFile|doString|method|for|if|else|elseif|then)\b',
|
|
|
|
Keyword),
|
|
|
|
# constants
|
|
|
|
(r'(nil|false|true)\b', Name.Constant),
|
|
|
|
# names
|
|
|
|
(r'(Object|list|List|Map|args|Sequence|Coroutine|File)\b',
|
|
|
|
Name.Builtin),
|
|
|
|
('[a-zA-Z_]\w*', Name),
|
|
|
|
# numbers
|
|
|
|
(r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
|
|
|
(r'\d+', Number.Integer)
|
|
|
|
],
|
|
|
|
'nestedcomment': [
|
|
|
|
(r'[^+/]+', Comment.Multiline),
|
|
|
|
(r'/\+', Comment.Multiline, '#push'),
|
|
|
|
(r'\+/', Comment.Multiline, '#pop'),
|
|
|
|
(r'[+/]', Comment.Multiline),
|
|
|
|
]
|
|
|
|
}
|