2021-04-13 04:02:29 +00:00
|
|
|
"""
|
|
|
|
pygments.lexers.iolang
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Lexers for the Io language.
|
|
|
|
|
2022-11-07 18:06:49 +00:00
|
|
|
:copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
|
2021-04-13 04:02:29 +00:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from pygments.lexer import RegexLexer
|
|
|
|
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
|
2022-11-07 18:06:49 +00:00
|
|
|
Number, Whitespace
|
2021-04-13 04:02:29 +00:00
|
|
|
|
|
|
|
__all__ = ['IoLexer']
|
|
|
|
|
|
|
|
|
|
|
|
class IoLexer(RegexLexer):
|
|
|
|
"""
|
2022-11-07 18:06:49 +00:00
|
|
|
For Io (a small, prototype-based programming language) source.
|
2021-04-13 04:02:29 +00:00
|
|
|
|
|
|
|
.. versionadded:: 0.10
|
|
|
|
"""
|
|
|
|
name = 'Io'
|
2022-11-07 18:06:49 +00:00
|
|
|
url = 'http://iolanguage.com/'
|
2021-04-13 04:02:29 +00:00
|
|
|
filenames = ['*.io']
|
|
|
|
aliases = ['io']
|
|
|
|
mimetypes = ['text/x-iosrc']
|
|
|
|
tokens = {
|
|
|
|
'root': [
|
2022-11-07 18:06:49 +00:00
|
|
|
(r'\n', Whitespace),
|
|
|
|
(r'\s+', Whitespace),
|
2021-04-13 04:02:29 +00:00
|
|
|
# Comments
|
2022-11-07 18:06:49 +00:00
|
|
|
(r'//(.*?)$', Comment.Single),
|
|
|
|
(r'#(.*?)$', Comment.Single),
|
2021-04-13 04:02:29 +00:00
|
|
|
(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),
|
|
|
|
(r'[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),
|
|
|
|
]
|
|
|
|
}
|