rapydscript-ns 0.8.0
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 -0
- package/.gitattributes +4 -0
- package/.github/workflows/ci.yml +38 -0
- package/.github/workflows/web-repl-page-deploy.yml +42 -0
- package/=template.pyj +5 -0
- package/CHANGELOG.md +456 -0
- package/CONTRIBUTORS +13 -0
- package/HACKING.md +103 -0
- package/LICENSE +24 -0
- package/README.md +2512 -0
- package/TODO.md +327 -0
- package/add-toc-to-readme +2 -0
- package/bin/export +75 -0
- package/bin/rapydscript +70 -0
- package/bin/web-repl-export +102 -0
- package/build +3 -0
- package/package.json +46 -0
- package/publish.py +37 -0
- package/release/baselib-plain-pretty.js +4370 -0
- package/release/baselib-plain-ugly.js +3 -0
- package/release/compiler.js +18394 -0
- package/release/signatures.json +31 -0
- package/session.vim +4 -0
- package/setup.cfg +2 -0
- package/src/ast.pyj +1356 -0
- package/src/baselib-builtins.pyj +279 -0
- package/src/baselib-containers.pyj +723 -0
- package/src/baselib-errors.pyj +37 -0
- package/src/baselib-internal.pyj +421 -0
- package/src/baselib-itertools.pyj +97 -0
- package/src/baselib-str.pyj +798 -0
- package/src/compiler.pyj +36 -0
- package/src/errors.pyj +30 -0
- package/src/lib/aes.pyj +646 -0
- package/src/lib/collections.pyj +695 -0
- package/src/lib/elementmaker.pyj +83 -0
- package/src/lib/encodings.pyj +126 -0
- package/src/lib/functools.pyj +148 -0
- package/src/lib/gettext.pyj +569 -0
- package/src/lib/itertools.pyj +580 -0
- package/src/lib/math.pyj +193 -0
- package/src/lib/numpy.pyj +2101 -0
- package/src/lib/operator.pyj +11 -0
- package/src/lib/pythonize.pyj +20 -0
- package/src/lib/random.pyj +118 -0
- package/src/lib/re.pyj +470 -0
- package/src/lib/traceback.pyj +63 -0
- package/src/lib/uuid.pyj +77 -0
- package/src/monaco-language-service/analyzer.js +526 -0
- package/src/monaco-language-service/builtins.js +543 -0
- package/src/monaco-language-service/completions.js +498 -0
- package/src/monaco-language-service/diagnostics.js +643 -0
- package/src/monaco-language-service/dts.js +550 -0
- package/src/monaco-language-service/hover.js +121 -0
- package/src/monaco-language-service/index.js +386 -0
- package/src/monaco-language-service/scope.js +162 -0
- package/src/monaco-language-service/signature.js +144 -0
- package/src/output/__init__.pyj +0 -0
- package/src/output/classes.pyj +296 -0
- package/src/output/codegen.pyj +492 -0
- package/src/output/comments.pyj +45 -0
- package/src/output/exceptions.pyj +105 -0
- package/src/output/functions.pyj +491 -0
- package/src/output/literals.pyj +109 -0
- package/src/output/loops.pyj +444 -0
- package/src/output/modules.pyj +329 -0
- package/src/output/operators.pyj +429 -0
- package/src/output/statements.pyj +463 -0
- package/src/output/stream.pyj +309 -0
- package/src/output/treeshake.pyj +182 -0
- package/src/output/utils.pyj +72 -0
- package/src/parse.pyj +3106 -0
- package/src/string_interpolation.pyj +72 -0
- package/src/tokenizer.pyj +702 -0
- package/src/unicode_aliases.pyj +576 -0
- package/src/utils.pyj +192 -0
- package/test/_import_one.pyj +37 -0
- package/test/_import_two/__init__.pyj +11 -0
- package/test/_import_two/level2/__init__.pyj +0 -0
- package/test/_import_two/level2/deep.pyj +4 -0
- package/test/_import_two/other.pyj +6 -0
- package/test/_import_two/sub.pyj +13 -0
- package/test/aes_vectors.pyj +421 -0
- package/test/annotations.pyj +80 -0
- package/test/baselib.pyj +319 -0
- package/test/classes.pyj +452 -0
- package/test/collections.pyj +152 -0
- package/test/decorators.pyj +77 -0
- package/test/dict_spread.pyj +76 -0
- package/test/docstrings.pyj +39 -0
- package/test/elementmaker_test.pyj +45 -0
- package/test/ellipsis.pyj +49 -0
- package/test/functions.pyj +151 -0
- package/test/generators.pyj +41 -0
- package/test/generic.pyj +370 -0
- package/test/imports.pyj +72 -0
- package/test/internationalization.pyj +73 -0
- package/test/lint.pyj +164 -0
- package/test/loops.pyj +85 -0
- package/test/numpy.pyj +734 -0
- package/test/omit_function_metadata.pyj +20 -0
- package/test/regexp.pyj +55 -0
- package/test/repl.pyj +121 -0
- package/test/scoped_flags.pyj +76 -0
- package/test/starargs.pyj +506 -0
- package/test/starred_assign.pyj +104 -0
- package/test/str.pyj +198 -0
- package/test/subscript_tuple.pyj +53 -0
- package/test/unit/fixtures/fibonacci_expected.js +46 -0
- package/test/unit/index.js +2989 -0
- package/test/unit/language-service-builtins.js +815 -0
- package/test/unit/language-service-completions.js +1067 -0
- package/test/unit/language-service-dts.js +543 -0
- package/test/unit/language-service-hover.js +455 -0
- package/test/unit/language-service-scope.js +833 -0
- package/test/unit/language-service-signature.js +458 -0
- package/test/unit/language-service.js +705 -0
- package/test/unit/run-language-service.js +41 -0
- package/test/unit/web-repl.js +484 -0
- package/tools/build-language-service.js +190 -0
- package/tools/cli.js +547 -0
- package/tools/compile.js +219 -0
- package/tools/compiler.js +108 -0
- package/tools/completer.js +131 -0
- package/tools/embedded_compiler.js +251 -0
- package/tools/export.js +316 -0
- package/tools/gettext.js +185 -0
- package/tools/ini.js +65 -0
- package/tools/lint.js +705 -0
- package/tools/msgfmt.js +187 -0
- package/tools/repl.js +223 -0
- package/tools/self.js +162 -0
- package/tools/test.js +118 -0
- package/tools/utils.js +128 -0
- package/tools/web_repl.js +95 -0
- package/try +41 -0
- package/web-repl/env.js +74 -0
- package/web-repl/index.html +163 -0
- package/web-repl/language-service.js +4084 -0
- package/web-repl/main.js +254 -0
- package/web-repl/prism.css +139 -0
- package/web-repl/prism.js +113 -0
- package/web-repl/rapydscript.js +435 -0
- package/web-repl/sha1.js +25 -0
package/.agignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lib/*
|
package/.gitattributes
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
env:
|
|
4
|
+
CI: 'true'
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
test:
|
|
8
|
+
name: Test on ${{ matrix.os }} LANG ${{ matrix.lang }}
|
|
9
|
+
runs-on: ${{ matrix.os }}
|
|
10
|
+
env:
|
|
11
|
+
LANG: ${{ matrix.lang }}
|
|
12
|
+
LC_ALL: ${{ matrix.lang }}
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
include:
|
|
16
|
+
- { os: ubuntu-latest, lang: en_US.UTF-8 }
|
|
17
|
+
- { os: ubuntu-latest, lang: de_DE.UTF-8}
|
|
18
|
+
- { os: ubuntu-latest, lang: hi_IN.UTF-8 }
|
|
19
|
+
|
|
20
|
+
- { os: macos-latest, lang: en_US.UTF-8 }
|
|
21
|
+
- { os: windows-latest, lang: en_US.UTF-8 }
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- name: Checkout source code
|
|
25
|
+
uses: actions/checkout@master
|
|
26
|
+
with:
|
|
27
|
+
fetch-depth: 10
|
|
28
|
+
|
|
29
|
+
- name: Set up Node ${{ matrix.node }}
|
|
30
|
+
uses: actions/setup-node@master
|
|
31
|
+
|
|
32
|
+
- name: Install deps
|
|
33
|
+
run:
|
|
34
|
+
npm install --no-optional
|
|
35
|
+
|
|
36
|
+
- name: Test
|
|
37
|
+
run:
|
|
38
|
+
npm test
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Simple workflow for deploying static content to GitHub Pages
|
|
2
|
+
name: Deploy static content to Pages
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
# Runs on pushes targeting the default branch
|
|
6
|
+
push:
|
|
7
|
+
branches: ["master"]
|
|
8
|
+
|
|
9
|
+
# Allows you to run this workflow manually from the Actions tab
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
pages: write
|
|
16
|
+
id-token: write
|
|
17
|
+
|
|
18
|
+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
19
|
+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
20
|
+
concurrency:
|
|
21
|
+
group: "pages"
|
|
22
|
+
cancel-in-progress: false
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
# Single deploy job since we're just deploying
|
|
26
|
+
deploy:
|
|
27
|
+
environment:
|
|
28
|
+
name: github-pages
|
|
29
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- name: Checkout
|
|
33
|
+
uses: actions/checkout@v4
|
|
34
|
+
- name: Setup Pages
|
|
35
|
+
uses: actions/configure-pages@v5
|
|
36
|
+
- name: Upload artifact
|
|
37
|
+
uses: actions/upload-pages-artifact@v3
|
|
38
|
+
with:
|
|
39
|
+
path: './web-repl'
|
|
40
|
+
- name: Deploy to GitHub Pages
|
|
41
|
+
id: deployment
|
|
42
|
+
uses: actions/deploy-pages@v4
|
package/=template.pyj
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
version 0.7.22
|
|
2
|
+
=======================
|
|
3
|
+
|
|
4
|
+
* Fix assignment operators other than the plain = not working with overload_getitem
|
|
5
|
+
* Fix dict.popitem() removing the first rather than the last item
|
|
6
|
+
|
|
7
|
+
version 0.7.21
|
|
8
|
+
=======================
|
|
9
|
+
|
|
10
|
+
* class decorators are now called after the class prototype is populated
|
|
11
|
+
* Fix len(range()) giving incorrect results
|
|
12
|
+
* Add support for {var=} to format strings
|
|
13
|
+
* Fix unary operators discarding parentheses
|
|
14
|
+
* Add a __module__ property to function objects
|
|
15
|
+
* Get isinstance working for int and float
|
|
16
|
+
|
|
17
|
+
version 0.7.20
|
|
18
|
+
========================
|
|
19
|
+
|
|
20
|
+
* lint: Fix using a tuple for destructuring assignment not registering the defined symbols
|
|
21
|
+
* Add head and body and base to elementmaker
|
|
22
|
+
* Make the gettext tools available in the embedded compiler
|
|
23
|
+
* re.pyj: Allow lookbehind assertions since they are supported in modern JS engines
|
|
24
|
+
|
|
25
|
+
version 0.7.19
|
|
26
|
+
========================
|
|
27
|
+
|
|
28
|
+
* Fix calling super-class methods in a method accepting `*args` not working
|
|
29
|
+
* Fix list.pypop() removing the first instead of the last element
|
|
30
|
+
* Fix exponentiation operator being used when js-version >= 6 rather than 7
|
|
31
|
+
* Disallow assignments in while conditionals
|
|
32
|
+
* Avoid unnecessary function annotations for functions that have empty signatures
|
|
33
|
+
* Fix handing of "not in" operator when LHS is also a binary operator with higher precedence
|
|
34
|
+
* Dont accept while statements without a trailing colon
|
|
35
|
+
* msgfmt: fix parsing of escapes in msg strings
|
|
36
|
+
* Fix missing enclosing brackets when translating an assert to an AssertionError
|
|
37
|
+
* Fix comments at the bottom of the file not being output
|
|
38
|
+
* Fix comments before first statement not being output for imported modules
|
|
39
|
+
* Fix outputting top-level comments preventing output of baselib
|
|
40
|
+
* Allow using NaN with the is operator
|
|
41
|
+
* Fix anonymous function definitions inside class definitions hoisting their variables into the class prototype.
|
|
42
|
+
* Fix gettext catalog generation when plurals are present
|
|
43
|
+
* Fix int() not working correctly on floating point numbers which have exponential string representations.
|
|
44
|
+
* Fix encoding of \u00ad
|
|
45
|
+
* Fir repeated calls to random.seed() with the same seed not fully resetting the RNG.
|
|
46
|
+
* Fix an error in handling chained binary operators involving comparison operators and an equality operator.
|
|
47
|
+
* Ensure repr() of set is always correct
|
|
48
|
+
|
|
49
|
+
version 0.7.18
|
|
50
|
+
==================
|
|
51
|
+
|
|
52
|
+
* Support the else: clause for try: statements
|
|
53
|
+
* Use the JS ** operator instead of Math.pow() when --js-version > 5
|
|
54
|
+
* Detect syntax errors of the form atomic token followed by atomic token
|
|
55
|
+
* Fix ** operator not working with parenthesized unary expressions
|
|
56
|
+
* Handle changed output from newer version of regenerator
|
|
57
|
+
* Detect missing indentation for blocks as a syntax error
|
|
58
|
+
* Linter: recognize pow() as a global function
|
|
59
|
+
|
|
60
|
+
version 0.7.17
|
|
61
|
+
==================
|
|
62
|
+
|
|
63
|
+
* Fix attempts to access calss variables from inside instance methods not
|
|
64
|
+
working
|
|
65
|
+
* Fix stdlib random.random() method not working in the Edge browser
|
|
66
|
+
|
|
67
|
+
version 0.7.16
|
|
68
|
+
==================
|
|
69
|
+
|
|
70
|
+
* Fix using function generators not working if installed version of uglify-js >= 3
|
|
71
|
+
* Speedup the compiler slightly by making reading options more efficient
|
|
72
|
+
|
|
73
|
+
version 0.7.15
|
|
74
|
+
==================
|
|
75
|
+
|
|
76
|
+
* Fix , flag for str.format thousands grouping not working
|
|
77
|
+
* Fix iteration over TouchList not working in Safari
|
|
78
|
+
* Fix }} escapes not being converted to } in f-strings
|
|
79
|
+
|
|
80
|
+
version 0.7.14
|
|
81
|
+
==================
|
|
82
|
+
|
|
83
|
+
* Fix }} escapes not being processed correctly in format strings
|
|
84
|
+
* Fix function definitions inside loops causing errors on ancient JS engines
|
|
85
|
+
* Fix --js-version command line argument not working
|
|
86
|
+
|
|
87
|
+
version 0.7.13
|
|
88
|
+
==================
|
|
89
|
+
|
|
90
|
+
* A uuid module for the standard library
|
|
91
|
+
* Implement the full python interface for the min() and max() functions
|
|
92
|
+
* Implement the full python interface for rangeobjects
|
|
93
|
+
* Implement the divmod function from python
|
|
94
|
+
|
|
95
|
+
version 0.7.12
|
|
96
|
+
==================
|
|
97
|
+
|
|
98
|
+
* Fix == failing when one of the arguments is None and the other is an object
|
|
99
|
+
* Make the range() function return an object that behaves like the python range() object
|
|
100
|
+
* Fix de-structuring assignment not working with iterators
|
|
101
|
+
|
|
102
|
+
version 0.7.11
|
|
103
|
+
==================
|
|
104
|
+
|
|
105
|
+
* Fix slice assignment not working
|
|
106
|
+
* Implement the global keyword
|
|
107
|
+
* Make list.pysort a stable sort on all JS engines
|
|
108
|
+
* Fix a typo that broke the REPL when XDG_CACHE_HOME is an absolute path
|
|
109
|
+
|
|
110
|
+
version 0.7.10
|
|
111
|
+
==================
|
|
112
|
+
|
|
113
|
+
* Fix passing of keyword args to the dict() function not working
|
|
114
|
+
* Improve the string representation of dicts and HTMLElements
|
|
115
|
+
|
|
116
|
+
version 0.7.9
|
|
117
|
+
==============
|
|
118
|
+
|
|
119
|
+
* BACWARDS INCOMPATIBLE: Make the `type()` function behave more like python's
|
|
120
|
+
`type()` function. It now return the class of the passed in argument, instead
|
|
121
|
+
of a string type name. For existing code that use `type()`, replace `type()` by
|
|
122
|
+
`jstype()`
|
|
123
|
+
|
|
124
|
+
* Fix multiple newlines not being properly escaped in interpolated string literals
|
|
125
|
+
|
|
126
|
+
version 0.7.8
|
|
127
|
+
==============
|
|
128
|
+
|
|
129
|
+
* Fix --cache-dir option defaulting to current working directory instead of being disabled
|
|
130
|
+
* Fix display of option names containing more than a single hyphen
|
|
131
|
+
* Fix including backslashes and/or newlines in interpolated string literals
|
|
132
|
+
* Fix spurious error message from linter when using interpolated string literals
|
|
133
|
+
|
|
134
|
+
version 0.7.7
|
|
135
|
+
==============
|
|
136
|
+
|
|
137
|
+
* Implement literal string interpolation (PEP 498)
|
|
138
|
+
* Fix incorrect method binding when using the `bound_methods` scoped flag and calling the super-class `__init__()` method
|
|
139
|
+
* elementmaker: Ignore kwargs that have types other than bool, string or func
|
|
140
|
+
* gettext: Allow registering callbacks for notification when new translation data is installed
|
|
141
|
+
* Fix a rare crash in the linter
|
|
142
|
+
|
|
143
|
+
version 0.7.6
|
|
144
|
+
==============
|
|
145
|
+
|
|
146
|
+
* Fix nested imports beyond two levels not working
|
|
147
|
+
* Fix iteration over NodeList/HTMLCollection not working with ES 6 output in Edge and Chrome < 51
|
|
148
|
+
* Add WebSocket to the list of known global class names
|
|
149
|
+
|
|
150
|
+
version 0.7.5
|
|
151
|
+
==============
|
|
152
|
+
|
|
153
|
+
* Add an option to have the compiler generate all its cache files in a central
|
|
154
|
+
directory. Use --cache-dir if you dislike having the `*.pyj-cached` files spread
|
|
155
|
+
throughout your source code
|
|
156
|
+
|
|
157
|
+
version 0.7.4
|
|
158
|
+
==============
|
|
159
|
+
|
|
160
|
+
* Fix piping data into rapydscript for compilation not working
|
|
161
|
+
|
|
162
|
+
version 0.7.3
|
|
163
|
+
==============
|
|
164
|
+
|
|
165
|
+
* Fix extra-semicolon after chain assignment, and also avoid using a temp
|
|
166
|
+
variable for non-destructuring chain assignments
|
|
167
|
+
|
|
168
|
+
* Fix a bug in the compiler cache system that could cause the compiler to
|
|
169
|
+
output incorrect code when re-compiling a previously cached module that was
|
|
170
|
+
imported from more than one other module.
|
|
171
|
+
|
|
172
|
+
* Add the builtin `pow()` function from python
|
|
173
|
+
|
|
174
|
+
* Workaround for a bug in the latest release of Chrome that broke the web REPL
|
|
175
|
+
and embedded compiler.
|
|
176
|
+
|
|
177
|
+
version 0.7.2
|
|
178
|
+
==============
|
|
179
|
+
|
|
180
|
+
* Fix multiline string literals not working in some contexts, such as after
|
|
181
|
+
return or yield keywords
|
|
182
|
+
|
|
183
|
+
* Add a scoped flag `hash_literals` to control whether `{}` literals generate
|
|
184
|
+
JavaScript arrays or JavaScript hashes. Note that the `dict_literals` scoped
|
|
185
|
+
flag takes precedence over this flag.
|
|
186
|
+
|
|
187
|
+
* Add a builtin function `get_module()` to get a reference to the module dicts
|
|
188
|
+
for a previously imported module.
|
|
189
|
+
|
|
190
|
+
* Nicer error messages when web-repl-export is not called correctly
|
|
191
|
+
|
|
192
|
+
version 0.7.1
|
|
193
|
+
==============
|
|
194
|
+
|
|
195
|
+
* Make importing of non-aliased submodules `import module.submodule` work just
|
|
196
|
+
like in python (the submodule name is bound into the parent namespace at
|
|
197
|
+
the import statement rather than at import time)
|
|
198
|
+
|
|
199
|
+
* Fix referring to class variables not working. Now there is no need to use
|
|
200
|
+
`A.prototype.x` one can just do `A.x` and the compiler will handle it automatically,
|
|
201
|
+
provided it knows that A is a class.
|
|
202
|
+
|
|
203
|
+
* Fix a regression in 0.6.0 that broke using @staticmethod for methods that accept arguments
|
|
204
|
+
|
|
205
|
+
version 0.7.0
|
|
206
|
+
==============
|
|
207
|
+
|
|
208
|
+
New features
|
|
209
|
+
-------------
|
|
210
|
+
|
|
211
|
+
* Implement the existential operator, see the README for details.
|
|
212
|
+
* Add the any() and all() builtin functions from python
|
|
213
|
+
* Drop support for the JavaScript form of the conditional ternary operator
|
|
214
|
+
(backwards incompatible). This was done mainly to free up the `?` operator for use
|
|
215
|
+
as the existential operator.
|
|
216
|
+
* Add a traceback module to the standard library that works like the python
|
|
217
|
+
one
|
|
218
|
+
* Full support for negative indices on lists: `a=-1; b[a] is b[-1]`
|
|
219
|
+
|
|
220
|
+
Bug fixes
|
|
221
|
+
------------
|
|
222
|
+
* Fix local variables in except: blocks not being declared
|
|
223
|
+
* Make defining custom exception classes work just as in python (just subclass
|
|
224
|
+
Exception and you are done)
|
|
225
|
+
* Make the default `__repr__()` method use the base class implementation when available
|
|
226
|
+
* Fix the del operator: Now your can use it to delete slices of arrays,
|
|
227
|
+
variable names, etc.
|
|
228
|
+
* Make the use of javascript reserved words as identifiers a compile time error, instead of a runtime error
|
|
229
|
+
* Fix optimization of range() causing incorrect behavior when the stop expression is dynamic
|
|
230
|
+
|
|
231
|
+
version 0.6.4
|
|
232
|
+
==============
|
|
233
|
+
|
|
234
|
+
* Support for docstrings in modules, classes and functions, just like python.
|
|
235
|
+
By default the docstrings are discarded (except in the REPL). There is a
|
|
236
|
+
compiler option to keep the docstrings as the `__doc__` attribute in the
|
|
237
|
+
output JavaScript.
|
|
238
|
+
|
|
239
|
+
* Add hexlify()/unhexlify() to the encodings stdlib module
|
|
240
|
+
|
|
241
|
+
* Object literals now produce JavaScript objects that have no prototype. This
|
|
242
|
+
makes them more like python dicts, in that there is no need to use
|
|
243
|
+
Object.keys() and Object.hasOwnProperty() to iterate/test their keys.
|
|
244
|
+
|
|
245
|
+
version 0.6.3
|
|
246
|
+
==============
|
|
247
|
+
|
|
248
|
+
* Add a module to the standard library to easily add python string methods to the JavaScript String object, if needed.
|
|
249
|
+
* Fix isinstance('a', str) not working
|
|
250
|
+
* Prevent an infinite loop in str.count() when needle is an empty string
|
|
251
|
+
* Fix default values for function args not working when combined with annotations
|
|
252
|
+
* Change the prefix used internally for RapydScript private symbols from `_$rapyd$_` to `ρσ_` as it makes the output JavaScript easier to read
|
|
253
|
+
|
|
254
|
+
version 0.6.2
|
|
255
|
+
==============
|
|
256
|
+
|
|
257
|
+
* Support multiple inheritance, just as in python
|
|
258
|
+
* Support method auto-binding for classes, just as in python, via an optional scoped flag. See the Method binding section in the README for details
|
|
259
|
+
|
|
260
|
+
version 0.6.1
|
|
261
|
+
==============
|
|
262
|
+
|
|
263
|
+
Bug fix release, fixing a couple of regressions in 0.6.0
|
|
264
|
+
|
|
265
|
+
* Fix a regression caused by the new kwargs code that caused incorrect construction of classes when called with kwargs
|
|
266
|
+
* Fix a regression when calling super class methods with kwargs
|
|
267
|
+
|
|
268
|
+
version 0.6.0
|
|
269
|
+
==============
|
|
270
|
+
|
|
271
|
+
New features
|
|
272
|
+
--------------------
|
|
273
|
+
|
|
274
|
+
* Support for function type annotations, just like in Python 3. You can now
|
|
275
|
+
create optional type annotation in RapydScript, exactly as you would in
|
|
276
|
+
Python 3.
|
|
277
|
+
|
|
278
|
+
* Support for *scoped flags* -- a mechanism to change the behavior of the
|
|
279
|
+
compiler in sections of code using simple statements in the code. These work
|
|
280
|
+
like compiler pragmas in C/C++ but have the additional feature that they are
|
|
281
|
+
local to a scope -- i.e. they are automatically reset when leaving the scope
|
|
282
|
+
they are defined in, which could be a function or a module or even a class.
|
|
283
|
+
|
|
284
|
+
* Support for python style dicts using the exact same syntax as in python. The
|
|
285
|
+
default syntax still creates JavaScript objects, but you can switch to
|
|
286
|
+
python dicts using a scoped flag:
|
|
287
|
+
```py
|
|
288
|
+
from __python__ import dict_literals, overload_getitem
|
|
289
|
+
```
|
|
290
|
+
This will cause the default syntax to generate python dicts.
|
|
291
|
+
|
|
292
|
+
* Add an **encodings.pyj** module to the stdlib which is very useful to convert
|
|
293
|
+
between utf-8 bytearrays, base64 encoded strings, and native strings.
|
|
294
|
+
|
|
295
|
+
* Implement repeating of string literals with the * operator
|
|
296
|
+
`'a' * 3 == 'aaa'`
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
Bugfixes
|
|
300
|
+
----------
|
|
301
|
+
|
|
302
|
+
* Enable use of keyword arguments/values when calling all functions, even if
|
|
303
|
+
they have not been defined with keyword arguments.
|
|
304
|
+
|
|
305
|
+
* Fix use of `*args/**kw` when calling functions that are the result of a
|
|
306
|
+
complex expression, causing the expression to be evaluated twice.
|
|
307
|
+
|
|
308
|
+
* Fix negative const index on expression containing a function call causing
|
|
309
|
+
the function call to be executed twice
|
|
310
|
+
|
|
311
|
+
* Fix --import-dirs not being used when recursively processing imports
|
|
312
|
+
|
|
313
|
+
version 0.5.2
|
|
314
|
+
==============
|
|
315
|
+
|
|
316
|
+
* New module in stdlib: **aes.pyj** that implements the symmetric encryption
|
|
317
|
+
ciphers: AES-GCM, AES-CBC, AES-CTR
|
|
318
|
+
|
|
319
|
+
* Improved support for TypedArrays -- you can now iterate over them just like
|
|
320
|
+
normal arrays and also repr() wors for them.
|
|
321
|
+
|
|
322
|
+
* elementmaker.pyj: Allow setting HTML 5 boolean attributes using True/False.
|
|
323
|
+
Fix E.iframe() not working.
|
|
324
|
+
|
|
325
|
+
* Make the equality operators also work with javascript dicts (when
|
|
326
|
+
javascript objects are used as dicts)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
version 0.5.1
|
|
330
|
+
==============
|
|
331
|
+
|
|
332
|
+
Fix a bug that caused the equality operators to not work for lists. Also,
|
|
333
|
+
fix the new equality operators causing their arguments to be evaluated twice
|
|
334
|
+
when the arguments are expressions, such as function calls, generators, object
|
|
335
|
+
literals, etc.
|
|
336
|
+
|
|
337
|
+
version 0.5.0
|
|
338
|
+
==============
|
|
339
|
+
|
|
340
|
+
Below are listed all the major new features and backwards incompatible changes
|
|
341
|
+
since the creation of the rapydscript-ng fork, up to version 0.5.0
|
|
342
|
+
|
|
343
|
+
Backwards incompatible changes:
|
|
344
|
+
--------------------------------------------------------------
|
|
345
|
+
|
|
346
|
+
* A new module/import system that works just like python's, with modules in
|
|
347
|
+
``.pyj`` files and packages in directories with an ``__init__.pyj`` file.
|
|
348
|
+
|
|
349
|
+
* The equality operators now work with all container types (list/set/dict) as
|
|
350
|
+
well as user defined classes that implement the `__eq__()` method, just as in
|
|
351
|
+
python.
|
|
352
|
+
|
|
353
|
+
* Remove the `to` and `til` operators
|
|
354
|
+
|
|
355
|
+
* Change syntax for embedded JavaScript literals. Now one uses a normal string
|
|
356
|
+
literal, with the **v** prefix, for example:
|
|
357
|
+
```py
|
|
358
|
+
for v'i = 0; i < 10; i++':
|
|
359
|
+
pass
|
|
360
|
+
```
|
|
361
|
+
The old compile time magic function `JS()` used for JavaScript literals has been removed.
|
|
362
|
+
|
|
363
|
+
* String literals now behave exactly like python. You can use raw string
|
|
364
|
+
literal, escapes for unicode such as `\u2122` or `\N{...}` etc.
|
|
365
|
+
|
|
366
|
+
* Dict literals now do not treat identifiers as strings, so you can use arbitrary expressions as keys.
|
|
367
|
+
|
|
368
|
+
* Remove the ``@kwargs`` decorator. Keyword arguments now work seamlessly, just
|
|
369
|
+
as in python.
|
|
370
|
+
|
|
371
|
+
Major new features:
|
|
372
|
+
--------------------
|
|
373
|
+
|
|
374
|
+
* There is now an in browser REPL (Read-Eval-Print-Loop) for RapydScript,
|
|
375
|
+
available at: https://sw.kovidgoyal.net/rapydscript/repl/
|
|
376
|
+
|
|
377
|
+
* There is now a linter that performs pyflakes style of undefined/unused
|
|
378
|
+
checks.
|
|
379
|
+
|
|
380
|
+
* Instructions for easily embedding the RapydScript compiler in a webapp are
|
|
381
|
+
now in the README.
|
|
382
|
+
|
|
383
|
+
* A new stdlib module: **elementmaker.pyj** that allows for easy creation of
|
|
384
|
+
DOM trees within RapydScript code. For example:
|
|
385
|
+
```py
|
|
386
|
+
from elementmaker import E
|
|
387
|
+
E.div(class_='mydiv', title='A tooltip', data_special='xxx',
|
|
388
|
+
E.a(href='javascript: void(0)', onclick=def():
|
|
389
|
+
# handle the click event
|
|
390
|
+
),
|
|
391
|
+
'Some text'
|
|
392
|
+
)
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
* All the python string functions are now available, including `format()`. However, for reasons of
|
|
396
|
+
compatibility with external javascript code, they are not implemented as
|
|
397
|
+
methods on string objects, instead, use the global ```str``` object, for
|
|
398
|
+
example:
|
|
399
|
+
```py
|
|
400
|
+
str.format('{:02d} {}', 1, "wow") == '01 wow'
|
|
401
|
+
```
|
|
402
|
+
There is a convenience module in the stdlib to add these functions to the
|
|
403
|
+
JavaScript String object, if needed.
|
|
404
|
+
|
|
405
|
+
* Support dict and set comprehensions
|
|
406
|
+
|
|
407
|
+
* Support the python conditional operator syntax: ```a if b else c```
|
|
408
|
+
|
|
409
|
+
New features
|
|
410
|
+
-------------------------
|
|
411
|
+
|
|
412
|
+
* Implement `str()` and `repr()` functions that work well for JavaScript arrays and
|
|
413
|
+
Objects as well as your own custom classes that define the `__repr__()` and
|
|
414
|
+
`__str__()` methods
|
|
415
|
+
|
|
416
|
+
* A builtin `sorted()` function that behaves like python's
|
|
417
|
+
|
|
418
|
+
* A builtin `id()` function that behaves like python's (only for objects
|
|
419
|
+
defined in RapydScript)
|
|
420
|
+
|
|
421
|
+
* Support for dynamic properties just as in python with the `@property` decorator
|
|
422
|
+
|
|
423
|
+
* Allow trailing commas in function calls and function definitions
|
|
424
|
+
|
|
425
|
+
* Allow specifying multiple locations to search for modules to import
|
|
426
|
+
|
|
427
|
+
* Allow iteration `(for x in ...)` to work for DOM based array like containers
|
|
428
|
+
such as `NodeList` and `NamedNodeMap` even when they come from a different frame.
|
|
429
|
+
|
|
430
|
+
* Support for internationalization, works just like in python (see README for
|
|
431
|
+
details).
|
|
432
|
+
|
|
433
|
+
* Linter: Allow suppressing errors at file level as well
|
|
434
|
+
|
|
435
|
+
* Automatic concantenation of neighboring string literals: '1' '2' == '12'
|
|
436
|
+
|
|
437
|
+
* Support for arbitrary expressions as decorators
|
|
438
|
+
|
|
439
|
+
* Support for generator comprehensions
|
|
440
|
+
|
|
441
|
+
* The stdlib's `re.pyj` module has been greatly enhanced. It's functionality is
|
|
442
|
+
now much closer to python's re module.
|
|
443
|
+
|
|
444
|
+
* Added support for the with statement (context managers)
|
|
445
|
+
|
|
446
|
+
* Support for binary number literals
|
|
447
|
+
|
|
448
|
+
* A builtin set type and set literals
|
|
449
|
+
|
|
450
|
+
* Support recursive destructuring in assignments and for loop expressions.
|
|
451
|
+
|
|
452
|
+
* Add a new ES 6 output mode that emits faster code for ES 6 compatible
|
|
453
|
+
runtimes
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
In addition there have been hundreds of bug fixes.
|
package/CONTRIBUTORS
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
This project is officially supported by Kovid Goyal.
|
|
2
|
+
|
|
3
|
+
Main Developers
|
|
4
|
+
---------------
|
|
5
|
+
Kovid Goyal
|
|
6
|
+
|
|
7
|
+
Other Contributors
|
|
8
|
+
------------------
|
|
9
|
+
Alexander Tsepkov (main developer of the original RapydScript)
|
|
10
|
+
Charles Law
|
|
11
|
+
Tobias Weber
|
|
12
|
+
Salvatore Di Dio
|
|
13
|
+
Tuomas Laakkonen
|
package/HACKING.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
Hacking the RapydScript compiler
|
|
2
|
+
=================================
|
|
3
|
+
|
|
4
|
+
The RapydScript compiler is written in RapydScript itself and uses the
|
|
5
|
+
RapydScript import system to modularize its code. The compiler source code is
|
|
6
|
+
in the `src` directory. The compiled compiler is by default in the `release`
|
|
7
|
+
directory.
|
|
8
|
+
|
|
9
|
+
In order to start hacking on the compiler, run the command
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
bin/rapydscript self --complete --test
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This will generate a build of the compiler in the `dev` directory. Now, the
|
|
16
|
+
rapydscript command will automatically use this build, rather than the one in
|
|
17
|
+
release. If you want to go back to the release build, simply delete the `dev`
|
|
18
|
+
directory.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Code organization
|
|
22
|
+
-------------------
|
|
23
|
+
|
|
24
|
+
The way the compiler works, given some RapydScript source code:
|
|
25
|
+
|
|
26
|
+
* The source code is lexed into a stream of tokens (`src/tokenzier.pyj`)
|
|
27
|
+
|
|
28
|
+
* The tokens are parsed into a Abstract Syntax Tree (`src/parse.pyj and src/ast.pyj`)
|
|
29
|
+
|
|
30
|
+
* During parsing any import statement are resolved (this is different from
|
|
31
|
+
python, where imports happen at run-time, not compile time).
|
|
32
|
+
|
|
33
|
+
* The Abstract Syntax Tree is transformed into the output JavaScript (`src/output/*.pyj`)
|
|
34
|
+
|
|
35
|
+
* Various bits of functionality in RapydScript depend upon the *Base Library*
|
|
36
|
+
(`src/baselib*.pyj`). This includes things like the basic container types
|
|
37
|
+
(list/set/dict) string functions such as `str.format()`, etc. The baselib
|
|
38
|
+
is automatically inserted into the start of the output JavaScript.
|
|
39
|
+
|
|
40
|
+
The RapydScript standard library can be found in `src/lib`. The various tools,
|
|
41
|
+
such as the linter, gettext support, the REPL, etc. are in the `tools`
|
|
42
|
+
directory.
|
|
43
|
+
|
|
44
|
+
Tests
|
|
45
|
+
--------
|
|
46
|
+
|
|
47
|
+
The tests are in the test directory and can be run using the command:
|
|
48
|
+
```
|
|
49
|
+
rapydscript test
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
You can run individual test files by providing the name of the file, as
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
rapydscript test classes
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Modifying the compiler
|
|
59
|
+
-------------------------
|
|
60
|
+
|
|
61
|
+
Edit the files in the `src` directory to make your changes, then use the
|
|
62
|
+
`./try` script to test them. This script will compile an updated version of
|
|
63
|
+
the compiler with your changes, if any, and use it to run the snippet of code
|
|
64
|
+
you pass to it.
|
|
65
|
+
|
|
66
|
+
For example:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
./try 'print("Hello world")'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
will compile `print ("Hello world")` and show you the output on stdout. You can
|
|
73
|
+
tell it to omit the baselib, so you can focus on the output, with the `-m`
|
|
74
|
+
switch, like this:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
./try -m 'print("Hello world")'
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
You can also have it not print out the JavaScript, instead directly executing the output
|
|
81
|
+
JavaScript with the `-x` switch, like this
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
./try -x 'print("Hello world")'
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
If you want to test longer sections of code, you can use the `-f` switch to
|
|
88
|
+
pass in the path to a RapydScript file to compile, like this:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
./try -f myfile.pyj
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Once you are happy with your changes, you can build the compiler and run the
|
|
95
|
+
test suite, all with a single command:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
./build
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
This will build the compiler with the updated version of itself and then run
|
|
102
|
+
the test suite. If all test pass you can commit your changes and send a pull
|
|
103
|
+
request :)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Copyright (c) 2015-, Kovid Goyal <kovid@kovidgoyal.net>
|
|
2
|
+
Copyright (c) 2013-2014, Alexander Tsepkov <atsepkov@pyjeon.com>
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
19
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|