summaryrefslogtreecommitdiff
path: root/pygments/lexers/scripting.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/scripting.py')
-rw-r--r--pygments/lexers/scripting.py55
1 files changed, 53 insertions, 2 deletions
diff --git a/pygments/lexers/scripting.py b/pygments/lexers/scripting.py
index a340f8e0..073c21b7 100644
--- a/pygments/lexers/scripting.py
+++ b/pygments/lexers/scripting.py
@@ -19,7 +19,7 @@ from pygments.util import get_bool_opt, get_list_opt, iteritems
__all__ = ['LuaLexer', 'MoonScriptLexer', 'ChaiscriptLexer', 'LSLLexer',
'AppleScriptLexer', 'RexxLexer', 'MOOCodeLexer', 'HybrisLexer',
- 'EasytrieveLexer', 'JclLexer']
+ 'EasytrieveLexer', 'JclLexer', 'MiniScriptLexer']
class LuaLexer(RegexLexer):
@@ -162,7 +162,6 @@ class LuaLexer(RegexLexer):
continue
yield index, token, value
-
class MoonScriptLexer(LuaLexer):
"""
For `MoonScript <http://moonscript.org>`_ source code.
@@ -1220,3 +1219,55 @@ class JclLexer(RegexLexer):
result = 1.0
assert 0.0 <= result <= 1.0
return result
+
+
+class MiniScriptLexer(RegexLexer):
+ """
+ For `MiniScript <https://miniscript.org>`_ source code.
+ """
+
+ name = "MiniScript"
+ aliases = ["ms", "miniscript"]
+ filenames = ["*.ms"]
+ mimetypes = ['text/x-minicript', 'application/x-miniscript']
+
+ tokens = {
+ 'root': [
+ (r'#!(.*?)$', Comment.Preproc),
+ default('base'),
+ ],
+ 'base': [
+ ('//.*$', Comment.Single),
+ (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number),
+ (r'(?i)\d+e[+-]?\d+', Number),
+ (r'\d+', Number),
+ (r'\n', Text),
+ (r'[^\S\n]+', Text),
+ (r'"', String, 'string_double'),
+ (r'(==|!=|<=|>=|[=+\-*/%^<>.:])', Operator),
+ (r'[;,\[\]{}()]', Punctuation),
+ (words((
+ 'break', 'continue', 'else', 'end', 'for', 'function', 'if',
+ 'in', 'isa', 'then', 'repeat', 'return', 'while'), suffix=r'\b'),
+ Keyword),
+ (words((
+ 'abs', 'acos', 'asin', 'atan', 'ceil', 'char', 'cos', 'floor',
+ 'log', 'round', 'rnd', 'pi', 'sign', 'sin', 'sqrt', 'str', 'tan',
+ 'hasIndex', 'indexOf', 'len', 'val', 'code', 'remove', 'lower',
+ 'upper', 'replace', 'split', 'indexes', 'values', 'join', 'sum',
+ 'sort', 'shuffle', 'push', 'pop', 'pull', 'range',
+ 'print', 'input', 'time', 'wait', 'locals', 'globals', 'outer',
+ 'yield'), suffix=r'\b'),
+ Name.Builtin),
+ (r'(true|false|null)\b', Keyword.Constant),
+ (r'(and|or|not|new)\b', Operator.Word),
+ (r'(self|super|__isa)\b', Name.Builtin.Pseudo),
+ (r'[a-zA-Z_]\w*', Name.Variable)
+ ],
+ 'string_double': [
+ (r'[^"\n]+', String),
+ (r'""', String),
+ (r'"', String, '#pop'),
+ (r'\n', Text, '#pop'), # Stray linefeed also terminates strings.
+ ]
+ }