rapydscript-ns 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agignore +1 -1
- package/.github/workflows/ci.yml +38 -38
- package/=template.pyj +5 -5
- package/CHANGELOG.md +9 -0
- package/HACKING.md +103 -103
- package/LICENSE +24 -24
- package/PYTHON_GAPS.md +48 -116
- package/README.md +35 -15
- package/TODO.md +1 -26
- package/add-toc-to-readme +2 -2
- package/bin/export +75 -75
- package/bin/rapydscript +0 -0
- package/bin/web-repl-export +102 -102
- package/build +2 -2
- package/language-service/index.js +9 -7
- package/package.json +1 -1
- package/publish.py +37 -37
- package/session.vim +4 -4
- package/setup.cfg +2 -2
- package/src/ast.pyj +6 -0
- package/src/baselib-containers.pyj +23 -1
- package/src/baselib-str.pyj +13 -2
- package/src/compiler.pyj +36 -36
- package/src/errors.pyj +30 -30
- package/src/lib/aes.pyj +646 -646
- package/src/lib/collections.pyj +227 -3
- package/src/lib/copy.pyj +120 -120
- package/src/lib/elementmaker.pyj +83 -83
- package/src/lib/encodings.pyj +126 -126
- package/src/lib/gettext.pyj +569 -569
- package/src/lib/itertools.pyj +580 -580
- package/src/lib/math.pyj +193 -193
- package/src/lib/operator.pyj +11 -11
- package/src/lib/pprint.pyj +455 -0
- package/src/lib/random.pyj +118 -118
- package/src/lib/react.pyj +74 -74
- package/src/lib/statistics.pyj +0 -0
- package/src/lib/traceback.pyj +63 -63
- package/src/lib/uuid.pyj +77 -77
- package/src/monaco-language-service/diagnostics.js +2 -2
- package/src/monaco-language-service/dts.js +550 -550
- package/src/output/codegen.pyj +4 -1
- package/src/output/comments.pyj +45 -45
- package/src/output/exceptions.pyj +201 -201
- package/src/output/jsx.pyj +164 -164
- package/src/output/treeshake.pyj +182 -182
- package/src/output/utils.pyj +72 -72
- package/src/parse.pyj +28 -7
- package/src/string_interpolation.pyj +72 -72
- package/src/tokenizer.pyj +18 -2
- package/src/unicode_aliases.pyj +576 -576
- package/src/utils.pyj +192 -192
- package/test/_import_one.pyj +37 -37
- package/test/_import_two/__init__.pyj +11 -11
- package/test/_import_two/level2/deep.pyj +4 -4
- package/test/_import_two/other.pyj +6 -6
- package/test/_import_two/sub.pyj +13 -13
- package/test/aes_vectors.pyj +421 -421
- package/test/annotations.pyj +80 -80
- package/test/baselib.pyj +23 -0
- package/test/chainmap.pyj +185 -0
- package/test/decorators.pyj +77 -77
- package/test/docstrings.pyj +39 -39
- package/test/elementmaker_test.pyj +45 -45
- package/test/functions.pyj +151 -151
- package/test/generators.pyj +41 -41
- package/test/generic.pyj +370 -370
- package/test/internationalization.pyj +73 -73
- package/test/lint.pyj +164 -164
- package/test/loops.pyj +85 -85
- package/test/numpy.pyj +734 -734
- package/test/pprint.pyj +232 -0
- package/test/repl.pyj +121 -121
- package/test/scoped_flags.pyj +76 -76
- package/test/statistics.pyj +224 -0
- package/test/unit/index.js +80 -0
- package/test/unit/language-service-completions.js +2 -0
- package/test/unit/language-service-dts.js +543 -543
- package/test/unit/language-service-hover.js +455 -455
- package/test/unit/language-service.js +63 -2
- package/test/unit/web-repl.js +323 -0
- package/tools/compiler.d.ts +367 -367
- package/tools/completer.js +131 -131
- package/tools/export.js +4 -2
- package/tools/gettext.js +185 -185
- package/tools/ini.js +65 -65
- package/tools/msgfmt.js +187 -187
- package/tools/repl.js +223 -223
- package/tools/test.js +118 -118
- package/tools/utils.js +128 -128
- package/tools/web_repl.js +95 -95
- package/try +41 -41
- package/web-repl/env.js +196 -196
- package/web-repl/index.html +163 -163
- package/web-repl/prism.css +139 -139
- package/web-repl/prism.js +113 -113
- package/web-repl/rapydscript.js +228 -226
- package/web-repl/sha1.js +25 -25
package/package.json
CHANGED
package/publish.py
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# vim:fileencoding=utf-8
|
|
3
|
-
# License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
|
4
|
-
|
|
5
|
-
import subprocess
|
|
6
|
-
import os
|
|
7
|
-
import shutil
|
|
8
|
-
import json
|
|
9
|
-
|
|
10
|
-
# Load metadata
|
|
11
|
-
base = os.path.dirname(os.path.abspath(__file__))
|
|
12
|
-
subprocess.check_call([os.path.join(base, 'build')])
|
|
13
|
-
with open('package.json', 'rb') as f:
|
|
14
|
-
m = json.load(f)
|
|
15
|
-
version = m['version']
|
|
16
|
-
|
|
17
|
-
# Update the files in release/ from dev/
|
|
18
|
-
shutil.rmtree(os.path.join(base, 'release'))
|
|
19
|
-
shutil.copytree(os.path.join(base, 'dev'), os.path.join(base, 'release'))
|
|
20
|
-
subprocess.check_call(['git', 'add', os.path.join(base, 'release')])
|
|
21
|
-
if subprocess.check_output(
|
|
22
|
-
'git status --porcelain --untracked-files release'.split()).strip():
|
|
23
|
-
subprocess.check_call([
|
|
24
|
-
'git', 'commit', '-m', 'Updating release build of compiler'])
|
|
25
|
-
subprocess.check_call('git push'.split())
|
|
26
|
-
|
|
27
|
-
# Tag the release
|
|
28
|
-
subprocess.check_call('git tag -s v{0} -m version-{0}'.format(version).split())
|
|
29
|
-
subprocess.check_call(['git', 'push', 'origin', 'v'+version])
|
|
30
|
-
|
|
31
|
-
# Update the web REPL
|
|
32
|
-
gh_pages = os.path.join(os.path.dirname(base), 'kovidgoyal.github.io')
|
|
33
|
-
subprocess.check_call([os.path.join(gh_pages, 'update-rapyd-repl.py')])
|
|
34
|
-
|
|
35
|
-
# Publish to NPM
|
|
36
|
-
subprocess.check_call(['npm', 'login'])
|
|
37
|
-
subprocess.check_call(['npm', 'publish', base])
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# vim:fileencoding=utf-8
|
|
3
|
+
# License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
|
4
|
+
|
|
5
|
+
import subprocess
|
|
6
|
+
import os
|
|
7
|
+
import shutil
|
|
8
|
+
import json
|
|
9
|
+
|
|
10
|
+
# Load metadata
|
|
11
|
+
base = os.path.dirname(os.path.abspath(__file__))
|
|
12
|
+
subprocess.check_call([os.path.join(base, 'build')])
|
|
13
|
+
with open('package.json', 'rb') as f:
|
|
14
|
+
m = json.load(f)
|
|
15
|
+
version = m['version']
|
|
16
|
+
|
|
17
|
+
# Update the files in release/ from dev/
|
|
18
|
+
shutil.rmtree(os.path.join(base, 'release'))
|
|
19
|
+
shutil.copytree(os.path.join(base, 'dev'), os.path.join(base, 'release'))
|
|
20
|
+
subprocess.check_call(['git', 'add', os.path.join(base, 'release')])
|
|
21
|
+
if subprocess.check_output(
|
|
22
|
+
'git status --porcelain --untracked-files release'.split()).strip():
|
|
23
|
+
subprocess.check_call([
|
|
24
|
+
'git', 'commit', '-m', 'Updating release build of compiler'])
|
|
25
|
+
subprocess.check_call('git push'.split())
|
|
26
|
+
|
|
27
|
+
# Tag the release
|
|
28
|
+
subprocess.check_call('git tag -s v{0} -m version-{0}'.format(version).split())
|
|
29
|
+
subprocess.check_call(['git', 'push', 'origin', 'v'+version])
|
|
30
|
+
|
|
31
|
+
# Update the web REPL
|
|
32
|
+
gh_pages = os.path.join(os.path.dirname(base), 'kovidgoyal.github.io')
|
|
33
|
+
subprocess.check_call([os.path.join(gh_pages, 'update-rapyd-repl.py')])
|
|
34
|
+
|
|
35
|
+
# Publish to NPM
|
|
36
|
+
subprocess.check_call(['npm', 'login'])
|
|
37
|
+
subprocess.check_call(['npm', 'publish', base])
|
package/session.vim
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
set wildignore+=*.pyj-cached
|
|
2
|
-
set wildignore+=node_modules
|
|
3
|
-
imap <F4> ρσ_
|
|
4
|
-
cmap <F4> ρσ_
|
|
1
|
+
set wildignore+=*.pyj-cached
|
|
2
|
+
set wildignore+=node_modules
|
|
3
|
+
imap <F4> ρσ_
|
|
4
|
+
cmap <F4> ρσ_
|
package/setup.cfg
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[rapydscript]
|
|
2
|
-
globals=assert,RapydScript
|
|
1
|
+
[rapydscript]
|
|
2
|
+
globals=assert,RapydScript
|
package/src/ast.pyj
CHANGED
|
@@ -1280,6 +1280,12 @@ class AST_Number(AST_Constant):
|
|
|
1280
1280
|
'value': "[number] the numeric value"
|
|
1281
1281
|
}
|
|
1282
1282
|
|
|
1283
|
+
class AST_BigInt(AST_Constant):
|
|
1284
|
+
"A BigInt literal (e.g. 42n)"
|
|
1285
|
+
properties = {
|
|
1286
|
+
'value': "[string] the raw numeric string (without n suffix)"
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1283
1289
|
class AST_RegExp(AST_Constant):
|
|
1284
1290
|
"A regexp literal"
|
|
1285
1291
|
properties = {
|
|
@@ -122,9 +122,22 @@ def ρσ_list_sort_key(value):
|
|
|
122
122
|
t = jstype(value)
|
|
123
123
|
if t is 'string' or t is 'number':
|
|
124
124
|
return value
|
|
125
|
+
# Keep objects that define __lt__ unchanged so ρσ_list_sort_cmp can
|
|
126
|
+
# dispatch the dunder; everything else falls back to a string key.
|
|
127
|
+
if value is not None and value is not undefined and jstype(value.__lt__) is 'function':
|
|
128
|
+
return value
|
|
125
129
|
return value.toString()
|
|
126
130
|
|
|
127
131
|
def ρσ_list_sort_cmp(a, b, ap, bp):
|
|
132
|
+
# When the elements define __lt__, order them the Pythonic way via
|
|
133
|
+
# ρσ_op_lt (which also handles a reflected __gt__); otherwise compare
|
|
134
|
+
# the precomputed primitive keys directly.
|
|
135
|
+
if a is not None and a is not undefined and jstype(a.__lt__) is 'function':
|
|
136
|
+
if ρσ_op_lt(a, b):
|
|
137
|
+
return -1
|
|
138
|
+
if ρσ_op_lt(b, a):
|
|
139
|
+
return 1
|
|
140
|
+
return ap - bp
|
|
128
141
|
if a < b:
|
|
129
142
|
return -1
|
|
130
143
|
if a > b:
|
|
@@ -132,8 +145,17 @@ def ρσ_list_sort_cmp(a, b, ap, bp):
|
|
|
132
145
|
return ap - bp
|
|
133
146
|
|
|
134
147
|
def ρσ_list_sort(key=None, reverse=False):
|
|
135
|
-
key = key or ρσ_list_sort_key
|
|
136
148
|
mult = -1 if reverse else 1
|
|
149
|
+
if key is not None and key is not undefined and jstype(key) is 'function' and key.length is 2:
|
|
150
|
+
# A two-argument function is treated as a comparator (à la
|
|
151
|
+
# functools.cmp_to_key) rather than a key function, so a JS-style
|
|
152
|
+
# `.sort((a, b) => ...)` callback works as expected.
|
|
153
|
+
cmpposmap = dict()
|
|
154
|
+
for v'var i=0; i < this.length; i++':
|
|
155
|
+
cmpposmap.set(this[i], i) # noqa:undef
|
|
156
|
+
Array.prototype.sort.call(this, def (a, b): return (mult * key(a, b)) or (cmpposmap.get(a) - cmpposmap.get(b));)
|
|
157
|
+
return
|
|
158
|
+
key = key or ρσ_list_sort_key
|
|
137
159
|
keymap = dict()
|
|
138
160
|
posmap = dict()
|
|
139
161
|
for v'var i=0; i < this.length; i++':
|
package/src/baselib-str.pyj
CHANGED
|
@@ -111,8 +111,19 @@ define_str_func = def(name, func):
|
|
|
111
111
|
if func.__argnames__:
|
|
112
112
|
Object.defineProperty(f, '__argnames__', {'value':v"['string']".concat(func.__argnames__)})
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
# Guard against multiple evaluations of the baselib in the same JS context
|
|
115
|
+
# (e.g. web_repl()/create_compiler() being called repeatedly). Without this,
|
|
116
|
+
# each eval captures the PREVIOUS patched String.prototype.split as ρσ_orig_split,
|
|
117
|
+
# creating a chain that eventually overflows the call stack.
|
|
118
|
+
if v'typeof globalThis !== "undefined" && globalThis._ρσ_orig_split':
|
|
119
|
+
ρσ_orig_split = v'globalThis._ρσ_orig_split'
|
|
120
|
+
ρσ_orig_replace = v'globalThis._ρσ_orig_replace'
|
|
121
|
+
else:
|
|
122
|
+
ρσ_orig_split = String.prototype.split.call.bind(String.prototype.split)
|
|
123
|
+
ρσ_orig_replace = String.prototype.replace.call.bind(String.prototype.replace)
|
|
124
|
+
if v'typeof globalThis !== "undefined"':
|
|
125
|
+
v'globalThis._ρσ_orig_split = ρσ_orig_split'
|
|
126
|
+
v'globalThis._ρσ_orig_replace = ρσ_orig_replace'
|
|
116
127
|
|
|
117
128
|
# format() {{{
|
|
118
129
|
define_str_func('format', def ():
|
package/src/compiler.pyj
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
# vim:fileencoding=utf-8
|
|
2
|
-
# License: BSD
|
|
3
|
-
# Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
|
4
|
-
# globals: console
|
|
5
|
-
|
|
6
|
-
from utils import DefaultsError, string_template
|
|
7
|
-
from errors import ImportError, SyntaxError
|
|
8
|
-
from tokenizer import ALL_KEYWORDS, IDENTIFIER_PAT, tokenizer
|
|
9
|
-
from parse import parse, NATIVE_CLASSES, compile_time_decorators
|
|
10
|
-
from output.stream import OutputStream
|
|
11
|
-
from output.codegen import generate_code
|
|
12
|
-
from output.treeshake import tree_shake
|
|
13
|
-
|
|
14
|
-
generate_code() # create the print methods on the AST nodes
|
|
15
|
-
|
|
16
|
-
# The following allows this module to be used from a pure javascript, require()
|
|
17
|
-
# based environment like Node.js
|
|
18
|
-
if jstype(exports) is 'object':
|
|
19
|
-
exports.DefaultsError = DefaultsError
|
|
20
|
-
exports.parse = parse
|
|
21
|
-
exports.compile_time_decorators = compile_time_decorators
|
|
22
|
-
exports.OutputStream = OutputStream
|
|
23
|
-
exports.string_template = string_template # noqa:undef
|
|
24
|
-
# Needed for REPL and linter
|
|
25
|
-
exports.ALL_KEYWORDS = ALL_KEYWORDS
|
|
26
|
-
exports.IDENTIFIER_PAT = IDENTIFIER_PAT
|
|
27
|
-
exports.NATIVE_CLASSES = NATIVE_CLASSES
|
|
28
|
-
exports.ImportError = ImportError
|
|
29
|
-
exports.SyntaxError = SyntaxError
|
|
30
|
-
exports.tokenizer = tokenizer
|
|
31
|
-
exports.tree_shake = tree_shake
|
|
32
|
-
# Magic! Export all the AST_* nodes
|
|
33
|
-
ast = ρσ_modules['ast']
|
|
34
|
-
for ast_node in ast:
|
|
35
|
-
if ast_node.substr(0, 4) is 'AST_':
|
|
36
|
-
exports[ast_node] = ast[ast_node] # noqa:undef
|
|
1
|
+
# vim:fileencoding=utf-8
|
|
2
|
+
# License: BSD
|
|
3
|
+
# Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
|
4
|
+
# globals: console
|
|
5
|
+
|
|
6
|
+
from utils import DefaultsError, string_template
|
|
7
|
+
from errors import ImportError, SyntaxError
|
|
8
|
+
from tokenizer import ALL_KEYWORDS, IDENTIFIER_PAT, tokenizer
|
|
9
|
+
from parse import parse, NATIVE_CLASSES, compile_time_decorators
|
|
10
|
+
from output.stream import OutputStream
|
|
11
|
+
from output.codegen import generate_code
|
|
12
|
+
from output.treeshake import tree_shake
|
|
13
|
+
|
|
14
|
+
generate_code() # create the print methods on the AST nodes
|
|
15
|
+
|
|
16
|
+
# The following allows this module to be used from a pure javascript, require()
|
|
17
|
+
# based environment like Node.js
|
|
18
|
+
if jstype(exports) is 'object':
|
|
19
|
+
exports.DefaultsError = DefaultsError
|
|
20
|
+
exports.parse = parse
|
|
21
|
+
exports.compile_time_decorators = compile_time_decorators
|
|
22
|
+
exports.OutputStream = OutputStream
|
|
23
|
+
exports.string_template = string_template # noqa:undef
|
|
24
|
+
# Needed for REPL and linter
|
|
25
|
+
exports.ALL_KEYWORDS = ALL_KEYWORDS
|
|
26
|
+
exports.IDENTIFIER_PAT = IDENTIFIER_PAT
|
|
27
|
+
exports.NATIVE_CLASSES = NATIVE_CLASSES
|
|
28
|
+
exports.ImportError = ImportError
|
|
29
|
+
exports.SyntaxError = SyntaxError
|
|
30
|
+
exports.tokenizer = tokenizer
|
|
31
|
+
exports.tree_shake = tree_shake
|
|
32
|
+
# Magic! Export all the AST_* nodes
|
|
33
|
+
ast = ρσ_modules['ast']
|
|
34
|
+
for ast_node in ast:
|
|
35
|
+
if ast_node.substr(0, 4) is 'AST_':
|
|
36
|
+
exports[ast_node] = ast[ast_node] # noqa:undef
|
package/src/errors.pyj
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
# vim:fileencoding=utf-8
|
|
2
|
-
# License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
|
3
|
-
from __python__ import hash_literals
|
|
4
|
-
|
|
5
|
-
class SyntaxError(Error):
|
|
6
|
-
|
|
7
|
-
def __init__(self, message, filename, line, col, pos, is_eof):
|
|
8
|
-
self.stack = Error().stack
|
|
9
|
-
self.message = message
|
|
10
|
-
self.line = line
|
|
11
|
-
self.col = col
|
|
12
|
-
self.pos = pos
|
|
13
|
-
self.is_eof = is_eof
|
|
14
|
-
self.filename = filename
|
|
15
|
-
# The "standard" form for these error attributes
|
|
16
|
-
self.lineNumber = line
|
|
17
|
-
self.fileName = filename
|
|
18
|
-
|
|
19
|
-
def toString(self):
|
|
20
|
-
ans = self.message + " (line: " + self.line + ", col: " + self.col + ", pos: " + self.pos + ")"
|
|
21
|
-
if self.filename:
|
|
22
|
-
ans = self.filename + ':' + ans
|
|
23
|
-
if self.stack:
|
|
24
|
-
ans += "\n\n" + self.stack
|
|
25
|
-
return ans
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class ImportError(SyntaxError):
|
|
29
|
-
pass
|
|
30
|
-
|
|
1
|
+
# vim:fileencoding=utf-8
|
|
2
|
+
# License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
|
3
|
+
from __python__ import hash_literals
|
|
4
|
+
|
|
5
|
+
class SyntaxError(Error):
|
|
6
|
+
|
|
7
|
+
def __init__(self, message, filename, line, col, pos, is_eof):
|
|
8
|
+
self.stack = Error().stack
|
|
9
|
+
self.message = message
|
|
10
|
+
self.line = line
|
|
11
|
+
self.col = col
|
|
12
|
+
self.pos = pos
|
|
13
|
+
self.is_eof = is_eof
|
|
14
|
+
self.filename = filename
|
|
15
|
+
# The "standard" form for these error attributes
|
|
16
|
+
self.lineNumber = line
|
|
17
|
+
self.fileName = filename
|
|
18
|
+
|
|
19
|
+
def toString(self):
|
|
20
|
+
ans = self.message + " (line: " + self.line + ", col: " + self.col + ", pos: " + self.pos + ")"
|
|
21
|
+
if self.filename:
|
|
22
|
+
ans = self.filename + ':' + ans
|
|
23
|
+
if self.stack:
|
|
24
|
+
ans += "\n\n" + self.stack
|
|
25
|
+
return ans
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ImportError(SyntaxError):
|
|
29
|
+
pass
|
|
30
|
+
|