eric6/ThirdParty/Pygments/pygments/lexers/scripting.py

changeset 7547
21b0534faebc
parent 6942
2602857055c5
child 7701
25f42e208e08
equal deleted inserted replaced
7546:bf5f777260a6 7547:21b0534faebc
3 pygments.lexers.scripting 3 pygments.lexers.scripting
4 ~~~~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexer for scripting and embedded languages. 6 Lexer for scripting and embedded languages.
7 7
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
14 from pygments.lexer import RegexLexer, include, bygroups, default, combined, \ 14 from pygments.lexer import RegexLexer, include, bygroups, default, combined, \
15 words 15 words
16 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ 16 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
17 Number, Punctuation, Error, Whitespace, Other 17 Number, Punctuation, Error, Whitespace, Other
18 from pygments.util import get_bool_opt, get_list_opt, iteritems 18 from pygments.util import get_bool_opt, get_list_opt
19 19
20 __all__ = ['LuaLexer', 'MoonScriptLexer', 'ChaiscriptLexer', 'LSLLexer', 20 __all__ = ['LuaLexer', 'MoonScriptLexer', 'ChaiscriptLexer', 'LSLLexer',
21 'AppleScriptLexer', 'RexxLexer', 'MOOCodeLexer', 'HybrisLexer', 21 'AppleScriptLexer', 'RexxLexer', 'MOOCodeLexer', 'HybrisLexer',
22 'EasytrieveLexer', 'JclLexer'] 22 'EasytrieveLexer', 'JclLexer', 'MiniScriptLexer']
23 23
24 24
25 class LuaLexer(RegexLexer): 25 class LuaLexer(RegexLexer):
26 """ 26 """
27 For `Lua <http://www.lua.org>`_ source code. 27 For `Lua <http://www.lua.org>`_ source code.
140 self.disabled_modules = get_list_opt(options, 'disabled_modules', []) 140 self.disabled_modules = get_list_opt(options, 'disabled_modules', [])
141 141
142 self._functions = set() 142 self._functions = set()
143 if self.func_name_highlighting: 143 if self.func_name_highlighting:
144 from pygments.lexers._lua_builtins import MODULES 144 from pygments.lexers._lua_builtins import MODULES
145 for mod, func in iteritems(MODULES): 145 for mod, func in MODULES.items():
146 if mod not in self.disabled_modules: 146 if mod not in self.disabled_modules:
147 self._functions.update(func) 147 self._functions.update(func)
148 RegexLexer.__init__(self, **options) 148 RegexLexer.__init__(self, **options)
149 149
150 def get_tokens_unprocessed(self, text): 150 def get_tokens_unprocessed(self, text):
159 yield index, Name, a 159 yield index, Name, a
160 yield index + len(a), Punctuation, u'.' 160 yield index + len(a), Punctuation, u'.'
161 yield index + len(a) + 1, Name, b 161 yield index + len(a) + 1, Name, b
162 continue 162 continue
163 yield index, token, value 163 yield index, token, value
164
165 164
166 class MoonScriptLexer(LuaLexer): 165 class MoonScriptLexer(LuaLexer):
167 """ 166 """
168 For `MoonScript <http://moonscript.org>`_ source code. 167 For `MoonScript <http://moonscript.org>`_ source code.
169 168
1218 if len(lines) > 0: 1217 if len(lines) > 0:
1219 if JclLexer._JOB_HEADER_PATTERN.match(lines[0]): 1218 if JclLexer._JOB_HEADER_PATTERN.match(lines[0]):
1220 result = 1.0 1219 result = 1.0
1221 assert 0.0 <= result <= 1.0 1220 assert 0.0 <= result <= 1.0
1222 return result 1221 return result
1222
1223
1224 class MiniScriptLexer(RegexLexer):
1225 """
1226 For `MiniScript <https://miniscript.org>`_ source code.
1227
1228 .. versionadded:: 2.6
1229 """
1230
1231 name = "MiniScript"
1232 aliases = ["ms", "miniscript"]
1233 filenames = ["*.ms"]
1234 mimetypes = ['text/x-minicript', 'application/x-miniscript']
1235
1236 tokens = {
1237 'root': [
1238 (r'#!(.*?)$', Comment.Preproc),
1239 default('base'),
1240 ],
1241 'base': [
1242 ('//.*$', Comment.Single),
1243 (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number),
1244 (r'(?i)\d+e[+-]?\d+', Number),
1245 (r'\d+', Number),
1246 (r'\n', Text),
1247 (r'[^\S\n]+', Text),
1248 (r'"', String, 'string_double'),
1249 (r'(==|!=|<=|>=|[=+\-*/%^<>.:])', Operator),
1250 (r'[;,\[\]{}()]', Punctuation),
1251 (words((
1252 'break', 'continue', 'else', 'end', 'for', 'function', 'if',
1253 'in', 'isa', 'then', 'repeat', 'return', 'while'), suffix=r'\b'),
1254 Keyword),
1255 (words((
1256 'abs', 'acos', 'asin', 'atan', 'ceil', 'char', 'cos', 'floor',
1257 'log', 'round', 'rnd', 'pi', 'sign', 'sin', 'sqrt', 'str', 'tan',
1258 'hasIndex', 'indexOf', 'len', 'val', 'code', 'remove', 'lower',
1259 'upper', 'replace', 'split', 'indexes', 'values', 'join', 'sum',
1260 'sort', 'shuffle', 'push', 'pop', 'pull', 'range',
1261 'print', 'input', 'time', 'wait', 'locals', 'globals', 'outer',
1262 'yield'), suffix=r'\b'),
1263 Name.Builtin),
1264 (r'(true|false|null)\b', Keyword.Constant),
1265 (r'(and|or|not|new)\b', Operator.Word),
1266 (r'(self|super|__isa)\b', Name.Builtin.Pseudo),
1267 (r'[a-zA-Z_]\w*', Name.Variable)
1268 ],
1269 'string_double': [
1270 (r'[^"\n]+', String),
1271 (r'""', String),
1272 (r'"', String, '#pop'),
1273 (r'\n', Text, '#pop'), # Stray linefeed also terminates strings.
1274 ]
1275 }

eric ide

mercurial