rapydscript-ng 0.7.18 → 0.7.22
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/.github/workflows/ci.yml +40 -0
- package/CHANGELOG.md +49 -1
- package/README.md +22 -7
- package/bin/web-repl-export +2 -2
- package/package.json +2 -2
- package/publish.py +9 -8
- package/release/baselib-plain-pretty.js +1707 -1044
- package/release/baselib-plain-ugly.js +3 -1
- package/release/compiler.js +5530 -3366
- package/release/signatures.json +18 -17
- package/src/ast.pyj +3 -1
- package/src/baselib-builtins.pyj +14 -3
- package/src/baselib-containers.pyj +13 -6
- package/src/baselib-internal.pyj +5 -1
- package/src/baselib-str.pyj +15 -2
- package/src/lib/elementmaker.pyj +2 -2
- package/src/lib/gettext.pyj +8 -7
- package/src/lib/random.pyj +1 -0
- package/src/lib/re.pyj +4 -3
- package/src/lib/traceback.pyj +16 -4
- package/src/output/classes.pyj +33 -5
- package/src/output/codegen.pyj +5 -38
- package/src/output/comments.pyj +45 -0
- package/src/output/functions.pyj +30 -19
- package/src/output/modules.pyj +19 -6
- package/src/output/operators.pyj +50 -19
- package/src/output/statements.pyj +2 -2
- package/src/output/stream.pyj +13 -21
- package/src/parse.pyj +52 -36
- package/src/string_interpolation.pyj +6 -1
- package/src/tokenizer.pyj +8 -2
- package/test/baselib.pyj +10 -0
- package/test/classes.pyj +24 -0
- package/test/collections.pyj +8 -0
- package/test/functions.pyj +16 -0
- package/test/generic.pyj +39 -1
- package/test/internationalization.pyj +8 -2
- package/test/regexp.pyj +3 -2
- package/test/scoped_flags.pyj +2 -0
- package/test/starargs.pyj +43 -0
- package/test/str.pyj +19 -8
- package/tools/cli.js +6 -1
- package/tools/compiler.js +3 -3
- package/tools/embedded_compiler.js +3 -3
- package/tools/export.js +3 -3
- package/tools/gettext.js +5 -2
- package/tools/lint.js +24 -13
- package/tools/msgfmt.js +1 -1
- package/web-repl/env.js +7 -1
- package/.appveyor.yml +0 -13
- package/.npmignore +0 -9
- package/.travis.yml +0 -12
package/test/functions.pyj
CHANGED
|
@@ -105,7 +105,23 @@ def hello(something):
|
|
|
105
105
|
return "hello " + something
|
|
106
106
|
|
|
107
107
|
assrt.equal(hello("world"), "<b><i>hello world</i></b>")
|
|
108
|
+
assrt.equal(hello.__module__, '__main__')
|
|
109
|
+
assrt.equal(hello.__argnames__.length, 1)
|
|
110
|
+
assrt.equal(hello.__argnames__[0], 'arg')
|
|
108
111
|
|
|
112
|
+
|
|
113
|
+
def simple_wrapper(f):
|
|
114
|
+
f.test_attr = 'test'
|
|
115
|
+
return f
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@simple_wrapper
|
|
119
|
+
def fw(x):
|
|
120
|
+
pass
|
|
121
|
+
|
|
122
|
+
assrt.equal(fw.__module__, '__main__')
|
|
123
|
+
assrt.equal(fw.__argnames__.length, 1)
|
|
124
|
+
assrt.equal(fw.__argnames__[0], 'x')
|
|
109
125
|
# just because something is a reserved keyword in RapydScript, doesn't mean other libraries won't attempt to use it
|
|
110
126
|
# let's make sure we parse that correctly
|
|
111
127
|
five = {}
|
package/test/generic.pyj
CHANGED
|
@@ -7,6 +7,11 @@ def throw_test(code):
|
|
|
7
7
|
RapydScript.parse(code, {'filename':code}).body[0]
|
|
8
8
|
, RapydScript.SyntaxError)
|
|
9
9
|
|
|
10
|
+
# unary operators
|
|
11
|
+
assrt.equal(-(1), -1)
|
|
12
|
+
assrt.equal(-(-1), 1)
|
|
13
|
+
assrt.equal(+(+1), 1)
|
|
14
|
+
|
|
10
15
|
# arithmetic
|
|
11
16
|
assrt.equal(3**4, Math.pow(3, 4))
|
|
12
17
|
assrt.equal(100**-2, Math.pow(100, -2))
|
|
@@ -20,9 +25,14 @@ a = 100
|
|
|
20
25
|
a //= 3
|
|
21
26
|
assrt.equal(a, 33)
|
|
22
27
|
assrt.equal(0b11, 3)
|
|
28
|
+
assrt.ok(42 / "x" is NaN)
|
|
29
|
+
assrt.ok(42 is not NaN)
|
|
30
|
+
assrt.ok(NaN is parseInt('asd', 10))
|
|
31
|
+
assrt.ok('NaN' is not 42 / 'x')
|
|
23
32
|
|
|
24
33
|
# comparisons
|
|
25
34
|
assrt.ok(3<5<7)
|
|
35
|
+
assrt.equal(-1 < 0 == 1 < 0, False)
|
|
26
36
|
|
|
27
37
|
# Empty tuple
|
|
28
38
|
assrt.deepEqual((), [])
|
|
@@ -84,6 +94,9 @@ throw_test('while 1:\npass')
|
|
|
84
94
|
throw_test('def f():\n while 1:\n pass')
|
|
85
95
|
throw_test('1 1')
|
|
86
96
|
throw_test('z = x y')
|
|
97
|
+
throw_test('while a = 1: pass')
|
|
98
|
+
throw_test('while 1\n pass')
|
|
99
|
+
throw_test('for a in [1]\n pass')
|
|
87
100
|
|
|
88
101
|
# object literals
|
|
89
102
|
{1:
|
|
@@ -131,6 +144,9 @@ for v'var i = 0; i < 1; i++':
|
|
|
131
144
|
a[i] = 1 # noqa: undef
|
|
132
145
|
assrt.deepEqual(a, [1])
|
|
133
146
|
|
|
147
|
+
# String literals
|
|
148
|
+
a = '\u00ad'
|
|
149
|
+
assrt.equal(a.charCodeAt(0), 0xad)
|
|
134
150
|
# String literal concatenation
|
|
135
151
|
|
|
136
152
|
assrt.equal('1' '2', '12')
|
|
@@ -256,7 +272,9 @@ def errf():
|
|
|
256
272
|
try:
|
|
257
273
|
errf()
|
|
258
274
|
except MyException as e:
|
|
259
|
-
|
|
275
|
+
fe = traceback.format_exception()
|
|
276
|
+
assrt.ok(str.strip(fe[-2]).startsWith('at errf'))
|
|
277
|
+
|
|
260
278
|
|
|
261
279
|
def stackf():
|
|
262
280
|
return traceback.format_stack()
|
|
@@ -330,3 +348,23 @@ assrt.equal(undef ? 1, 0)
|
|
|
330
348
|
ml = 1, '''
|
|
331
349
|
'''
|
|
332
350
|
assrt.deepEqual(ml, [1, '\n'])
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
# localvars in conditions
|
|
354
|
+
|
|
355
|
+
gv = 1
|
|
356
|
+
(def ():
|
|
357
|
+
if (gv = 2):
|
|
358
|
+
pass
|
|
359
|
+
assrt.equal(gv, 2)
|
|
360
|
+
)()
|
|
361
|
+
assrt.equal(gv, 1)
|
|
362
|
+
|
|
363
|
+
assrt.ok(1 not in [2, 3])
|
|
364
|
+
assrt.ok(1 in [1, 2])
|
|
365
|
+
assrt.ok("1" + "2" in ["12", "x"])
|
|
366
|
+
assrt.ok("1" + "2" not in ["1", "2"])
|
|
367
|
+
if "1" + "2" not in ["1", "2"]:
|
|
368
|
+
assrt.ok(1)
|
|
369
|
+
else:
|
|
370
|
+
assrt.ok(0)
|
|
@@ -22,7 +22,7 @@ test_string('''a = _("""one
|
|
|
22
22
|
two""")''', '#: <test>:1\nmsgid "one\\ntwo"\nmsgstr ""')
|
|
23
23
|
test_string('a = _("{}one")', '#: <test>:1\n#, python-brace-format\nmsgid "{}one"\nmsgstr ""')
|
|
24
24
|
test_string('a = _("{one}")', '#: <test>:1\n#, python-brace-format\nmsgid "{one}"\nmsgstr ""')
|
|
25
|
-
test_string('ngettext("one", "two", 1)', '#: <test>:1\nmsgid "one"\nmsgid_plural "two"\nmsgstr ""')
|
|
25
|
+
test_string('ngettext("one", "two", 1)', '#: <test>:1\nmsgid "one"\nmsgid_plural "two"\nmsgstr[0] ""\nmsgstr[1] ""')
|
|
26
26
|
test_string('''_('o"ne')''', '#: <test>:1\nmsgid "o\\"ne"\nmsgstr ""')
|
|
27
27
|
|
|
28
28
|
m = require('../tools/msgfmt.js')
|
|
@@ -43,11 +43,14 @@ msgid_plural "three"
|
|
|
43
43
|
msgstr[0] "a"
|
|
44
44
|
"bc"
|
|
45
45
|
msgstr[1] "def"
|
|
46
|
+
|
|
47
|
+
msgid "test \"quote\" escape"
|
|
48
|
+
msgstr "good"
|
|
46
49
|
''')
|
|
47
50
|
|
|
48
51
|
assrt.equal(2, catalog['nplurals'])
|
|
49
52
|
assrt.equal('en', catalog['language'])
|
|
50
|
-
assrt.equal(catalog['entries'].length,
|
|
53
|
+
assrt.equal(catalog['entries'].length, 3)
|
|
51
54
|
item = catalog['entries'][0]
|
|
52
55
|
assrt.equal(item['msgid'], 'one\ncontinued')
|
|
53
56
|
assrt.deepEqual(item['msgstr'], v"['ONE']")
|
|
@@ -56,6 +59,9 @@ item = catalog['entries'][1]
|
|
|
56
59
|
assrt.equal(item['msgid'], 'two')
|
|
57
60
|
assrt.deepEqual(item['msgstr'], v"['abc', 'def']")
|
|
58
61
|
assrt.ok(not item['fuzzy'], 'item not fuzzy')
|
|
62
|
+
item = catalog['entries'][2]
|
|
63
|
+
assrt.equal(item['msgid'], 'test "quote" escape')
|
|
64
|
+
assrt.deepEqual(item['msgstr'], v"['good']")
|
|
59
65
|
|
|
60
66
|
install({'entries': {
|
|
61
67
|
'one':['ONE'],
|
package/test/regexp.pyj
CHANGED
|
@@ -36,9 +36,11 @@ assrt.equal(re.sub('a(b)', r'\g<1>', 'ab'), r'b')
|
|
|
36
36
|
assrt.equal(re.sub('a(b)', def(m):return m.group(1);, 'ab'), r'b')
|
|
37
37
|
assrt.equal(']', re.match('[]]', ']').group())
|
|
38
38
|
|
|
39
|
-
assrt.throws(def():re.search(r'(?<=a)b', 'ab');, re.error)
|
|
40
39
|
assrt.throws(def():re.search(r'(?(1)a|b)b', 'ab');, re.error)
|
|
41
40
|
|
|
41
|
+
# Test lookbehind assertions
|
|
42
|
+
assrt.equal('acdb', re.sub(r'(?<=a)b', 'c', 'abdb'))
|
|
43
|
+
|
|
42
44
|
# Test named groups
|
|
43
45
|
assrt.equal('aa', re.sub(r'(?P<a>a)b', r'\g<a>\1', 'ab'))
|
|
44
46
|
assrt.equal('bb', re.sub(r'(?P<a>a)(?P=a)', r'bb', 'aa'))
|
|
@@ -51,4 +53,3 @@ assrt.equal(re.search(///
|
|
|
51
53
|
. # anything
|
|
52
54
|
b
|
|
53
55
|
///, ' axb').group(), 'axb')
|
|
54
|
-
|
package/test/scoped_flags.pyj
CHANGED
package/test/starargs.pyj
CHANGED
|
@@ -297,3 +297,46 @@ p1, p2 = Pr(), Pr(a=1)
|
|
|
297
297
|
eq(p1.prototype, p2.prototype)
|
|
298
298
|
de(dir(p1), dir(p2))
|
|
299
299
|
|
|
300
|
+
class Prn:
|
|
301
|
+
|
|
302
|
+
def __init__(self, x):
|
|
303
|
+
self.x = x
|
|
304
|
+
|
|
305
|
+
class Prn1(Prn):
|
|
306
|
+
|
|
307
|
+
def __init__(self, x, *a):
|
|
308
|
+
Prn.__init__(self, [x, a])
|
|
309
|
+
|
|
310
|
+
class Prn2(Prn):
|
|
311
|
+
|
|
312
|
+
def __init__(self, *a):
|
|
313
|
+
Prn.__init__(self, a)
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
class Prn3(Prn):
|
|
317
|
+
|
|
318
|
+
def __init__(self, *a):
|
|
319
|
+
Prn.__init__(self, *a)
|
|
320
|
+
|
|
321
|
+
p = Prn1(1, 2, 3)
|
|
322
|
+
eq(p.x[0], 1)
|
|
323
|
+
de(p.x[1], [2, 3])
|
|
324
|
+
p = Prn2(1, 2)
|
|
325
|
+
de(p.x, [1, 2])
|
|
326
|
+
p = Prn3(1, 2)
|
|
327
|
+
eq(p.x, 1)
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
class Prnb:
|
|
331
|
+
|
|
332
|
+
def __init__(self, a, k):
|
|
333
|
+
self.a, self.k = a, k
|
|
334
|
+
|
|
335
|
+
class Prnb1(Prnb):
|
|
336
|
+
|
|
337
|
+
def __init__(self, *a, **kw):
|
|
338
|
+
Prnb.__init__(self, a, kw)
|
|
339
|
+
|
|
340
|
+
p = Prnb1(1, 2, x=1, y=2)
|
|
341
|
+
de(p.a, [1, 2])
|
|
342
|
+
de(p.k, {'x': 1, 'y':2})
|
package/test/str.pyj
CHANGED
|
@@ -42,11 +42,18 @@ def test_interpolation():
|
|
|
42
42
|
ae(f'0{a}', '01')
|
|
43
43
|
ae(f'0{a}2', '012')
|
|
44
44
|
ae(f'{a}{b[-1]}', '1x')
|
|
45
|
-
ae(f'{c:,d}',
|
|
45
|
+
ae(f'{c:,d}', (30000).toLocaleString())
|
|
46
46
|
ae(f'\n', '\n')
|
|
47
47
|
ae(f'{a}\\{b[0]}', '1\\x')
|
|
48
48
|
ae(f'x\n\ny', 'x\n\ny')
|
|
49
|
+
ae(f'{a=}', 'a=1')
|
|
50
|
+
somevar = {'x': 1}
|
|
51
|
+
ae(f'{somevar.x=}', 'somevar.x=1')
|
|
49
52
|
|
|
53
|
+
somevar = 33
|
|
54
|
+
test('somevar=33', '{somevar=}', somevar=somevar)
|
|
55
|
+
somevar = {'v': 'x'}
|
|
56
|
+
test('somevar.v=x', '{somevar.v=}', somevar=somevar)
|
|
50
57
|
test(' 1 2', ' {} {}', 1, 2)
|
|
51
58
|
test('{ a ', '{{ {0} ', 'a')
|
|
52
59
|
test('11', '{0}{0}', 1)
|
|
@@ -58,18 +65,22 @@ test('1', '{0[a][b]}', {'a':{'b':1}})
|
|
|
58
65
|
test('x', '{}', def (): return 'x';)
|
|
59
66
|
test('11', '{:b}', 3)
|
|
60
67
|
test('0b11', '{:#b}', 3)
|
|
61
|
-
test(
|
|
68
|
+
test((30000).toLocaleString(), '{:,d}', 30000)
|
|
69
|
+
# in e.g. the indian number system, this is 3,00,000
|
|
70
|
+
test((300000).toLocaleString(), '{:,d}', 300000)
|
|
62
71
|
test('1.234568e+8', '{:e}', 123456789)
|
|
63
72
|
test('1.23E+8', '{:.2E}', 123456789)
|
|
64
73
|
test('12.35%', '{:.2%}', .123456789)
|
|
65
|
-
test(
|
|
74
|
+
test((1234).toLocaleString(), '{:,}', 1234)
|
|
66
75
|
test('1_234', '{:_d}', 1234)
|
|
67
|
-
|
|
68
|
-
test(
|
|
69
|
-
|
|
70
|
-
test('1
|
|
76
|
+
# 6 is the default: 1234.000000% or 1234,000000%
|
|
77
|
+
test((1234).toLocaleString(undefined, {'minimumFractionDigits': 6}), '{:,f}', 1234)
|
|
78
|
+
# 1234.0% or 1234,0%
|
|
79
|
+
test((1234).toLocaleString(undefined, {'minimumFractionDigits': 1}) + '%', '{:,.1%}', 12.34)
|
|
80
|
+
test((1234.57).toLocaleString(), '{:,g}', 1234.567)
|
|
81
|
+
test((1234).toLocaleString(), '{:,g}', 1234)
|
|
71
82
|
fnum = 1234
|
|
72
|
-
ae(f'{fnum:,}',
|
|
83
|
+
ae(f'{fnum:,}', (1234).toLocaleString())
|
|
73
84
|
test('left aligned ', '{:<30}', 'left aligned')
|
|
74
85
|
test(' right aligned', '{:>30}', 'right aligned')
|
|
75
86
|
test(' centered ', '{:^30}', 'centered')
|
package/tools/cli.js
CHANGED
|
@@ -350,7 +350,7 @@ it.
|
|
|
350
350
|
create_group('lint', "[input1.pyj input2.pyj ...]", function(){/*
|
|
351
351
|
Run the RapydScript linter. This will find various
|
|
352
352
|
possible problems in the .pyj files you specify and
|
|
353
|
-
write messages about them to stdout.
|
|
353
|
+
write messages about them to stdout. Use - to read from STDIN.
|
|
354
354
|
The main check it performs is for unused/undefined
|
|
355
355
|
symbols, like pyflakes does for python.
|
|
356
356
|
*/}, function() {/*
|
|
@@ -421,6 +421,11 @@ List all available linter checks, with a brief
|
|
|
421
421
|
description, and exit.
|
|
422
422
|
*/});
|
|
423
423
|
|
|
424
|
+
opt('stdin_filename', '', 'string', 'STDIN', function(){/*
|
|
425
|
+
The filename for data read from STDIN. If not specified
|
|
426
|
+
STDIN is used.
|
|
427
|
+
*/});
|
|
428
|
+
|
|
424
429
|
create_group('test', '[test1 test2...]', function(){/*
|
|
425
430
|
Run RapydScript tests. You can specify the name of
|
|
426
431
|
individual test files to only run tests from those
|
package/tools/compiler.js
CHANGED
|
@@ -48,9 +48,9 @@ function regenerate(code, beautify) {
|
|
|
48
48
|
} else {
|
|
49
49
|
// Return the runtime
|
|
50
50
|
ans = regenerator.compile('', {includeRuntime:true}).code;
|
|
51
|
-
start = ans.indexOf('
|
|
52
|
-
end = ans.lastIndexOf('
|
|
53
|
-
end = ans.lastIndexOf('}
|
|
51
|
+
start = ans.indexOf('=') + 1;
|
|
52
|
+
end = ans.lastIndexOf('typeof');
|
|
53
|
+
end = ans.lastIndexOf('}(', end);
|
|
54
54
|
ans = ans.slice(start + 1, end);
|
|
55
55
|
if (!beautify) {
|
|
56
56
|
var extra = '})()';
|
|
@@ -14,8 +14,8 @@ module.exports = function(compiler, baselib, runjs, name) {
|
|
|
14
14
|
runjs(print_ast(compiler.parse(''), true));
|
|
15
15
|
runjs('var __name__ = "' + (name || '__embedded__') + '";');
|
|
16
16
|
|
|
17
|
-
function print_ast(ast, keep_baselib, keep_docstrings, js_version) {
|
|
18
|
-
var output_options = {omit_baselib:!keep_baselib, write_name
|
|
17
|
+
function print_ast(ast, keep_baselib, keep_docstrings, js_version, private_scope, write_name) {
|
|
18
|
+
var output_options = {omit_baselib:!keep_baselib, write_name:!!write_name, private_scope:!!private_scope, beautify:true, js_version: (js_version || 6), keep_docstrings:keep_docstrings};
|
|
19
19
|
if (keep_baselib) output_options.baselib_plain = baselib;
|
|
20
20
|
var output = new compiler.OutputStream(output_options);
|
|
21
21
|
ast.print(output);
|
|
@@ -36,7 +36,7 @@ module.exports = function(compiler, baselib, runjs, name) {
|
|
|
36
36
|
'scoped_flags': scoped_flags,
|
|
37
37
|
'discard_asserts': opts.discard_asserts,
|
|
38
38
|
});
|
|
39
|
-
var ans = print_ast(this.toplevel,
|
|
39
|
+
var ans = print_ast(this.toplevel, opts.keep_baselib, opts.keep_docstrings, opts.js_version, opts.private_scope, opts.write_name);
|
|
40
40
|
if (classes) {
|
|
41
41
|
var exports = {};
|
|
42
42
|
var self = this;
|
package/tools/export.js
CHANGED
|
@@ -176,9 +176,9 @@ function regenerate(code, beautify) {
|
|
|
176
176
|
} else {
|
|
177
177
|
// Return the runtime
|
|
178
178
|
ans = regenerator.compile('', {includeRuntime:true}).code;
|
|
179
|
-
start = ans.indexOf('
|
|
180
|
-
end = ans.lastIndexOf('
|
|
181
|
-
end = ans.lastIndexOf('}
|
|
179
|
+
start = ans.indexOf('=') + 1;
|
|
180
|
+
end = ans.lastIndexOf('typeof');
|
|
181
|
+
end = ans.lastIndexOf('}(', end);
|
|
182
182
|
ans = ans.slice(start + 1, end);
|
|
183
183
|
if (!beautify) {
|
|
184
184
|
var extra = '})()';
|
package/tools/gettext.js
CHANGED
|
@@ -82,8 +82,11 @@ function entry_to_string(msgid, data) {
|
|
|
82
82
|
data.locations.forEach(function (loc) { ans.push('#: ' + loc); });
|
|
83
83
|
if (data.format) ans.push('#, ' + data.format);
|
|
84
84
|
ans.push('msgid "' + esc(msgid) + '"');
|
|
85
|
-
if (data.plural)
|
|
86
|
-
|
|
85
|
+
if (data.plural) {
|
|
86
|
+
ans.push('msgid_plural "' + esc(data.plural) + '"');
|
|
87
|
+
ans.push('msgstr[0] ""');
|
|
88
|
+
ans.push('msgstr[1] ""');
|
|
89
|
+
} else ans.push('msgstr ""');
|
|
87
90
|
return ans.join('\n');
|
|
88
91
|
}
|
|
89
92
|
|
package/tools/lint.js
CHANGED
|
@@ -39,7 +39,7 @@ var BUILTINS = Object.create(null);
|
|
|
39
39
|
' NodeList alert console Node Symbol NamedNodeMap ρσ_eslice ρσ_delslice Number' +
|
|
40
40
|
' Boolean encodeURIComponent decodeURIComponent setTimeout setInterval' +
|
|
41
41
|
' setImmediate clearTimeout clearInterval clearImmediate requestAnimationFrame' +
|
|
42
|
-
' id repr sorted __name__ equals get_module ρσ_str jstype divmod'
|
|
42
|
+
' id repr sorted __name__ equals get_module ρσ_str jstype divmod NaN'
|
|
43
43
|
).split(' ').forEach(function(x) { BUILTINS[x] = true; });
|
|
44
44
|
|
|
45
45
|
Object.keys(RapydScript.NATIVE_CLASSES).forEach(function (name) { BUILTINS[name] = true; });
|
|
@@ -280,6 +280,18 @@ function Linter(toplevel, filename, code, options) {
|
|
|
280
280
|
this.handle_assign = function() {
|
|
281
281
|
var node = this.current_node;
|
|
282
282
|
|
|
283
|
+
var handle_destructured = function(self, flat) {
|
|
284
|
+
for (var i = 0; i < flat.length; i++) {
|
|
285
|
+
var cnode = flat[i];
|
|
286
|
+
if (cnode instanceof RapydScript.AST_SymbolRef) {
|
|
287
|
+
self.current_node = cnode;
|
|
288
|
+
cnode.lint_visited = true;
|
|
289
|
+
self.add_binding(cnode.name);
|
|
290
|
+
self.current_node = node;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
283
295
|
if (node.left instanceof RapydScript.AST_SymbolRef) {
|
|
284
296
|
node.left.lint_visited = node.operator === '='; // Could be compound assignment like: +=
|
|
285
297
|
if (node.operator === '=') {
|
|
@@ -292,15 +304,10 @@ function Linter(toplevel, filename, code, options) {
|
|
|
292
304
|
} else if (node.left instanceof RapydScript.AST_Array) {
|
|
293
305
|
// destructuring assignment: a, b = 1, 2
|
|
294
306
|
var flat = node.left.flatten();
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
cnode.lint_visited = true;
|
|
300
|
-
this.add_binding(cnode.name);
|
|
301
|
-
this.current_node = node;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
307
|
+
handle_destructured(this, node.left.flatten());
|
|
308
|
+
|
|
309
|
+
} else if (node.left instanceof RapydScript.AST_Seq && node.left.car instanceof RapydScript.AST_SymbolRef) {
|
|
310
|
+
handle_destructured(this, node.left.to_array());
|
|
304
311
|
}
|
|
305
312
|
|
|
306
313
|
};
|
|
@@ -557,7 +564,7 @@ function lint_code(code, options) {
|
|
|
557
564
|
// CLI {{{
|
|
558
565
|
|
|
559
566
|
function read_whole_file(filename, cb) {
|
|
560
|
-
if (!filename) {
|
|
567
|
+
if (!filename || filename === '-') {
|
|
561
568
|
var chunks = [];
|
|
562
569
|
process.stdin.setEncoding('utf-8');
|
|
563
570
|
process.stdin.on('data', function (chunk) {
|
|
@@ -646,6 +653,10 @@ module.exports.cli = function(argv, base_path, src_path, lib_path) {
|
|
|
646
653
|
if (argv.globals) argv.globals.split(',').forEach(function(sym) { builtins[sym] = true; });
|
|
647
654
|
if (argv.noqa) argv.noqa.split(',').forEach(function(sym) { noqa[sym] = true; });
|
|
648
655
|
|
|
656
|
+
function path_for_filename(x) {
|
|
657
|
+
return x === '-' ? argv.stdin_filename : x;
|
|
658
|
+
}
|
|
659
|
+
|
|
649
660
|
function lint_single_file(err, code) {
|
|
650
661
|
var output, final_builtins = merge(builtins), final_noqa = merge(noqa), rl;
|
|
651
662
|
if (err) {
|
|
@@ -654,7 +665,7 @@ module.exports.cli = function(argv, base_path, src_path, lib_path) {
|
|
|
654
665
|
}
|
|
655
666
|
|
|
656
667
|
// Read setup.cfg
|
|
657
|
-
rl = get_ini(path.dirname(files[0]));
|
|
668
|
+
rl = get_ini(path.dirname(path_for_filename(files[0])));
|
|
658
669
|
var g = {};
|
|
659
670
|
(rl.globals || rl.builtins || '').split(',').forEach(function (x) { g[x.trim()] = true; });
|
|
660
671
|
final_builtins = merge(final_builtins, g);
|
|
@@ -674,7 +685,7 @@ module.exports.cli = function(argv, base_path, src_path, lib_path) {
|
|
|
674
685
|
});
|
|
675
686
|
|
|
676
687
|
// Lint!
|
|
677
|
-
if (lint_code(code, {filename:files[0], builtins:final_builtins, noqa:final_noqa, errorformat:argv.errorformat || false}).length) all_ok = false;
|
|
688
|
+
if (lint_code(code, {filename:path_for_filename(files[0]), builtins:final_builtins, noqa:final_noqa, errorformat:argv.errorformat || false}).length) all_ok = false;
|
|
678
689
|
|
|
679
690
|
files = files.slice(1);
|
|
680
691
|
if (files.length) {
|
package/tools/msgfmt.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"use strict"; /*jshint node:true */
|
|
8
8
|
|
|
9
9
|
function unesc(string) {
|
|
10
|
-
return string.replace(
|
|
10
|
+
return string.replace(/\\"/g, '"').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\\\/g, '\\');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function parse(data, on_error) {
|
package/web-repl/env.js
CHANGED
|
@@ -47,6 +47,10 @@ var builtin_modules = {
|
|
|
47
47
|
|
|
48
48
|
'fs': {
|
|
49
49
|
'readFileSync': function readfile(name) {
|
|
50
|
+
if (namespace.virtual_file_system && namespace.virtual_file_system.read_file_sync) {
|
|
51
|
+
data = namespace.virtual_file_system.read_file_sync(name);
|
|
52
|
+
if (data !== null) return data;
|
|
53
|
+
}
|
|
50
54
|
var data = namespace.file_data[name];
|
|
51
55
|
if (data) return data;
|
|
52
56
|
data = write_cache[name];
|
|
@@ -57,7 +61,9 @@ var builtin_modules = {
|
|
|
57
61
|
},
|
|
58
62
|
|
|
59
63
|
'writeFileSync': function writefile(name, data) {
|
|
60
|
-
|
|
64
|
+
if (namespace.virtual_file_system && namespace.virtual_file_system.write_file_sync) {
|
|
65
|
+
namespace.virtual_file_system.write_file_sync(name, data);
|
|
66
|
+
} else write_cache[name] = data;
|
|
61
67
|
},
|
|
62
68
|
|
|
63
69
|
},
|
package/.appveyor.yml
DELETED
package/.npmignore
DELETED