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

Thu, 14 Jan 2021 18:14:15 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 14 Jan 2021 18:14:15 +0100
changeset 7983
54c5cfbb1e29
parent 7701
25f42e208e08
permissions
-rw-r--r--

Third Party packages
- updated Pygments to 2.7.4

7983
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1 # -*- coding: utf-8 -*-
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
2 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
3 pygments.lexers.scripting
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
5
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
6 Lexer for scripting and embedded languages.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
7
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
8 :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
9 :license: BSD, see LICENSE for details.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
10 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
11
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
12 import re
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
13
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
14 from pygments.lexer import RegexLexer, include, bygroups, default, combined, \
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
15 words
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
16 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
17 Number, Punctuation, Error, Whitespace, Other
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
18 from pygments.util import get_bool_opt, get_list_opt
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
19
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
20 __all__ = ['LuaLexer', 'MoonScriptLexer', 'ChaiscriptLexer', 'LSLLexer',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
21 'AppleScriptLexer', 'RexxLexer', 'MOOCodeLexer', 'HybrisLexer',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
22 'EasytrieveLexer', 'JclLexer', 'MiniScriptLexer']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
23
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
24
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
25 class LuaLexer(RegexLexer):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
26 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
27 For `Lua <http://www.lua.org>`_ source code.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
28
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
29 Additional options accepted:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
30
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
31 `func_name_highlighting`
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
32 If given and ``True``, highlight builtin function names
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
33 (default: ``True``).
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
34 `disabled_modules`
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
35 If given, must be a list of module names whose function names
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
36 should not be highlighted. By default all modules are highlighted.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
37
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
38 To get a list of allowed modules have a look into the
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
39 `_lua_builtins` module:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
40
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
41 .. sourcecode:: pycon
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
42
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
43 >>> from pygments.lexers._lua_builtins import MODULES
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
44 >>> MODULES.keys()
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
45 ['string', 'coroutine', 'modules', 'io', 'basic', ...]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
46 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
47
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
48 name = 'Lua'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
49 aliases = ['lua']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
50 filenames = ['*.lua', '*.wlua']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
51 mimetypes = ['text/x-lua', 'application/x-lua']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
52
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
53 _comment_multiline = r'(?:--\[(?P<level>=*)\[[\w\W]*?\](?P=level)\])'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
54 _comment_single = r'(?:--.*$)'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
55 _space = r'(?:\s+)'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
56 _s = r'(?:%s|%s|%s)' % (_comment_multiline, _comment_single, _space)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
57 _name = r'(?:[^\W\d]\w*)'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
58
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
59 tokens = {
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
60 'root': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
61 # Lua allows a file to start with a shebang.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
62 (r'#!.*', Comment.Preproc),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
63 default('base'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
64 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
65 'ws': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
66 (_comment_multiline, Comment.Multiline),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
67 (_comment_single, Comment.Single),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
68 (_space, Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
69 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
70 'base': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
71 include('ws'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
72
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
73 (r'(?i)0x[\da-f]*(\.[\da-f]*)?(p[+-]?\d+)?', Number.Hex),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
74 (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
75 (r'(?i)\d+e[+-]?\d+', Number.Float),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
76 (r'\d+', Number.Integer),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
77
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
78 # multiline strings
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
79 (r'(?s)\[(=*)\[.*?\]\1\]', String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
80
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
81 (r'::', Punctuation, 'label'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
82 (r'\.{3}', Punctuation),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
83 (r'[=<>|~&+\-*/%#^]+|\.\.', Operator),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
84 (r'[\[\]{}().,:;]', Punctuation),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
85 (r'(and|or|not)\b', Operator.Word),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
86
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
87 ('(break|do|else|elseif|end|for|if|in|repeat|return|then|until|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
88 r'while)\b', Keyword.Reserved),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
89 (r'goto\b', Keyword.Reserved, 'goto'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
90 (r'(local)\b', Keyword.Declaration),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
91 (r'(true|false|nil)\b', Keyword.Constant),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
92
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
93 (r'(function)\b', Keyword.Reserved, 'funcname'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
94
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
95 (r'[A-Za-z_]\w*(\.[A-Za-z_]\w*)?', Name),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
96
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
97 ("'", String.Single, combined('stringescape', 'sqs')),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
98 ('"', String.Double, combined('stringescape', 'dqs'))
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
99 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
100
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
101 'funcname': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
102 include('ws'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
103 (r'[.:]', Punctuation),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
104 (r'%s(?=%s*[.:])' % (_name, _s), Name.Class),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
105 (_name, Name.Function, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
106 # inline function
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
107 (r'\(', Punctuation, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
108 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
109
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
110 'goto': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
111 include('ws'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
112 (_name, Name.Label, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
113 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
114
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
115 'label': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
116 include('ws'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
117 (r'::', Punctuation, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
118 (_name, Name.Label),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
119 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
120
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
121 'stringescape': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
122 (r'\\([abfnrtv\\"\']|[\r\n]{1,2}|z\s*|x[0-9a-fA-F]{2}|\d{1,3}|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
123 r'u\{[0-9a-fA-F]+\})', String.Escape),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
124 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
125
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
126 'sqs': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
127 (r"'", String.Single, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
128 (r"[^\\']+", String.Single),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
129 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
130
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
131 'dqs': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
132 (r'"', String.Double, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
133 (r'[^\\"]+', String.Double),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
134 ]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
135 }
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
136
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
137 def __init__(self, **options):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
138 self.func_name_highlighting = get_bool_opt(
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
139 options, 'func_name_highlighting', True)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
140 self.disabled_modules = get_list_opt(options, 'disabled_modules', [])
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
141
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
142 self._functions = set()
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
143 if self.func_name_highlighting:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
144 from pygments.lexers._lua_builtins import MODULES
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
145 for mod, func in MODULES.items():
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
146 if mod not in self.disabled_modules:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
147 self._functions.update(func)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
148 RegexLexer.__init__(self, **options)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
149
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
150 def get_tokens_unprocessed(self, text):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
151 for index, token, value in \
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
152 RegexLexer.get_tokens_unprocessed(self, text):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
153 if token is Name:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
154 if value in self._functions:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
155 yield index, Name.Builtin, value
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
156 continue
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
157 elif '.' in value:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
158 a, b = value.split('.')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
159 yield index, Name, a
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
160 yield index + len(a), Punctuation, '.'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
161 yield index + len(a) + 1, Name, b
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
162 continue
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
163 yield index, token, value
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
164
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
165 class MoonScriptLexer(LuaLexer):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
166 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
167 For `MoonScript <http://moonscript.org>`_ source code.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
168
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
169 .. versionadded:: 1.5
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
170 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
171
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
172 name = "MoonScript"
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
173 aliases = ["moon", "moonscript"]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
174 filenames = ["*.moon"]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
175 mimetypes = ['text/x-moonscript', 'application/x-moonscript']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
176
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
177 tokens = {
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
178 'root': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
179 (r'#!(.*?)$', Comment.Preproc),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
180 default('base'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
181 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
182 'base': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
183 ('--.*$', Comment.Single),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
184 (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
185 (r'(?i)\d+e[+-]?\d+', Number.Float),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
186 (r'(?i)0x[0-9a-f]*', Number.Hex),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
187 (r'\d+', Number.Integer),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
188 (r'\n', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
189 (r'[^\S\n]+', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
190 (r'(?s)\[(=*)\[.*?\]\1\]', String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
191 (r'(->|=>)', Name.Function),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
192 (r':[a-zA-Z_]\w*', Name.Variable),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
193 (r'(==|!=|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#!.\\:])', Operator),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
194 (r'[;,]', Punctuation),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
195 (r'[\[\]{}()]', Keyword.Type),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
196 (r'[a-zA-Z_]\w*:', Name.Variable),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
197 (words((
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
198 'class', 'extends', 'if', 'then', 'super', 'do', 'with',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
199 'import', 'export', 'while', 'elseif', 'return', 'for', 'in',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
200 'from', 'when', 'using', 'else', 'and', 'or', 'not', 'switch',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
201 'break'), suffix=r'\b'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
202 Keyword),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
203 (r'(true|false|nil)\b', Keyword.Constant),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
204 (r'(and|or|not)\b', Operator.Word),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
205 (r'(self)\b', Name.Builtin.Pseudo),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
206 (r'@@?([a-zA-Z_]\w*)?', Name.Variable.Class),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
207 (r'[A-Z]\w*', Name.Class), # proper name
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
208 (r'[A-Za-z_]\w*(\.[A-Za-z_]\w*)?', Name),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
209 ("'", String.Single, combined('stringescape', 'sqs')),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
210 ('"', String.Double, combined('stringescape', 'dqs'))
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
211 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
212 'stringescape': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
213 (r'''\\([abfnrtv\\"']|\d{1,3})''', String.Escape)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
214 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
215 'sqs': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
216 ("'", String.Single, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
217 (".", String)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
218 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
219 'dqs': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
220 ('"', String.Double, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
221 (".", String)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
222 ]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
223 }
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
224
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
225 def get_tokens_unprocessed(self, text):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
226 # set . as Operator instead of Punctuation
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
227 for index, token, value in LuaLexer.get_tokens_unprocessed(self, text):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
228 if token == Punctuation and value == ".":
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
229 token = Operator
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
230 yield index, token, value
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
231
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
232
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
233 class ChaiscriptLexer(RegexLexer):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
234 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
235 For `ChaiScript <http://chaiscript.com/>`_ source code.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
236
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
237 .. versionadded:: 2.0
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
238 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
239
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
240 name = 'ChaiScript'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
241 aliases = ['chai', 'chaiscript']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
242 filenames = ['*.chai']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
243 mimetypes = ['text/x-chaiscript', 'application/x-chaiscript']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
244
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
245 flags = re.DOTALL | re.MULTILINE
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
246
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
247 tokens = {
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
248 'commentsandwhitespace': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
249 (r'\s+', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
250 (r'//.*?\n', Comment.Single),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
251 (r'/\*.*?\*/', Comment.Multiline),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
252 (r'^\#.*?\n', Comment.Single)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
253 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
254 'slashstartsregex': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
255 include('commentsandwhitespace'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
256 (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
257 r'([gim]+\b|\B)', String.Regex, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
258 (r'(?=/)', Text, ('#pop', 'badregex')),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
259 default('#pop')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
260 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
261 'badregex': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
262 (r'\n', Text, '#pop')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
263 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
264 'root': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
265 include('commentsandwhitespace'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
266 (r'\n', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
267 (r'[^\S\n]+', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
268 (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|\.\.'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
269 r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
270 (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
271 (r'[})\].]', Punctuation),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
272 (r'[=+\-*/]', Operator),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
273 (r'(for|in|while|do|break|return|continue|if|else|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
274 r'throw|try|catch'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
275 r')\b', Keyword, 'slashstartsregex'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
276 (r'(var)\b', Keyword.Declaration, 'slashstartsregex'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
277 (r'(attr|def|fun)\b', Keyword.Reserved),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
278 (r'(true|false)\b', Keyword.Constant),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
279 (r'(eval|throw)\b', Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
280 (r'`\S+`', Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
281 (r'[$a-zA-Z_]\w*', Name.Other),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
282 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
283 (r'0x[0-9a-fA-F]+', Number.Hex),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
284 (r'[0-9]+', Number.Integer),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
285 (r'"', String.Double, 'dqstring'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
286 (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
287 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
288 'dqstring': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
289 (r'\$\{[^"}]+?\}', String.Interpol),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
290 (r'\$', String.Double),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
291 (r'\\\\', String.Double),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
292 (r'\\"', String.Double),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
293 (r'[^\\"$]+', String.Double),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
294 (r'"', String.Double, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
295 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
296 }
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
297
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
298
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
299 class LSLLexer(RegexLexer):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
300 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
301 For Second Life's Linden Scripting Language source code.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
302
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
303 .. versionadded:: 2.0
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
304 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
305
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
306 name = 'LSL'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
307 aliases = ['lsl']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
308 filenames = ['*.lsl']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
309 mimetypes = ['text/x-lsl']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
310
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
311 flags = re.MULTILINE
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
312
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
313 lsl_keywords = r'\b(?:do|else|for|if|jump|return|while)\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
314 lsl_types = r'\b(?:float|integer|key|list|quaternion|rotation|string|vector)\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
315 lsl_states = r'\b(?:(?:state)\s+\w+|default)\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
316 lsl_events = r'\b(?:state_(?:entry|exit)|touch(?:_(?:start|end))?|(?:land_)?collision(?:_(?:start|end))?|timer|listen|(?:no_)?sensor|control|(?:not_)?at_(?:rot_)?target|money|email|run_time_permissions|changed|attach|dataserver|moving_(?:start|end)|link_message|(?:on|object)_rez|remote_data|http_re(?:sponse|quest)|path_update|transaction_result)\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
317 lsl_functions_builtin = r'\b(?:ll(?:ReturnObjectsBy(?:ID|Owner)|Json(?:2List|[GS]etValue|ValueType)|Sin|Cos|Tan|Atan2|Sqrt|Pow|Abs|Fabs|Frand|Floor|Ceil|Round|Vec(?:Mag|Norm|Dist)|Rot(?:Between|2(?:Euler|Fwd|Left|Up))|(?:Euler|Axes)2Rot|Whisper|(?:Region|Owner)?Say|Shout|Listen(?:Control|Remove)?|Sensor(?:Repeat|Remove)?|Detected(?:Name|Key|Owner|Type|Pos|Vel|Grab|Rot|Group|LinkNumber)|Die|Ground|Wind|(?:[GS]et)(?:AnimationOverride|MemoryLimit|PrimMediaParams|ParcelMusicURL|Object(?:Desc|Name)|PhysicsMaterial|Status|Scale|Color|Alpha|Texture|Pos|Rot|Force|Torque)|ResetAnimationOverride|(?:Scale|Offset|Rotate)Texture|(?:Rot)?Target(?:Remove)?|(?:Stop)?MoveToTarget|Apply(?:Rotational)?Impulse|Set(?:KeyframedMotion|ContentType|RegionPos|(?:Angular)?Velocity|Buoyancy|HoverHeight|ForceAndTorque|TimerEvent|ScriptState|Damage|TextureAnim|Sound(?:Queueing|Radius)|Vehicle(?:Type|(?:Float|Vector|Rotation)Param)|(?:Touch|Sit)?Text|Camera(?:Eye|At)Offset|PrimitiveParams|ClickAction|Link(?:Alpha|Color|PrimitiveParams(?:Fast)?|Texture(?:Anim)?|Camera|Media)|RemoteScriptAccessPin|PayPrice|LocalRot)|ScaleByFactor|Get(?:(?:Max|Min)ScaleFactor|ClosestNavPoint|StaticPath|SimStats|Env|PrimitiveParams|Link(?:PrimitiveParams|Number(?:OfSides)?|Key|Name|Media)|HTTPHeader|FreeURLs|Object(?:Details|PermMask|PrimCount)|Parcel(?:MaxPrims|Details|Prim(?:Count|Owners))|Attached|(?:SPMax|Free|Used)Memory|Region(?:Name|TimeDilation|FPS|Corner|AgentCount)|Root(?:Position|Rotation)|UnixTime|(?:Parcel|Region)Flags|(?:Wall|GMT)clock|SimulatorHostname|BoundingBox|GeometricCenter|Creator|NumberOf(?:Prims|NotecardLines|Sides)|Animation(?:List)?|(?:Camera|Local)(?:Pos|Rot)|Vel|Accel|Omega|Time(?:stamp|OfDay)|(?:Object|CenterOf)?Mass|MassMKS|Energy|Owner|(?:Owner)?Key|SunDirection|Texture(?:Offset|Scale|Rot)|Inventory(?:Number|Name|Key|Type|Creator|PermMask)|Permissions(?:Key)?|StartParameter|List(?:Length|EntryType)|Date|Agent(?:Size|Info|Language|List)|LandOwnerAt|NotecardLine|Script(?:Name|State))|(?:Get|Reset|GetAndReset)Time|PlaySound(?:Slave)?|LoopSound(?:Master|Slave)?|(?:Trigger|Stop|Preload)Sound|(?:(?:Get|Delete)Sub|Insert)String|To(?:Upper|Lower)|Give(?:InventoryList|Money)|RezObject|(?:Stop)?LookAt|Sleep|CollisionFilter|(?:Take|Release)Controls|DetachFromAvatar|AttachToAvatar(?:Temp)?|InstantMessage|(?:GetNext)?Email|StopHover|MinEventDelay|RotLookAt|String(?:Length|Trim)|(?:Start|Stop)Animation|TargetOmega|RequestPermissions|(?:Create|Break)Link|BreakAllLinks|(?:Give|Remove)Inventory|Water|PassTouches|Request(?:Agent|Inventory)Data|TeleportAgent(?:Home|GlobalCoords)?|ModifyLand|CollisionSound|ResetScript|MessageLinked|PushObject|PassCollisions|AxisAngle2Rot|Rot2(?:Axis|Angle)|A(?:cos|sin)|AngleBetween|AllowInventoryDrop|SubStringIndex|List2(?:CSV|Integer|Json|Float|String|Key|Vector|Rot|List(?:Strided)?)|DeleteSubList|List(?:Statistics|Sort|Randomize|(?:Insert|Find|Replace)List)|EdgeOfWorld|AdjustSoundVolume|Key2Name|TriggerSoundLimited|EjectFromLand|(?:CSV|ParseString)2List|OverMyLand|SameGroup|UnSit|Ground(?:Slope|Normal|Contour)|GroundRepel|(?:Set|Remove)VehicleFlags|(?:AvatarOn)?(?:Link)?SitTarget|Script(?:Danger|Profiler)|Dialog|VolumeDetect|ResetOtherScript|RemoteLoadScriptPin|(?:Open|Close)RemoteDataChannel|SendRemoteData|RemoteDataReply|(?:Integer|String)ToBase64|XorBase64|Log(?:10)?|Base64To(?:String|Integer)|ParseStringKeepNulls|RezAtRoot|RequestSimulatorData|ForceMouselook|(?:Load|Release|(?:E|Une)scape)URL|ParcelMedia(?:CommandList|Query)|ModPow|MapDestination|(?:RemoveFrom|AddTo|Reset)Land(?:Pass|Ban)List|(?:Set|Clear)CameraParams|HTTP(?:Request|Response)|TextBox|DetectedTouch(?:UV|Face|Pos|(?:N|Bin)ormal|ST)|(?:MD5|SHA1|DumpList2)String|Request(?:Secure)?URL|Clear(?:Prim|Link)Media|(?:Link)?ParticleSystem|(?:Get|Request)(?:Username|DisplayName)|RegionSayTo|CastRay|GenerateKey|TransferLindenDollars|ManageEstateAccess|(?:Create|Delete)Character|ExecCharacterCmd|Evade|FleeFrom|NavigateTo|PatrolPoints|Pursue|UpdateCharacter|WanderWithin))\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
318 lsl_constants_float = r'\b(?:DEG_TO_RAD|PI(?:_BY_TWO)?|RAD_TO_DEG|SQRT2|TWO_PI)\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
319 lsl_constants_integer = r'\b(?:JSON_APPEND|STATUS_(?:PHYSICS|ROTATE_[XYZ]|PHANTOM|SANDBOX|BLOCK_GRAB(?:_OBJECT)?|(?:DIE|RETURN)_AT_EDGE|CAST_SHADOWS|OK|MALFORMED_PARAMS|TYPE_MISMATCH|BOUNDS_ERROR|NOT_(?:FOUND|SUPPORTED)|INTERNAL_ERROR|WHITELIST_FAILED)|AGENT(?:_(?:BY_(?:LEGACY_|USER)NAME|FLYING|ATTACHMENTS|SCRIPTED|MOUSELOOK|SITTING|ON_OBJECT|AWAY|WALKING|IN_AIR|TYPING|CROUCHING|BUSY|ALWAYS_RUN|AUTOPILOT|LIST_(?:PARCEL(?:_OWNER)?|REGION)))?|CAMERA_(?:PITCH|DISTANCE|BEHINDNESS_(?:ANGLE|LAG)|(?:FOCUS|POSITION)(?:_(?:THRESHOLD|LOCKED|LAG))?|FOCUS_OFFSET|ACTIVE)|ANIM_ON|LOOP|REVERSE|PING_PONG|SMOOTH|ROTATE|SCALE|ALL_SIDES|LINK_(?:ROOT|SET|ALL_(?:OTHERS|CHILDREN)|THIS)|ACTIVE|PASSIVE|SCRIPTED|CONTROL_(?:FWD|BACK|(?:ROT_)?(?:LEFT|RIGHT)|UP|DOWN|(?:ML_)?LBUTTON)|PERMISSION_(?:RETURN_OBJECTS|DEBIT|OVERRIDE_ANIMATIONS|SILENT_ESTATE_MANAGEMENT|TAKE_CONTROLS|TRIGGER_ANIMATION|ATTACH|CHANGE_LINKS|(?:CONTROL|TRACK)_CAMERA|TELEPORT)|INVENTORY_(?:TEXTURE|SOUND|OBJECT|SCRIPT|LANDMARK|CLOTHING|NOTECARD|BODYPART|ANIMATION|GESTURE|ALL|NONE)|CHANGED_(?:INVENTORY|COLOR|SHAPE|SCALE|TEXTURE|LINK|ALLOWED_DROP|OWNER|REGION(?:_START)?|TELEPORT|MEDIA)|OBJECT_(?:(?:PHYSICS|SERVER|STREAMING)_COST|UNKNOWN_DETAIL|CHARACTER_TIME|PHANTOM|PHYSICS|TEMP_ON_REZ|NAME|DESC|POS|PRIM_EQUIVALENCE|RETURN_(?:PARCEL(?:_OWNER)?|REGION)|ROO?T|VELOCITY|OWNER|GROUP|CREATOR|ATTACHED_POINT|RENDER_WEIGHT|PATHFINDING_TYPE|(?:RUNNING|TOTAL)_SCRIPT_COUNT|SCRIPT_(?:MEMORY|TIME))|TYPE_(?:INTEGER|FLOAT|STRING|KEY|VECTOR|ROTATION|INVALID)|(?:DEBUG|PUBLIC)_CHANNEL|ATTACH_(?:AVATAR_CENTER|CHEST|HEAD|BACK|PELVIS|MOUTH|CHIN|NECK|NOSE|BELLY|[LR](?:SHOULDER|HAND|FOOT|EAR|EYE|[UL](?:ARM|LEG)|HIP)|(?:LEFT|RIGHT)_PEC|HUD_(?:CENTER_[12]|TOP_(?:RIGHT|CENTER|LEFT)|BOTTOM(?:_(?:RIGHT|LEFT))?))|LAND_(?:LEVEL|RAISE|LOWER|SMOOTH|NOISE|REVERT)|DATA_(?:ONLINE|NAME|BORN|SIM_(?:POS|STATUS|RATING)|PAYINFO)|PAYMENT_INFO_(?:ON_FILE|USED)|REMOTE_DATA_(?:CHANNEL|REQUEST|REPLY)|PSYS_(?:PART_(?:BF_(?:ZERO|ONE(?:_MINUS_(?:DEST_COLOR|SOURCE_(ALPHA|COLOR)))?|DEST_COLOR|SOURCE_(ALPHA|COLOR))|BLEND_FUNC_(DEST|SOURCE)|FLAGS|(?:START|END)_(?:COLOR|ALPHA|SCALE|GLOW)|MAX_AGE|(?:RIBBON|WIND|INTERP_(?:COLOR|SCALE)|BOUNCE|FOLLOW_(?:SRC|VELOCITY)|TARGET_(?:POS|LINEAR)|EMISSIVE)_MASK)|SRC_(?:MAX_AGE|PATTERN|ANGLE_(?:BEGIN|END)|BURST_(?:RATE|PART_COUNT|RADIUS|SPEED_(?:MIN|MAX))|ACCEL|TEXTURE|TARGET_KEY|OMEGA|PATTERN_(?:DROP|EXPLODE|ANGLE(?:_CONE(?:_EMPTY)?)?)))|VEHICLE_(?:REFERENCE_FRAME|TYPE_(?:NONE|SLED|CAR|BOAT|AIRPLANE|BALLOON)|(?:LINEAR|ANGULAR)_(?:FRICTION_TIMESCALE|MOTOR_DIRECTION)|LINEAR_MOTOR_OFFSET|HOVER_(?:HEIGHT|EFFICIENCY|TIMESCALE)|BUOYANCY|(?:LINEAR|ANGULAR)_(?:DEFLECTION_(?:EFFICIENCY|TIMESCALE)|MOTOR_(?:DECAY_)?TIMESCALE)|VERTICAL_ATTRACTION_(?:EFFICIENCY|TIMESCALE)|BANKING_(?:EFFICIENCY|MIX|TIMESCALE)|FLAG_(?:NO_DEFLECTION_UP|LIMIT_(?:ROLL_ONLY|MOTOR_UP)|HOVER_(?:(?:WATER|TERRAIN|UP)_ONLY|GLOBAL_HEIGHT)|MOUSELOOK_(?:STEER|BANK)|CAMERA_DECOUPLED))|PRIM_(?:TYPE(?:_(?:BOX|CYLINDER|PRISM|SPHERE|TORUS|TUBE|RING|SCULPT))?|HOLE_(?:DEFAULT|CIRCLE|SQUARE|TRIANGLE)|MATERIAL(?:_(?:STONE|METAL|GLASS|WOOD|FLESH|PLASTIC|RUBBER))?|SHINY_(?:NONE|LOW|MEDIUM|HIGH)|BUMP_(?:NONE|BRIGHT|DARK|WOOD|BARK|BRICKS|CHECKER|CONCRETE|TILE|STONE|DISKS|GRAVEL|BLOBS|SIDING|LARGETILE|STUCCO|SUCTION|WEAVE)|TEXGEN_(?:DEFAULT|PLANAR)|SCULPT_(?:TYPE_(?:SPHERE|TORUS|PLANE|CYLINDER|MASK)|FLAG_(?:MIRROR|INVERT))|PHYSICS(?:_(?:SHAPE_(?:CONVEX|NONE|PRIM|TYPE)))?|(?:POS|ROT)_LOCAL|SLICE|TEXT|FLEXIBLE|POINT_LIGHT|TEMP_ON_REZ|PHANTOM|POSITION|SIZE|ROTATION|TEXTURE|NAME|OMEGA|DESC|LINK_TARGET|COLOR|BUMP_SHINY|FULLBRIGHT|TEXGEN|GLOW|MEDIA_(?:ALT_IMAGE_ENABLE|CONTROLS|(?:CURRENT|HOME)_URL|AUTO_(?:LOOP|PLAY|SCALE|ZOOM)|FIRST_CLICK_INTERACT|(?:WIDTH|HEIGHT)_PIXELS|WHITELIST(?:_ENABLE)?|PERMS_(?:INTERACT|CONTROL)|PARAM_MAX|CONTROLS_(?:STANDARD|MINI)|PERM_(?:NONE|OWNER|GROUP|ANYONE)|MAX_(?:URL_LENGTH|WHITELIST_(?:SIZE|COUNT)|(?:WIDTH|HEIGHT)_PIXELS)))|MASK_(?:BASE|OWNER|GROUP|EVERYONE|NEXT)|PERM_(?:TRANSFER|MODIFY|COPY|MOVE|ALL)|PARCEL_(?:MEDIA_COMMAND_(?:STOP|PAUSE|PLAY|LOOP|TEXTURE|URL|TIME|AGENT|UNLOAD|AUTO_ALIGN|TYPE|SIZE|DESC|LOOP_SET)|FLAG_(?:ALLOW_(?:FLY|(?:GROUP_)?SCRIPTS|LANDMARK|TERRAFORM|DAMAGE|CREATE_(?:GROUP_)?OBJECTS)|USE_(?:ACCESS_(?:GROUP|LIST)|BAN_LIST|LAND_PASS_LIST)|LOCAL_SOUND_ONLY|RESTRICT_PUSHOBJECT|ALLOW_(?:GROUP|ALL)_OBJECT_ENTRY)|COUNT_(?:TOTAL|OWNER|GROUP|OTHER|SELECTED|TEMP)|DETAILS_(?:NAME|DESC|OWNER|GROUP|AREA|ID|SEE_AVATARS))|LIST_STAT_(?:MAX|MIN|MEAN|MEDIAN|STD_DEV|SUM(?:_SQUARES)?|NUM_COUNT|GEOMETRIC_MEAN|RANGE)|PAY_(?:HIDE|DEFAULT)|REGION_FLAG_(?:ALLOW_DAMAGE|FIXED_SUN|BLOCK_TERRAFORM|SANDBOX|DISABLE_(?:COLLISIONS|PHYSICS)|BLOCK_FLY|ALLOW_DIRECT_TELEPORT|RESTRICT_PUSHOBJECT)|HTTP_(?:METHOD|MIMETYPE|BODY_(?:MAXLENGTH|TRUNCATED)|CUSTOM_HEADER|PRAGMA_NO_CACHE|VERBOSE_THROTTLE|VERIFY_CERT)|STRING_(?:TRIM(?:_(?:HEAD|TAIL))?)|CLICK_ACTION_(?:NONE|TOUCH|SIT|BUY|PAY|OPEN(?:_MEDIA)?|PLAY|ZOOM)|TOUCH_INVALID_FACE|PROFILE_(?:NONE|SCRIPT_MEMORY)|RC_(?:DATA_FLAGS|DETECT_PHANTOM|GET_(?:LINK_NUM|NORMAL|ROOT_KEY)|MAX_HITS|REJECT_(?:TYPES|AGENTS|(?:NON)?PHYSICAL|LAND))|RCERR_(?:CAST_TIME_EXCEEDED|SIM_PERF_LOW|UNKNOWN)|ESTATE_ACCESS_(?:ALLOWED_(?:AGENT|GROUP)_(?:ADD|REMOVE)|BANNED_AGENT_(?:ADD|REMOVE))|DENSITY|FRICTION|RESTITUTION|GRAVITY_MULTIPLIER|KFM_(?:COMMAND|CMD_(?:PLAY|STOP|PAUSE|SET_MODE)|MODE|FORWARD|LOOP|PING_PONG|REVERSE|DATA|ROTATION|TRANSLATION)|ERR_(?:GENERIC|PARCEL_PERMISSIONS|MALFORMED_PARAMS|RUNTIME_PERMISSIONS|THROTTLED)|CHARACTER_(?:CMD_(?:(?:SMOOTH_)?STOP|JUMP)|DESIRED_(?:TURN_)?SPEED|RADIUS|STAY_WITHIN_PARCEL|LENGTH|ORIENTATION|ACCOUNT_FOR_SKIPPED_FRAMES|AVOIDANCE_MODE|TYPE(?:_(?:[A-D]|NONE))?|MAX_(?:DECEL|TURN_RADIUS|(?:ACCEL|SPEED)))|PURSUIT_(?:OFFSET|FUZZ_FACTOR|GOAL_TOLERANCE|INTERCEPT)|REQUIRE_LINE_OF_SIGHT|FORCE_DIRECT_PATH|VERTICAL|HORIZONTAL|AVOID_(?:CHARACTERS|DYNAMIC_OBSTACLES|NONE)|PU_(?:EVADE_(?:HIDDEN|SPOTTED)|FAILURE_(?:DYNAMIC_PATHFINDING_DISABLED|INVALID_(?:GOAL|START)|NO_(?:NAVMESH|VALID_DESTINATION)|OTHER|TARGET_GONE|(?:PARCEL_)?UNREACHABLE)|(?:GOAL|SLOWDOWN_DISTANCE)_REACHED)|TRAVERSAL_TYPE(?:_(?:FAST|NONE|SLOW))?|CONTENT_TYPE_(?:ATOM|FORM|HTML|JSON|LLSD|RSS|TEXT|XHTML|XML)|GCNP_(?:RADIUS|STATIC)|(?:PATROL|WANDER)_PAUSE_AT_WAYPOINTS|OPT_(?:AVATAR|CHARACTER|EXCLUSION_VOLUME|LEGACY_LINKSET|MATERIAL_VOLUME|OTHER|STATIC_OBSTACLE|WALKABLE)|SIM_STAT_PCT_CHARS_STEPPED)\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
320 lsl_constants_integer_boolean = r'\b(?:FALSE|TRUE)\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
321 lsl_constants_rotation = r'\b(?:ZERO_ROTATION)\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
322 lsl_constants_string = r'\b(?:EOF|JSON_(?:ARRAY|DELETE|FALSE|INVALID|NULL|NUMBER|OBJECT|STRING|TRUE)|NULL_KEY|TEXTURE_(?:BLANK|DEFAULT|MEDIA|PLYWOOD|TRANSPARENT)|URL_REQUEST_(?:GRANTED|DENIED))\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
323 lsl_constants_vector = r'\b(?:TOUCH_INVALID_(?:TEXCOORD|VECTOR)|ZERO_VECTOR)\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
324 lsl_invalid_broken = r'\b(?:LAND_(?:LARGE|MEDIUM|SMALL)_BRUSH)\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
325 lsl_invalid_deprecated = r'\b(?:ATTACH_[LR]PEC|DATA_RATING|OBJECT_ATTACHMENT_(?:GEOMETRY_BYTES|SURFACE_AREA)|PRIM_(?:CAST_SHADOWS|MATERIAL_LIGHT|TYPE_LEGACY)|PSYS_SRC_(?:INNER|OUTER)ANGLE|VEHICLE_FLAG_NO_FLY_UP|ll(?:Cloud|Make(?:Explosion|Fountain|Smoke|Fire)|RemoteDataSetRegion|Sound(?:Preload)?|XorBase64Strings(?:Correct)?))\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
326 lsl_invalid_illegal = r'\b(?:event)\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
327 lsl_invalid_unimplemented = r'\b(?:CHARACTER_(?:MAX_ANGULAR_(?:ACCEL|SPEED)|TURN_SPEED_MULTIPLIER)|PERMISSION_(?:CHANGE_(?:JOINTS|PERMISSIONS)|RELEASE_OWNERSHIP|REMAP_CONTROLS)|PRIM_PHYSICS_MATERIAL|PSYS_SRC_OBJ_REL_MASK|ll(?:CollisionSprite|(?:Stop)?PointAt|(?:(?:Refresh|Set)Prim)URL|(?:Take|Release)Camera|RemoteLoadScript))\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
328 lsl_reserved_godmode = r'\b(?:ll(?:GodLikeRezObject|Set(?:Inventory|Object)PermMask))\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
329 lsl_reserved_log = r'\b(?:print)\b'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
330 lsl_operators = r'\+\+|\-\-|<<|>>|&&?|\|\|?|\^|~|[!%<>=*+\-/]=?'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
331
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
332 tokens = {
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
333 'root':
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
334 [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
335 (r'//.*?\n', Comment.Single),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
336 (r'/\*', Comment.Multiline, 'comment'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
337 (r'"', String.Double, 'string'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
338 (lsl_keywords, Keyword),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
339 (lsl_types, Keyword.Type),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
340 (lsl_states, Name.Class),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
341 (lsl_events, Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
342 (lsl_functions_builtin, Name.Function),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
343 (lsl_constants_float, Keyword.Constant),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
344 (lsl_constants_integer, Keyword.Constant),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
345 (lsl_constants_integer_boolean, Keyword.Constant),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
346 (lsl_constants_rotation, Keyword.Constant),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
347 (lsl_constants_string, Keyword.Constant),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
348 (lsl_constants_vector, Keyword.Constant),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
349 (lsl_invalid_broken, Error),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
350 (lsl_invalid_deprecated, Error),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
351 (lsl_invalid_illegal, Error),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
352 (lsl_invalid_unimplemented, Error),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
353 (lsl_reserved_godmode, Keyword.Reserved),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
354 (lsl_reserved_log, Keyword.Reserved),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
355 (r'\b([a-zA-Z_]\w*)\b', Name.Variable),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
356 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d*', Number.Float),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
357 (r'(\d+\.\d*|\.\d+)', Number.Float),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
358 (r'0[xX][0-9a-fA-F]+', Number.Hex),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
359 (r'\d+', Number.Integer),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
360 (lsl_operators, Operator),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
361 (r':=?', Error),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
362 (r'[,;{}()\[\]]', Punctuation),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
363 (r'\n+', Whitespace),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
364 (r'\s+', Whitespace)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
365 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
366 'comment':
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
367 [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
368 (r'[^*/]+', Comment.Multiline),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
369 (r'/\*', Comment.Multiline, '#push'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
370 (r'\*/', Comment.Multiline, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
371 (r'[*/]', Comment.Multiline)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
372 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
373 'string':
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
374 [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
375 (r'\\([nt"\\])', String.Escape),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
376 (r'"', String.Double, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
377 (r'\\.', Error),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
378 (r'[^"\\]+', String.Double),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
379 ]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
380 }
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
381
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
382
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
383 class AppleScriptLexer(RegexLexer):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
384 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
385 For `AppleScript source code
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
386 <http://developer.apple.com/documentation/AppleScript/
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
387 Conceptual/AppleScriptLangGuide>`_,
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
388 including `AppleScript Studio
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
389 <http://developer.apple.com/documentation/AppleScript/
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
390 Reference/StudioReference>`_.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
391 Contributed by Andreas Amann <aamann@mac.com>.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
392
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
393 .. versionadded:: 1.0
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
394 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
395
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
396 name = 'AppleScript'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
397 aliases = ['applescript']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
398 filenames = ['*.applescript']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
399
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
400 flags = re.MULTILINE | re.DOTALL
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
401
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
402 Identifiers = r'[a-zA-Z]\w*'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
403
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
404 # XXX: use words() for all of these
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
405 Literals = ('AppleScript', 'current application', 'false', 'linefeed',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
406 'missing value', 'pi', 'quote', 'result', 'return', 'space',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
407 'tab', 'text item delimiters', 'true', 'version')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
408 Classes = ('alias ', 'application ', 'boolean ', 'class ', 'constant ',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
409 'date ', 'file ', 'integer ', 'list ', 'number ', 'POSIX file ',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
410 'real ', 'record ', 'reference ', 'RGB color ', 'script ',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
411 'text ', 'unit types', '(?:Unicode )?text', 'string')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
412 BuiltIn = ('attachment', 'attribute run', 'character', 'day', 'month',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
413 'paragraph', 'word', 'year')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
414 HandlerParams = ('about', 'above', 'against', 'apart from', 'around',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
415 'aside from', 'at', 'below', 'beneath', 'beside',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
416 'between', 'for', 'given', 'instead of', 'on', 'onto',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
417 'out of', 'over', 'since')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
418 Commands = ('ASCII (character|number)', 'activate', 'beep', 'choose URL',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
419 'choose application', 'choose color', 'choose file( name)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
420 'choose folder', 'choose from list',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
421 'choose remote application', 'clipboard info',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
422 'close( access)?', 'copy', 'count', 'current date', 'delay',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
423 'delete', 'display (alert|dialog)', 'do shell script',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
424 'duplicate', 'exists', 'get eof', 'get volume settings',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
425 'info for', 'launch', 'list (disks|folder)', 'load script',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
426 'log', 'make', 'mount volume', 'new', 'offset',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
427 'open( (for access|location))?', 'path to', 'print', 'quit',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
428 'random number', 'read', 'round', 'run( script)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
429 'say', 'scripting components',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
430 'set (eof|the clipboard to|volume)', 'store script',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
431 'summarize', 'system attribute', 'system info',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
432 'the clipboard', 'time to GMT', 'write', 'quoted form')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
433 References = ('(in )?back of', '(in )?front of', '[0-9]+(st|nd|rd|th)',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
434 'first', 'second', 'third', 'fourth', 'fifth', 'sixth',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
435 'seventh', 'eighth', 'ninth', 'tenth', 'after', 'back',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
436 'before', 'behind', 'every', 'front', 'index', 'last',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
437 'middle', 'some', 'that', 'through', 'thru', 'where', 'whose')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
438 Operators = ("and", "or", "is equal", "equals", "(is )?equal to", "is not",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
439 "isn't", "isn't equal( to)?", "is not equal( to)?",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
440 "doesn't equal", "does not equal", "(is )?greater than",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
441 "comes after", "is not less than or equal( to)?",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
442 "isn't less than or equal( to)?", "(is )?less than",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
443 "comes before", "is not greater than or equal( to)?",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
444 "isn't greater than or equal( to)?",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
445 "(is )?greater than or equal( to)?", "is not less than",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
446 "isn't less than", "does not come before",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
447 "doesn't come before", "(is )?less than or equal( to)?",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
448 "is not greater than", "isn't greater than",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
449 "does not come after", "doesn't come after", "starts? with",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
450 "begins? with", "ends? with", "contains?", "does not contain",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
451 "doesn't contain", "is in", "is contained by", "is not in",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
452 "is not contained by", "isn't contained by", "div", "mod",
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
453 "not", "(a )?(ref( to)?|reference to)", "is", "does")
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
454 Control = ('considering', 'else', 'error', 'exit', 'from', 'if',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
455 'ignoring', 'in', 'repeat', 'tell', 'then', 'times', 'to',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
456 'try', 'until', 'using terms from', 'while', 'whith',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
457 'with timeout( of)?', 'with transaction', 'by', 'continue',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
458 'end', 'its?', 'me', 'my', 'return', 'of', 'as')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
459 Declarations = ('global', 'local', 'prop(erty)?', 'set', 'get')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
460 Reserved = ('but', 'put', 'returning', 'the')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
461 StudioClasses = ('action cell', 'alert reply', 'application', 'box',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
462 'browser( cell)?', 'bundle', 'button( cell)?', 'cell',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
463 'clip view', 'color well', 'color-panel',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
464 'combo box( item)?', 'control',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
465 'data( (cell|column|item|row|source))?', 'default entry',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
466 'dialog reply', 'document', 'drag info', 'drawer',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
467 'event', 'font(-panel)?', 'formatter',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
468 'image( (cell|view))?', 'matrix', 'menu( item)?', 'item',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
469 'movie( view)?', 'open-panel', 'outline view', 'panel',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
470 'pasteboard', 'plugin', 'popup button',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
471 'progress indicator', 'responder', 'save-panel',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
472 'scroll view', 'secure text field( cell)?', 'slider',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
473 'sound', 'split view', 'stepper', 'tab view( item)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
474 'table( (column|header cell|header view|view))',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
475 'text( (field( cell)?|view))?', 'toolbar( item)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
476 'user-defaults', 'view', 'window')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
477 StudioEvents = ('accept outline drop', 'accept table drop', 'action',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
478 'activated', 'alert ended', 'awake from nib', 'became key',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
479 'became main', 'begin editing', 'bounds changed',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
480 'cell value', 'cell value changed', 'change cell value',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
481 'change item value', 'changed', 'child of item',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
482 'choose menu item', 'clicked', 'clicked toolbar item',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
483 'closed', 'column clicked', 'column moved',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
484 'column resized', 'conclude drop', 'data representation',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
485 'deminiaturized', 'dialog ended', 'document nib name',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
486 'double clicked', 'drag( (entered|exited|updated))?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
487 'drop', 'end editing', 'exposed', 'idle', 'item expandable',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
488 'item value', 'item value changed', 'items changed',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
489 'keyboard down', 'keyboard up', 'launched',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
490 'load data representation', 'miniaturized', 'mouse down',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
491 'mouse dragged', 'mouse entered', 'mouse exited',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
492 'mouse moved', 'mouse up', 'moved',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
493 'number of browser rows', 'number of items',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
494 'number of rows', 'open untitled', 'opened', 'panel ended',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
495 'parameters updated', 'plugin loaded', 'prepare drop',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
496 'prepare outline drag', 'prepare outline drop',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
497 'prepare table drag', 'prepare table drop',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
498 'read from file', 'resigned active', 'resigned key',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
499 'resigned main', 'resized( sub views)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
500 'right mouse down', 'right mouse dragged',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
501 'right mouse up', 'rows changed', 'scroll wheel',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
502 'selected tab view item', 'selection changed',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
503 'selection changing', 'should begin editing',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
504 'should close', 'should collapse item',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
505 'should end editing', 'should expand item',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
506 'should open( untitled)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
507 'should quit( after last window closed)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
508 'should select column', 'should select item',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
509 'should select row', 'should select tab view item',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
510 'should selection change', 'should zoom', 'shown',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
511 'update menu item', 'update parameters',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
512 'update toolbar item', 'was hidden', 'was miniaturized',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
513 'will become active', 'will close', 'will dismiss',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
514 'will display browser cell', 'will display cell',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
515 'will display item cell', 'will display outline cell',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
516 'will finish launching', 'will hide', 'will miniaturize',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
517 'will move', 'will open', 'will pop up', 'will quit',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
518 'will resign active', 'will resize( sub views)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
519 'will select tab view item', 'will show', 'will zoom',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
520 'write to file', 'zoomed')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
521 StudioCommands = ('animate', 'append', 'call method', 'center',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
522 'close drawer', 'close panel', 'display',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
523 'display alert', 'display dialog', 'display panel', 'go',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
524 'hide', 'highlight', 'increment', 'item for',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
525 'load image', 'load movie', 'load nib', 'load panel',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
526 'load sound', 'localized string', 'lock focus', 'log',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
527 'open drawer', 'path for', 'pause', 'perform action',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
528 'play', 'register', 'resume', 'scroll', 'select( all)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
529 'show', 'size to fit', 'start', 'step back',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
530 'step forward', 'stop', 'synchronize', 'unlock focus',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
531 'update')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
532 StudioProperties = ('accepts arrow key', 'action method', 'active',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
533 'alignment', 'allowed identifiers',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
534 'allows branch selection', 'allows column reordering',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
535 'allows column resizing', 'allows column selection',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
536 'allows customization',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
537 'allows editing text attributes',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
538 'allows empty selection', 'allows mixed state',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
539 'allows multiple selection', 'allows reordering',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
540 'allows undo', 'alpha( value)?', 'alternate image',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
541 'alternate increment value', 'alternate title',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
542 'animation delay', 'associated file name',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
543 'associated object', 'auto completes', 'auto display',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
544 'auto enables items', 'auto repeat',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
545 'auto resizes( outline column)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
546 'auto save expanded items', 'auto save name',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
547 'auto save table columns', 'auto saves configuration',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
548 'auto scroll', 'auto sizes all columns to fit',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
549 'auto sizes cells', 'background color', 'bezel state',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
550 'bezel style', 'bezeled', 'border rect', 'border type',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
551 'bordered', 'bounds( rotation)?', 'box type',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
552 'button returned', 'button type',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
553 'can choose directories', 'can choose files',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
554 'can draw', 'can hide',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
555 'cell( (background color|size|type))?', 'characters',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
556 'class', 'click count', 'clicked( data)? column',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
557 'clicked data item', 'clicked( data)? row',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
558 'closeable', 'collating', 'color( (mode|panel))',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
559 'command key down', 'configuration',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
560 'content(s| (size|view( margins)?))?', 'context',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
561 'continuous', 'control key down', 'control size',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
562 'control tint', 'control view',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
563 'controller visible', 'coordinate system',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
564 'copies( on scroll)?', 'corner view', 'current cell',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
565 'current column', 'current( field)? editor',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
566 'current( menu)? item', 'current row',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
567 'current tab view item', 'data source',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
568 'default identifiers', 'delta (x|y|z)',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
569 'destination window', 'directory', 'display mode',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
570 'displayed cell', 'document( (edited|rect|view))?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
571 'double value', 'dragged column', 'dragged distance',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
572 'dragged items', 'draws( cell)? background',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
573 'draws grid', 'dynamically scrolls', 'echos bullets',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
574 'edge', 'editable', 'edited( data)? column',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
575 'edited data item', 'edited( data)? row', 'enabled',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
576 'enclosing scroll view', 'ending page',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
577 'error handling', 'event number', 'event type',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
578 'excluded from windows menu', 'executable path',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
579 'expanded', 'fax number', 'field editor', 'file kind',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
580 'file name', 'file type', 'first responder',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
581 'first visible column', 'flipped', 'floating',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
582 'font( panel)?', 'formatter', 'frameworks path',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
583 'frontmost', 'gave up', 'grid color', 'has data items',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
584 'has horizontal ruler', 'has horizontal scroller',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
585 'has parent data item', 'has resize indicator',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
586 'has shadow', 'has sub menu', 'has vertical ruler',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
587 'has vertical scroller', 'header cell', 'header view',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
588 'hidden', 'hides when deactivated', 'highlights by',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
589 'horizontal line scroll', 'horizontal page scroll',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
590 'horizontal ruler view', 'horizontally resizable',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
591 'icon image', 'id', 'identifier',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
592 'ignores multiple clicks',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
593 'image( (alignment|dims when disabled|frame style|scaling))?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
594 'imports graphics', 'increment value',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
595 'indentation per level', 'indeterminate', 'index',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
596 'integer value', 'intercell spacing', 'item height',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
597 'key( (code|equivalent( modifier)?|window))?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
598 'knob thickness', 'label', 'last( visible)? column',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
599 'leading offset', 'leaf', 'level', 'line scroll',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
600 'loaded', 'localized sort', 'location', 'loop mode',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
601 'main( (bunde|menu|window))?', 'marker follows cell',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
602 'matrix mode', 'maximum( content)? size',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
603 'maximum visible columns',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
604 'menu( form representation)?', 'miniaturizable',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
605 'miniaturized', 'minimized image', 'minimized title',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
606 'minimum column width', 'minimum( content)? size',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
607 'modal', 'modified', 'mouse down state',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
608 'movie( (controller|file|rect))?', 'muted', 'name',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
609 'needs display', 'next state', 'next text',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
610 'number of tick marks', 'only tick mark values',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
611 'opaque', 'open panel', 'option key down',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
612 'outline table column', 'page scroll', 'pages across',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
613 'pages down', 'palette label', 'pane splitter',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
614 'parent data item', 'parent window', 'pasteboard',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
615 'path( (names|separator))?', 'playing',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
616 'plays every frame', 'plays selection only', 'position',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
617 'preferred edge', 'preferred type', 'pressure',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
618 'previous text', 'prompt', 'properties',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
619 'prototype cell', 'pulls down', 'rate',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
620 'released when closed', 'repeated',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
621 'requested print time', 'required file type',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
622 'resizable', 'resized column', 'resource path',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
623 'returns records', 'reuses columns', 'rich text',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
624 'roll over', 'row height', 'rulers visible',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
625 'save panel', 'scripts path', 'scrollable',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
626 'selectable( identifiers)?', 'selected cell',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
627 'selected( data)? columns?', 'selected data items?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
628 'selected( data)? rows?', 'selected item identifier',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
629 'selection by rect', 'send action on arrow key',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
630 'sends action when done editing', 'separates columns',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
631 'separator item', 'sequence number', 'services menu',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
632 'shared frameworks path', 'shared support path',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
633 'sheet', 'shift key down', 'shows alpha',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
634 'shows state by', 'size( mode)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
635 'smart insert delete enabled', 'sort case sensitivity',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
636 'sort column', 'sort order', 'sort type',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
637 'sorted( data rows)?', 'sound', 'source( mask)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
638 'spell checking enabled', 'starting page', 'state',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
639 'string value', 'sub menu', 'super menu', 'super view',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
640 'tab key traverses cells', 'tab state', 'tab type',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
641 'tab view', 'table view', 'tag', 'target( printer)?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
642 'text color', 'text container insert',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
643 'text container origin', 'text returned',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
644 'tick mark position', 'time stamp',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
645 'title(d| (cell|font|height|position|rect))?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
646 'tool tip', 'toolbar', 'trailing offset', 'transparent',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
647 'treat packages as directories', 'truncated labels',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
648 'types', 'unmodified characters', 'update views',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
649 'use sort indicator', 'user defaults',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
650 'uses data source', 'uses ruler',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
651 'uses threaded animation',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
652 'uses title from previous column', 'value wraps',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
653 'version',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
654 'vertical( (line scroll|page scroll|ruler view))?',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
655 'vertically resizable', 'view',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
656 'visible( document rect)?', 'volume', 'width', 'window',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
657 'windows menu', 'wraps', 'zoomable', 'zoomed')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
658
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
659 tokens = {
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
660 'root': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
661 (r'\s+', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
662 (r'¬\n', String.Escape),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
663 (r"'s\s+", Text), # This is a possessive, consider moving
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
664 (r'(--|#).*?$', Comment),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
665 (r'\(\*', Comment.Multiline, 'comment'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
666 (r'[(){}!,.:]', Punctuation),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
667 (r'(«)([^»]+)(»)',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
668 bygroups(Text, Name.Builtin, Text)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
669 (r'\b((?:considering|ignoring)\s*)'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
670 r'(application responses|case|diacriticals|hyphens|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
671 r'numeric strings|punctuation|white space)',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
672 bygroups(Keyword, Name.Builtin)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
673 (r'(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\^)', Operator),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
674 (r"\b(%s)\b" % '|'.join(Operators), Operator.Word),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
675 (r'^(\s*(?:on|end)\s+)'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
676 r'(%s)' % '|'.join(StudioEvents[::-1]),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
677 bygroups(Keyword, Name.Function)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
678 (r'^(\s*)(in|on|script|to)(\s+)', bygroups(Text, Keyword, Text)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
679 (r'\b(as )(%s)\b' % '|'.join(Classes),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
680 bygroups(Keyword, Name.Class)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
681 (r'\b(%s)\b' % '|'.join(Literals), Name.Constant),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
682 (r'\b(%s)\b' % '|'.join(Commands), Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
683 (r'\b(%s)\b' % '|'.join(Control), Keyword),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
684 (r'\b(%s)\b' % '|'.join(Declarations), Keyword),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
685 (r'\b(%s)\b' % '|'.join(Reserved), Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
686 (r'\b(%s)s?\b' % '|'.join(BuiltIn), Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
687 (r'\b(%s)\b' % '|'.join(HandlerParams), Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
688 (r'\b(%s)\b' % '|'.join(StudioProperties), Name.Attribute),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
689 (r'\b(%s)s?\b' % '|'.join(StudioClasses), Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
690 (r'\b(%s)\b' % '|'.join(StudioCommands), Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
691 (r'\b(%s)\b' % '|'.join(References), Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
692 (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
693 (r'\b(%s)\b' % Identifiers, Name.Variable),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
694 (r'[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?', Number.Float),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
695 (r'[-+]?\d+', Number.Integer),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
696 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
697 'comment': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
698 (r'\(\*', Comment.Multiline, '#push'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
699 (r'\*\)', Comment.Multiline, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
700 ('[^*(]+', Comment.Multiline),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
701 ('[*(]', Comment.Multiline),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
702 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
703 }
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
704
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
705
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
706 class RexxLexer(RegexLexer):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
707 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
708 `Rexx <http://www.rexxinfo.org/>`_ is a scripting language available for
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
709 a wide range of different platforms with its roots found on mainframe
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
710 systems. It is popular for I/O- and data based tasks and can act as glue
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
711 language to bind different applications together.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
712
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
713 .. versionadded:: 2.0
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
714 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
715 name = 'Rexx'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
716 aliases = ['rexx', 'arexx']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
717 filenames = ['*.rexx', '*.rex', '*.rx', '*.arexx']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
718 mimetypes = ['text/x-rexx']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
719 flags = re.IGNORECASE
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
720
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
721 tokens = {
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
722 'root': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
723 (r'\s', Whitespace),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
724 (r'/\*', Comment.Multiline, 'comment'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
725 (r'"', String, 'string_double'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
726 (r"'", String, 'string_single'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
727 (r'[0-9]+(\.[0-9]+)?(e[+-]?[0-9])?', Number),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
728 (r'([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
729 bygroups(Name.Function, Whitespace, Operator, Whitespace,
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
730 Keyword.Declaration)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
731 (r'([a-z_]\w*)(\s*)(:)',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
732 bygroups(Name.Label, Whitespace, Operator)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
733 include('function'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
734 include('keyword'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
735 include('operator'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
736 (r'[a-z_]\w*', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
737 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
738 'function': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
739 (words((
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
740 'abbrev', 'abs', 'address', 'arg', 'b2x', 'bitand', 'bitor', 'bitxor',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
741 'c2d', 'c2x', 'center', 'charin', 'charout', 'chars', 'compare',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
742 'condition', 'copies', 'd2c', 'd2x', 'datatype', 'date', 'delstr',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
743 'delword', 'digits', 'errortext', 'form', 'format', 'fuzz', 'insert',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
744 'lastpos', 'left', 'length', 'linein', 'lineout', 'lines', 'max',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
745 'min', 'overlay', 'pos', 'queued', 'random', 'reverse', 'right', 'sign',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
746 'sourceline', 'space', 'stream', 'strip', 'substr', 'subword', 'symbol',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
747 'time', 'trace', 'translate', 'trunc', 'value', 'verify', 'word',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
748 'wordindex', 'wordlength', 'wordpos', 'words', 'x2b', 'x2c', 'x2d',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
749 'xrange'), suffix=r'(\s*)(\()'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
750 bygroups(Name.Builtin, Whitespace, Operator)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
751 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
752 'keyword': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
753 (r'(address|arg|by|call|do|drop|else|end|exit|for|forever|if|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
754 r'interpret|iterate|leave|nop|numeric|off|on|options|parse|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
755 r'pull|push|queue|return|say|select|signal|to|then|trace|until|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
756 r'while)\b', Keyword.Reserved),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
757 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
758 'operator': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
759 (r'(-|//|/|\(|\)|\*\*|\*|\\<<|\\<|\\==|\\=|\\>>|\\>|\\|\|\||\||'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
760 r'&&|&|%|\+|<<=|<<|<=|<>|<|==|=|><|>=|>>=|>>|>|¬<<|¬<|¬==|¬=|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
761 r'¬>>|¬>|¬|\.|,)', Operator),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
762 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
763 'string_double': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
764 (r'[^"\n]+', String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
765 (r'""', String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
766 (r'"', String, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
767 (r'\n', Text, '#pop'), # Stray linefeed also terminates strings.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
768 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
769 'string_single': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
770 (r'[^\'\n]', String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
771 (r'\'\'', String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
772 (r'\'', String, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
773 (r'\n', Text, '#pop'), # Stray linefeed also terminates strings.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
774 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
775 'comment': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
776 (r'[^*]+', Comment.Multiline),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
777 (r'\*/', Comment.Multiline, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
778 (r'\*', Comment.Multiline),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
779 ]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
780 }
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
781
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
782 _c = lambda s: re.compile(s, re.MULTILINE)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
783 _ADDRESS_COMMAND_PATTERN = _c(r'^\s*address\s+command\b')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
784 _ADDRESS_PATTERN = _c(r'^\s*address\s+')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
785 _DO_WHILE_PATTERN = _c(r'^\s*do\s+while\b')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
786 _IF_THEN_DO_PATTERN = _c(r'^\s*if\b.+\bthen\s+do\s*$')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
787 _PROCEDURE_PATTERN = _c(r'^\s*([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
788 _ELSE_DO_PATTERN = _c(r'\belse\s+do\s*$')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
789 _PARSE_ARG_PATTERN = _c(r'^\s*parse\s+(upper\s+)?(arg|value)\b')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
790 PATTERNS_AND_WEIGHTS = (
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
791 (_ADDRESS_COMMAND_PATTERN, 0.2),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
792 (_ADDRESS_PATTERN, 0.05),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
793 (_DO_WHILE_PATTERN, 0.1),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
794 (_ELSE_DO_PATTERN, 0.1),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
795 (_IF_THEN_DO_PATTERN, 0.1),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
796 (_PROCEDURE_PATTERN, 0.5),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
797 (_PARSE_ARG_PATTERN, 0.2),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
798 )
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
799
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
800 def analyse_text(text):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
801 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
802 Check for inital comment and patterns that distinguish Rexx from other
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
803 C-like languages.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
804 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
805 if re.search(r'/\*\**\s*rexx', text, re.IGNORECASE):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
806 # Header matches MVS Rexx requirements, this is certainly a Rexx
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
807 # script.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
808 return 1.0
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
809 elif text.startswith('/*'):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
810 # Header matches general Rexx requirements; the source code might
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
811 # still be any language using C comments such as C++, C# or Java.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
812 lowerText = text.lower()
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
813 result = sum(weight
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
814 for (pattern, weight) in RexxLexer.PATTERNS_AND_WEIGHTS
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
815 if pattern.search(lowerText)) + 0.01
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
816 return min(result, 1.0)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
817
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
818
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
819 class MOOCodeLexer(RegexLexer):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
820 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
821 For `MOOCode <http://www.moo.mud.org/>`_ (the MOO scripting
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
822 language).
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
823
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
824 .. versionadded:: 0.9
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
825 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
826 name = 'MOOCode'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
827 filenames = ['*.moo']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
828 aliases = ['moocode', 'moo']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
829 mimetypes = ['text/x-moocode']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
830
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
831 tokens = {
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
832 'root': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
833 # Numbers
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
834 (r'(0|[1-9][0-9_]*)', Number.Integer),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
835 # Strings
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
836 (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
837 # exceptions
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
838 (r'(E_PERM|E_DIV)', Name.Exception),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
839 # db-refs
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
840 (r'((#[-0-9]+)|(\$\w+))', Name.Entity),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
841 # Keywords
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
842 (r'\b(if|else|elseif|endif|for|endfor|fork|endfork|while'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
843 r'|endwhile|break|continue|return|try'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
844 r'|except|endtry|finally|in)\b', Keyword),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
845 # builtins
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
846 (r'(random|length)', Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
847 # special variables
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
848 (r'(player|caller|this|args)', Name.Variable.Instance),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
849 # skip whitespace
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
850 (r'\s+', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
851 (r'\n', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
852 # other operators
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
853 (r'([!;=,{}&|:.\[\]@()<>?]+)', Operator),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
854 # function call
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
855 (r'(\w+)(\()', bygroups(Name.Function, Operator)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
856 # variables
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
857 (r'(\w+)', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
858 ]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
859 }
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
860
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
861
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
862 class HybrisLexer(RegexLexer):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
863 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
864 For `Hybris <http://www.hybris-lang.org>`_ source code.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
865
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
866 .. versionadded:: 1.4
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
867 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
868
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
869 name = 'Hybris'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
870 aliases = ['hybris', 'hy']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
871 filenames = ['*.hy', '*.hyb']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
872 mimetypes = ['text/x-hybris', 'application/x-hybris']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
873
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
874 flags = re.MULTILINE | re.DOTALL
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
875
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
876 tokens = {
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
877 'root': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
878 # method names
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
879 (r'^(\s*(?:function|method|operator\s+)+?)'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
880 r'([a-zA-Z_]\w*)'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
881 r'(\s*)(\()', bygroups(Keyword, Name.Function, Text, Operator)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
882 (r'[^\S\n]+', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
883 (r'//.*?\n', Comment.Single),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
884 (r'/\*.*?\*/', Comment.Multiline),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
885 (r'@[a-zA-Z_][\w.]*', Name.Decorator),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
886 (r'(break|case|catch|next|default|do|else|finally|for|foreach|of|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
887 r'unless|if|new|return|switch|me|throw|try|while)\b', Keyword),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
888 (r'(extends|private|protected|public|static|throws|function|method|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
889 r'operator)\b', Keyword.Declaration),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
890 (r'(true|false|null|__FILE__|__LINE__|__VERSION__|__LIB_PATH__|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
891 r'__INC_PATH__)\b', Keyword.Constant),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
892 (r'(class|struct)(\s+)',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
893 bygroups(Keyword.Declaration, Text), 'class'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
894 (r'(import|include)(\s+)',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
895 bygroups(Keyword.Namespace, Text), 'import'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
896 (words((
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
897 'gc_collect', 'gc_mm_items', 'gc_mm_usage', 'gc_collect_threshold',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
898 'urlencode', 'urldecode', 'base64encode', 'base64decode', 'sha1', 'crc32',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
899 'sha2', 'md5', 'md5_file', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
900 'cosh', 'exp', 'fabs', 'floor', 'fmod', 'log', 'log10', 'pow', 'sin',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
901 'sinh', 'sqrt', 'tan', 'tanh', 'isint', 'isfloat', 'ischar', 'isstring',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
902 'isarray', 'ismap', 'isalias', 'typeof', 'sizeof', 'toint', 'tostring',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
903 'fromxml', 'toxml', 'binary', 'pack', 'load', 'eval', 'var_names',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
904 'var_values', 'user_functions', 'dyn_functions', 'methods', 'call',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
905 'call_method', 'mknod', 'mkfifo', 'mount', 'umount2', 'umount', 'ticks',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
906 'usleep', 'sleep', 'time', 'strtime', 'strdate', 'dllopen', 'dlllink',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
907 'dllcall', 'dllcall_argv', 'dllclose', 'env', 'exec', 'fork', 'getpid',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
908 'wait', 'popen', 'pclose', 'exit', 'kill', 'pthread_create',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
909 'pthread_create_argv', 'pthread_exit', 'pthread_join', 'pthread_kill',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
910 'smtp_send', 'http_get', 'http_post', 'http_download', 'socket', 'bind',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
911 'listen', 'accept', 'getsockname', 'getpeername', 'settimeout', 'connect',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
912 'server', 'recv', 'send', 'close', 'print', 'println', 'printf', 'input',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
913 'readline', 'serial_open', 'serial_fcntl', 'serial_get_attr',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
914 'serial_get_ispeed', 'serial_get_ospeed', 'serial_set_attr',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
915 'serial_set_ispeed', 'serial_set_ospeed', 'serial_write', 'serial_read',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
916 'serial_close', 'xml_load', 'xml_parse', 'fopen', 'fseek', 'ftell',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
917 'fsize', 'fread', 'fwrite', 'fgets', 'fclose', 'file', 'readdir',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
918 'pcre_replace', 'size', 'pop', 'unmap', 'has', 'keys', 'values',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
919 'length', 'find', 'substr', 'replace', 'split', 'trim', 'remove',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
920 'contains', 'join'), suffix=r'\b'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
921 Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
922 (words((
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
923 'MethodReference', 'Runner', 'Dll', 'Thread', 'Pipe', 'Process',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
924 'Runnable', 'CGI', 'ClientSocket', 'Socket', 'ServerSocket',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
925 'File', 'Console', 'Directory', 'Exception'), suffix=r'\b'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
926 Keyword.Type),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
927 (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
928 (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
929 (r'(\.)([a-zA-Z_]\w*)',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
930 bygroups(Operator, Name.Attribute)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
931 (r'[a-zA-Z_]\w*:', Name.Label),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
932 (r'[a-zA-Z_$]\w*', Name),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
933 (r'[~^*!%&\[\](){}<>|+=:;,./?\-@]+', Operator),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
934 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
935 (r'0x[0-9a-f]+', Number.Hex),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
936 (r'[0-9]+L?', Number.Integer),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
937 (r'\n', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
938 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
939 'class': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
940 (r'[a-zA-Z_]\w*', Name.Class, '#pop')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
941 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
942 'import': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
943 (r'[\w.]+\*?', Name.Namespace, '#pop')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
944 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
945 }
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
946
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
947 def analyse_text(text):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
948 """public method and private method don't seem to be quite common
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
949 elsewhere."""
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
950 result = 0
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
951 if re.search(r'\b(?:public|private)\s+method\b', text):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
952 result += 0.01
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
953 return result
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
954
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
955
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
956
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
957 class EasytrieveLexer(RegexLexer):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
958 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
959 Easytrieve Plus is a programming language for extracting, filtering and
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
960 converting sequential data. Furthermore it can layout data for reports.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
961 It is mainly used on mainframe platforms and can access several of the
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
962 mainframe's native file formats. It is somewhat comparable to awk.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
963
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
964 .. versionadded:: 2.1
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
965 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
966 name = 'Easytrieve'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
967 aliases = ['easytrieve']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
968 filenames = ['*.ezt', '*.mac']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
969 mimetypes = ['text/x-easytrieve']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
970 flags = 0
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
971
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
972 # Note: We cannot use r'\b' at the start and end of keywords because
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
973 # Easytrieve Plus delimiter characters are:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
974 #
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
975 # * space ( )
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
976 # * apostrophe (')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
977 # * period (.)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
978 # * comma (,)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
979 # * paranthesis ( and )
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
980 # * colon (:)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
981 #
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
982 # Additionally words end once a '*' appears, indicatins a comment.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
983 _DELIMITERS = r' \'.,():\n'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
984 _DELIMITERS_OR_COMENT = _DELIMITERS + '*'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
985 _DELIMITER_PATTERN = '[' + _DELIMITERS + ']'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
986 _DELIMITER_PATTERN_CAPTURE = '(' + _DELIMITER_PATTERN + ')'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
987 _NON_DELIMITER_OR_COMMENT_PATTERN = '[^' + _DELIMITERS_OR_COMENT + ']'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
988 _OPERATORS_PATTERN = '[.+\\-/=\\[\\](){}<>;,&%¬]'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
989 _KEYWORDS = [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
990 'AFTER-BREAK', 'AFTER-LINE', 'AFTER-SCREEN', 'AIM', 'AND', 'ATTR',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
991 'BEFORE', 'BEFORE-BREAK', 'BEFORE-LINE', 'BEFORE-SCREEN', 'BUSHU',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
992 'BY', 'CALL', 'CASE', 'CHECKPOINT', 'CHKP', 'CHKP-STATUS', 'CLEAR',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
993 'CLOSE', 'COL', 'COLOR', 'COMMIT', 'CONTROL', 'COPY', 'CURSOR', 'D',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
994 'DECLARE', 'DEFAULT', 'DEFINE', 'DELETE', 'DENWA', 'DISPLAY', 'DLI',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
995 'DO', 'DUPLICATE', 'E', 'ELSE', 'ELSE-IF', 'END', 'END-CASE',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
996 'END-DO', 'END-IF', 'END-PROC', 'ENDPAGE', 'ENDTABLE', 'ENTER', 'EOF',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
997 'EQ', 'ERROR', 'EXIT', 'EXTERNAL', 'EZLIB', 'F1', 'F10', 'F11', 'F12',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
998 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F2', 'F20', 'F21',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
999 'F22', 'F23', 'F24', 'F25', 'F26', 'F27', 'F28', 'F29', 'F3', 'F30',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1000 'F31', 'F32', 'F33', 'F34', 'F35', 'F36', 'F4', 'F5', 'F6', 'F7',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1001 'F8', 'F9', 'FETCH', 'FILE-STATUS', 'FILL', 'FINAL', 'FIRST',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1002 'FIRST-DUP', 'FOR', 'GE', 'GET', 'GO', 'GOTO', 'GQ', 'GR', 'GT',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1003 'HEADING', 'HEX', 'HIGH-VALUES', 'IDD', 'IDMS', 'IF', 'IN', 'INSERT',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1004 'JUSTIFY', 'KANJI-DATE', 'KANJI-DATE-LONG', 'KANJI-TIME', 'KEY',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1005 'KEY-PRESSED', 'KOKUGO', 'KUN', 'LAST-DUP', 'LE', 'LEVEL', 'LIKE',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1006 'LINE', 'LINE-COUNT', 'LINE-NUMBER', 'LINK', 'LIST', 'LOW-VALUES',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1007 'LQ', 'LS', 'LT', 'MACRO', 'MASK', 'MATCHED', 'MEND', 'MESSAGE',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1008 'MOVE', 'MSTART', 'NE', 'NEWPAGE', 'NOMASK', 'NOPRINT', 'NOT',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1009 'NOTE', 'NOVERIFY', 'NQ', 'NULL', 'OF', 'OR', 'OTHERWISE', 'PA1',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1010 'PA2', 'PA3', 'PAGE-COUNT', 'PAGE-NUMBER', 'PARM-REGISTER',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1011 'PATH-ID', 'PATTERN', 'PERFORM', 'POINT', 'POS', 'PRIMARY', 'PRINT',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1012 'PROCEDURE', 'PROGRAM', 'PUT', 'READ', 'RECORD', 'RECORD-COUNT',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1013 'RECORD-LENGTH', 'REFRESH', 'RELEASE', 'RENUM', 'REPEAT', 'REPORT',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1014 'REPORT-INPUT', 'RESHOW', 'RESTART', 'RETRIEVE', 'RETURN-CODE',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1015 'ROLLBACK', 'ROW', 'S', 'SCREEN', 'SEARCH', 'SECONDARY', 'SELECT',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1016 'SEQUENCE', 'SIZE', 'SKIP', 'SOKAKU', 'SORT', 'SQL', 'STOP', 'SUM',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1017 'SYSDATE', 'SYSDATE-LONG', 'SYSIN', 'SYSIPT', 'SYSLST', 'SYSPRINT',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1018 'SYSSNAP', 'SYSTIME', 'TALLY', 'TERM-COLUMNS', 'TERM-NAME',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1019 'TERM-ROWS', 'TERMINATION', 'TITLE', 'TO', 'TRANSFER', 'TRC',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1020 'UNIQUE', 'UNTIL', 'UPDATE', 'UPPERCASE', 'USER', 'USERID', 'VALUE',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1021 'VERIFY', 'W', 'WHEN', 'WHILE', 'WORK', 'WRITE', 'X', 'XDM', 'XRST'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1022 ]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1023
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1024 tokens = {
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1025 'root': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1026 (r'\*.*\n', Comment.Single),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1027 (r'\n+', Whitespace),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1028 # Macro argument
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1029 (r'&' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+\.', Name.Variable,
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1030 'after_macro_argument'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1031 # Macro call
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1032 (r'%' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name.Variable),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1033 (r'(FILE|MACRO|REPORT)(\s+)',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1034 bygroups(Keyword.Declaration, Whitespace), 'after_declaration'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1035 (r'(JOB|PARM)' + r'(' + _DELIMITER_PATTERN + r')',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1036 bygroups(Keyword.Declaration, Operator)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1037 (words(_KEYWORDS, suffix=_DELIMITER_PATTERN_CAPTURE),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1038 bygroups(Keyword.Reserved, Operator)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1039 (_OPERATORS_PATTERN, Operator),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1040 # Procedure declaration
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1041 (r'(' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+)(\s*)(\.?)(\s*)(PROC)(\s*\n)',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1042 bygroups(Name.Function, Whitespace, Operator, Whitespace,
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1043 Keyword.Declaration, Whitespace)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1044 (r'[0-9]+\.[0-9]*', Number.Float),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1045 (r'[0-9]+', Number.Integer),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1046 (r"'(''|[^'])*'", String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1047 (r'\s+', Whitespace),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1048 # Everything else just belongs to a name
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1049 (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1050 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1051 'after_declaration': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1052 (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name.Function),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1053 default('#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1054 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1055 'after_macro_argument': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1056 (r'\*.*\n', Comment.Single, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1057 (r'\s+', Whitespace, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1058 (_OPERATORS_PATTERN, Operator, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1059 (r"'(''|[^'])*'", String, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1060 # Everything else just belongs to a name
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1061 (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1062 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1063 }
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1064 _COMMENT_LINE_REGEX = re.compile(r'^\s*\*')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1065 _MACRO_HEADER_REGEX = re.compile(r'^\s*MACRO')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1066
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1067 def analyse_text(text):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1068 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1069 Perform a structural analysis for basic Easytrieve constructs.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1070 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1071 result = 0.0
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1072 lines = text.split('\n')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1073 hasEndProc = False
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1074 hasHeaderComment = False
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1075 hasFile = False
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1076 hasJob = False
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1077 hasProc = False
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1078 hasParm = False
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1079 hasReport = False
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1080
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1081 def isCommentLine(line):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1082 return EasytrieveLexer._COMMENT_LINE_REGEX.match(lines[0]) is not None
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1083
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1084 def isEmptyLine(line):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1085 return not bool(line.strip())
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1086
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1087 # Remove possible empty lines and header comments.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1088 while lines and (isEmptyLine(lines[0]) or isCommentLine(lines[0])):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1089 if not isEmptyLine(lines[0]):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1090 hasHeaderComment = True
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1091 del lines[0]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1092
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1093 if EasytrieveLexer._MACRO_HEADER_REGEX.match(lines[0]):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1094 # Looks like an Easytrieve macro.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1095 result = 0.4
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1096 if hasHeaderComment:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1097 result += 0.4
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1098 else:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1099 # Scan the source for lines starting with indicators.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1100 for line in lines:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1101 words = line.split()
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1102 if (len(words) >= 2):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1103 firstWord = words[0]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1104 if not hasReport:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1105 if not hasJob:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1106 if not hasFile:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1107 if not hasParm:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1108 if firstWord == 'PARM':
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1109 hasParm = True
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1110 if firstWord == 'FILE':
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1111 hasFile = True
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1112 if firstWord == 'JOB':
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1113 hasJob = True
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1114 elif firstWord == 'PROC':
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1115 hasProc = True
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1116 elif firstWord == 'END-PROC':
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1117 hasEndProc = True
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1118 elif firstWord == 'REPORT':
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1119 hasReport = True
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1120
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1121 # Weight the findings.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1122 if hasJob and (hasProc == hasEndProc):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1123 if hasHeaderComment:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1124 result += 0.1
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1125 if hasParm:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1126 if hasProc:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1127 # Found PARM, JOB and PROC/END-PROC:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1128 # pretty sure this is Easytrieve.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1129 result += 0.8
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1130 else:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1131 # Found PARAM and JOB: probably this is Easytrieve
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1132 result += 0.5
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1133 else:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1134 # Found JOB and possibly other keywords: might be Easytrieve
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1135 result += 0.11
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1136 if hasParm:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1137 # Note: PARAM is not a proper English word, so this is
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1138 # regarded a much better indicator for Easytrieve than
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1139 # the other words.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1140 result += 0.2
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1141 if hasFile:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1142 result += 0.01
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1143 if hasReport:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1144 result += 0.01
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1145 assert 0.0 <= result <= 1.0
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1146 return result
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1147
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1148
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1149 class JclLexer(RegexLexer):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1150 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1151 `Job Control Language (JCL)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1152 <http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IEA2B570/CCONTENTS>`_
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1153 is a scripting language used on mainframe platforms to instruct the system
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1154 on how to run a batch job or start a subsystem. It is somewhat
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1155 comparable to MS DOS batch and Unix shell scripts.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1156
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1157 .. versionadded:: 2.1
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1158 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1159 name = 'JCL'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1160 aliases = ['jcl']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1161 filenames = ['*.jcl']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1162 mimetypes = ['text/x-jcl']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1163 flags = re.IGNORECASE
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1164
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1165 tokens = {
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1166 'root': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1167 (r'//\*.*\n', Comment.Single),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1168 (r'//', Keyword.Pseudo, 'statement'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1169 (r'/\*', Keyword.Pseudo, 'jes2_statement'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1170 # TODO: JES3 statement
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1171 (r'.*\n', Other) # Input text or inline code in any language.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1172 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1173 'statement': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1174 (r'\s*\n', Whitespace, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1175 (r'([a-z]\w*)(\s+)(exec|job)(\s*)',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1176 bygroups(Name.Label, Whitespace, Keyword.Reserved, Whitespace),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1177 'option'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1178 (r'[a-z]\w*', Name.Variable, 'statement_command'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1179 (r'\s+', Whitespace, 'statement_command'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1180 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1181 'statement_command': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1182 (r'\s+(command|cntl|dd|endctl|endif|else|include|jcllib|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1183 r'output|pend|proc|set|then|xmit)\s+', Keyword.Reserved, 'option'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1184 include('option')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1185 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1186 'jes2_statement': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1187 (r'\s*\n', Whitespace, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1188 (r'\$', Keyword, 'option'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1189 (r'\b(jobparam|message|netacct|notify|output|priority|route|'
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1190 r'setup|signoff|xeq|xmit)\b', Keyword, 'option'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1191 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1192 'option': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1193 # (r'\n', Text, 'root'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1194 (r'\*', Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1195 (r'[\[\](){}<>;,]', Punctuation),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1196 (r'[-+*/=&%]', Operator),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1197 (r'[a-z_]\w*', Name),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1198 (r'\d+\.\d*', Number.Float),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1199 (r'\.\d+', Number.Float),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1200 (r'\d+', Number.Integer),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1201 (r"'", String, 'option_string'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1202 (r'[ \t]+', Whitespace, 'option_comment'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1203 (r'\.', Punctuation),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1204 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1205 'option_string': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1206 (r"(\n)(//)", bygroups(Text, Keyword.Pseudo)),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1207 (r"''", String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1208 (r"[^']", String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1209 (r"'", String, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1210 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1211 'option_comment': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1212 # (r'\n', Text, 'root'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1213 (r'.+', Comment.Single),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1214 ]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1215 }
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1216
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1217 _JOB_HEADER_PATTERN = re.compile(r'^//[a-z#$@][a-z0-9#$@]{0,7}\s+job(\s+.*)?$',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1218 re.IGNORECASE)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1219
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1220 def analyse_text(text):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1221 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1222 Recognize JCL job by header.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1223 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1224 result = 0.0
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1225 lines = text.split('\n')
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1226 if len(lines) > 0:
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1227 if JclLexer._JOB_HEADER_PATTERN.match(lines[0]):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1228 result = 1.0
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1229 assert 0.0 <= result <= 1.0
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1230 return result
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1231
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1232
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1233 class MiniScriptLexer(RegexLexer):
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1234 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1235 For `MiniScript <https://miniscript.org>`_ source code.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1236
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1237 .. versionadded:: 2.6
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1238 """
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1239
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1240 name = "MiniScript"
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1241 aliases = ["ms", "miniscript"]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1242 filenames = ["*.ms"]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1243 mimetypes = ['text/x-minicript', 'application/x-miniscript']
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1244
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1245 tokens = {
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1246 'root': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1247 (r'#!(.*?)$', Comment.Preproc),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1248 default('base'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1249 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1250 'base': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1251 ('//.*$', Comment.Single),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1252 (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1253 (r'(?i)\d+e[+-]?\d+', Number),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1254 (r'\d+', Number),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1255 (r'\n', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1256 (r'[^\S\n]+', Text),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1257 (r'"', String, 'string_double'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1258 (r'(==|!=|<=|>=|[=+\-*/%^<>.:])', Operator),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1259 (r'[;,\[\]{}()]', Punctuation),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1260 (words((
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1261 'break', 'continue', 'else', 'end', 'for', 'function', 'if',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1262 'in', 'isa', 'then', 'repeat', 'return', 'while'), suffix=r'\b'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1263 Keyword),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1264 (words((
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1265 'abs', 'acos', 'asin', 'atan', 'ceil', 'char', 'cos', 'floor',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1266 'log', 'round', 'rnd', 'pi', 'sign', 'sin', 'sqrt', 'str', 'tan',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1267 'hasIndex', 'indexOf', 'len', 'val', 'code', 'remove', 'lower',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1268 'upper', 'replace', 'split', 'indexes', 'values', 'join', 'sum',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1269 'sort', 'shuffle', 'push', 'pop', 'pull', 'range',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1270 'print', 'input', 'time', 'wait', 'locals', 'globals', 'outer',
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1271 'yield'), suffix=r'\b'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1272 Name.Builtin),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1273 (r'(true|false|null)\b', Keyword.Constant),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1274 (r'(and|or|not|new)\b', Operator.Word),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1275 (r'(self|super|__isa)\b', Name.Builtin.Pseudo),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1276 (r'[a-zA-Z_]\w*', Name.Variable)
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1277 ],
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1278 'string_double': [
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1279 (r'[^"\n]+', String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1280 (r'""', String),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1281 (r'"', String, '#pop'),
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1282 (r'\n', Text, '#pop'), # Stray linefeed also terminates strings.
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1283 ]
54c5cfbb1e29 Third Party packages
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7701
diff changeset
1284 }

eric ide

mercurial