rapydscript-ng 0.8.0 → 0.8.1

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +8 -0
  3. package/bin/build.ts +117 -0
  4. package/build_wheels.py +133 -0
  5. package/editor-plugins/README.md +80 -0
  6. package/editor-plugins/nvim.lua +321 -0
  7. package/package.json +1 -1
  8. package/publish.py +27 -17
  9. package/release/compiler.js +8125 -8093
  10. package/release/signatures.json +27 -27
  11. package/release/stdlib_modules.json +1 -0
  12. package/src/ast.pyj +379 -279
  13. package/src/baselib-builtins.pyj +47 -26
  14. package/src/baselib-containers.pyj +105 -92
  15. package/src/baselib-errors.pyj +8 -1
  16. package/src/baselib-internal.pyj +35 -20
  17. package/src/baselib-itertools.pyj +13 -7
  18. package/src/baselib-str.pyj +55 -80
  19. package/src/compiler.pyj +4 -4
  20. package/src/errors.pyj +3 -4
  21. package/src/lib/aes.pyj +46 -32
  22. package/src/lib/elementmaker.pyj +11 -9
  23. package/src/lib/encodings.pyj +15 -5
  24. package/src/lib/gettext.pyj +9 -4
  25. package/src/lib/math.pyj +106 -45
  26. package/src/lib/operator.pyj +10 -10
  27. package/src/lib/pythonize.pyj +2 -1
  28. package/src/lib/random.pyj +28 -21
  29. package/src/lib/re.pyj +490 -17
  30. package/src/lib/traceback.pyj +7 -2
  31. package/src/lib/uuid.pyj +2 -2
  32. package/src/output/classes.pyj +28 -27
  33. package/src/output/codegen.pyj +80 -83
  34. package/src/output/comments.pyj +8 -8
  35. package/src/output/exceptions.pyj +20 -21
  36. package/src/output/functions.pyj +37 -26
  37. package/src/output/literals.pyj +14 -10
  38. package/src/output/loops.pyj +63 -59
  39. package/src/output/modules.pyj +52 -23
  40. package/src/output/operators.pyj +40 -29
  41. package/src/output/statements.pyj +20 -14
  42. package/src/output/stream.pyj +33 -34
  43. package/src/output/utils.pyj +12 -8
  44. package/src/parse.pyj +234 -233
  45. package/src/string_interpolation.pyj +5 -3
  46. package/src/tokenizer.pyj +176 -148
  47. package/src/utils.pyj +31 -14
  48. package/test/fmt.pyj +94 -4
  49. package/test/generic.pyj +9 -0
  50. package/test/lsp.pyj +35 -0
  51. package/test/str.pyj +8 -0
  52. package/tools/cli.mjs +25 -4
  53. package/tools/compile.mjs +7 -3
  54. package/tools/compiler.mjs +34 -2
  55. package/tools/fmt.mjs +262 -22
  56. package/tools/ini.mjs +112 -1
  57. package/tools/lsp.mjs +56 -6
  58. package/tools/repl.mjs +5 -2
  59. package/tools/self.mjs +15 -0
  60. package/tools/test.mjs +100 -0
  61. package/tools/web_repl_export.mjs +4 -0
  62. package/tree-sitter/package.json +1 -1
  63. package/tree-sitter/tree-sitter.json +1 -1
  64. package/editor-plugins/nvim/rapydscript/README.md +0 -184
  65. package/editor-plugins/nvim/rapydscript/bin/rapydscript.so +0 -0
  66. package/editor-plugins/nvim/rapydscript/ftdetect/rapydscript.lua +0 -10
  67. package/editor-plugins/nvim/rapydscript/lua/rapydscript/health.lua +0 -88
  68. package/editor-plugins/nvim/rapydscript/lua/rapydscript/init.lua +0 -279
  69. /package/tree-sitter/queries/{rapydscript/highlights.scm → highlights.scm} +0 -0
  70. /package/tree-sitter/queries/{rapydscript/indents.scm → indents.scm} +0 -0
  71. /package/tree-sitter/queries/{rapydscript/injections.scm → injections.scm} +0 -0
  72. /package/tree-sitter/queries/{rapydscript/locals.scm → locals.scm} +0 -0
@@ -12,6 +12,7 @@
12
12
  # .value
13
13
  decimal_sep = (1.1).toLocaleString()[1]
14
14
 
15
+
15
16
  def ρσ_repr_js_builtin(x, as_array):
16
17
  ans = v'[]'
17
18
  b = '{}'
@@ -26,6 +27,7 @@ def ρσ_repr_js_builtin(x, as_array):
26
27
  ans.push(JSON.stringify(key) + ':' + ρσ_repr(x[key]))
27
28
  return b[0] + ans.join(', ') + b[1]
28
29
 
30
+
29
31
  def ρσ_html_element_to_string(elem):
30
32
  attrs = v'[]'
31
33
  for attr in elem.attributes:
@@ -39,6 +41,7 @@ def ρσ_html_element_to_string(elem):
39
41
  ans = f'<{elem.tagName}{attrs}>'
40
42
  return ans
41
43
 
44
+
42
45
  def ρσ_repr(x):
43
46
  if x is None:
44
47
  return 'None'
@@ -58,8 +61,8 @@ def ρσ_repr(x):
58
61
  ans = ρσ_repr_js_builtin(x)
59
62
  else:
60
63
  name = Object.prototype.toString.call(x).slice(8, -1)
61
- if "Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".indexOf(name) != -1:
62
- return name + '([' + x.map(def(i): return str.format('0x{:02x}', i);).join(', ') + '])'
64
+ if 'Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.indexOf(name) != -1:
65
+ return name + '([' + x.map(def (i): return str.format('0x{:02x}', i);).join(', ') + '])'
63
66
  if jstype(HTMLElement) is not 'undefined' and v'x instanceof HTMLElement':
64
67
  ans = ρσ_html_element_to_string(x)
65
68
  else:
@@ -73,6 +76,7 @@ def ρσ_repr(x):
73
76
  pass
74
77
  return ans + '' # Ensures we return an object of type string (i.e. primitive value) rather than a String object
75
78
 
79
+
76
80
  def ρσ_str(x):
77
81
  if x is None:
78
82
  return 'None'
@@ -89,8 +93,8 @@ def ρσ_str(x):
89
93
  ans = ρσ_repr_js_builtin(x, True)
90
94
  elif v'typeof x.toString === "function"':
91
95
  name = Object.prototype.toString.call(x).slice(8, -1)
92
- if "Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".indexOf(name) != -1:
93
- return name + '([' + x.map(def(i): return str.format('0x{:02x}', i);).join(', ') + '])'
96
+ if 'Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.indexOf(name) != -1:
97
+ return name + '([' + x.map(def (i): return str.format('0x{:02x}', i);).join(', ') + '])'
94
98
  if jstype(HTMLElement) is not 'undefined' and v'x instanceof HTMLElement':
95
99
  ans = ρσ_html_element_to_string(x)
96
100
  else:
@@ -103,11 +107,11 @@ def ρσ_str(x):
103
107
  ans = ρσ_repr_js_builtin(x)
104
108
  return ans + '' # Ensures we return an object of type string (i.e. primitive value) rather than a String object
105
109
 
106
- define_str_func = def(name, func):
110
+ define_str_func = def (name, func):
107
111
  ρσ_str.prototype[name] = func
108
112
  ρσ_str[name] = f = func.call.bind(func)
109
113
  if func.__argnames__:
110
- Object.defineProperty(f, '__argnames__', {'value':v"['string']".concat(func.__argnames__)})
114
+ Object.defineProperty(f, '__argnames__', {'value': v"['string']".concat(func.__argnames__)})
111
115
 
112
116
  ρσ_orig_split, ρσ_orig_replace = String.prototype.split.call.bind(String.prototype.split), String.prototype.replace.call.bind(String.prototype.replace)
113
117
 
@@ -115,20 +119,17 @@ define_str_func = def(name, func):
115
119
  define_str_func('format', def ():
116
120
  template = this
117
121
  if template is undefined:
118
- raise TypeError("Template is required")
119
- args = Array.from(arguments)
122
+ raise TypeError('Template is required')
123
+ args = Array.from (arguments)
120
124
  kwargs = {}
121
125
  if args[-1] and args[-1][ρσ_kwargs_symbol] is not undefined:
122
126
  kwargs = args[-1]
123
127
  args = args[:-1]
124
-
125
128
  explicit = implicit = False
126
129
  idx = 0
127
130
  split = ρσ_orig_split
128
-
129
131
  if ρσ_str.format._template_resolve_pat is undefined:
130
132
  ρσ_str.format._template_resolve_pat = /[.\[]/
131
-
132
133
  def resolve(arg, object):
133
134
  if not arg:
134
135
  return object
@@ -139,7 +140,6 @@ define_str_func('format', def ():
139
140
  if ans is undefined:
140
141
  raise KeyError(key[:-1] if first is '[' else key)
141
142
  return resolve(rest, ans)
142
-
143
143
  def resolve_format_spec(format_spec):
144
144
  if ρσ_str.format._template_resolve_fs_pat is undefined:
145
145
  ρσ_str.format._template_resolve_fs_pat = /[{]([a-zA-Z0-9_]+)[}]/g
@@ -148,21 +148,17 @@ define_str_func('format', def ():
148
148
  return ''
149
149
  return '' + kwargs[key]
150
150
  )
151
-
152
151
  def set_comma(ans, comma):
153
152
  if comma is not ',':
154
153
  sep = 1234
155
154
  sep = sep.toLocaleString(undefined, v'{useGrouping: true}')[1]
156
155
  ans = str.replace(ans, sep, comma)
157
156
  return ans
158
-
159
157
  def safe_comma(value, comma):
160
158
  try:
161
159
  return set_comma(value.toLocaleString(undefined, v'{useGrouping: true}'), comma)
162
160
  except:
163
161
  return value.toString(10)
164
-
165
-
166
162
  def safe_fixed(value, precision, comma):
167
163
  if not comma:
168
164
  return value.toFixed(precision)
@@ -170,8 +166,6 @@ define_str_func('format', def ():
170
166
  return set_comma(value.toLocaleString(undefined, v'{useGrouping: true, minimumFractionDigits: precision, maximumFractionDigits: precision}'), comma)
171
167
  except:
172
168
  return value.toFixed(precision)
173
-
174
-
175
169
  def apply_formatting(value, format_spec):
176
170
  if format_spec.indexOf('{') is not -1:
177
171
  format_spec = resolve_format_spec(format_spec)
@@ -186,7 +180,6 @@ define_str_func('format', def ():
186
180
  (?:\.(\d+))? # precision
187
181
  ([bcdeEfFgGnosxX%])? # type
188
182
  ///
189
-
190
183
  try:
191
184
  fill, align, sign, fhash, zeropad, width, comma, precision, ftype = format_spec.match(ρσ_str.format._template_format_pat)[1:]
192
185
  except TypeError:
@@ -201,7 +194,6 @@ define_str_func('format', def ():
201
194
  is_int = is_numeric and v'value % 1 === 0'
202
195
  precision = parseInt(precision, 10)
203
196
  lftype = (ftype or '').toLowerCase()
204
-
205
197
  if ftype is 'n':
206
198
  is_numeric = True
207
199
  if is_int:
@@ -210,7 +202,6 @@ define_str_func('format', def ():
210
202
  value = parseInt(value, 10).toLocaleString()
211
203
  else:
212
204
  value = parseFloat(value).toLocaleString()
213
-
214
205
  elif v"['b', 'c', 'd', 'o', 'x']".indexOf(lftype) is not -1:
215
206
  value = parseInt(value, 10)
216
207
  is_numeric = True
@@ -222,7 +213,7 @@ define_str_func('format', def ():
222
213
  elif ftype is 'c':
223
214
  if value > 0xFFFF:
224
215
  code = value - 0x10000
225
- value = String.fromCharCode(0xD800+(code>>10), 0xDC00+(code&0x3FF))
216
+ value = String.fromCharCode(0xD800 + (code >> 10), 0xDC00 + (code & 0x3FF))
226
217
  else:
227
218
  value = String.fromCharCode(value)
228
219
  elif ftype is 'd':
@@ -239,7 +230,6 @@ define_str_func('format', def ():
239
230
  value = value.toLowerCase() if ftype is 'x' else value.toUpperCase()
240
231
  if fhash:
241
232
  value = '0x' + value
242
-
243
233
  elif v"['e','f','g','%']".indexOf(lftype) is not -1:
244
234
  is_numeric = True
245
235
  value = parseFloat(value)
@@ -265,7 +255,6 @@ define_str_func('format', def ():
265
255
  value = value[:-1]
266
256
  if ftype is 'G':
267
257
  value = value.toUpperCase()
268
-
269
258
  else:
270
259
  if comma:
271
260
  value = parseInt(value, 10)
@@ -275,26 +264,20 @@ define_str_func('format', def ():
275
264
  value += '' # Ensure we have a string
276
265
  if not isNaN(precision):
277
266
  value = value[:precision]
278
-
279
267
  value += '' # Ensure we have a string
280
-
281
268
  if is_numeric and sign:
282
269
  nval = v'Number(value)'
283
270
  is_positive = not isNaN(nval) and nval >= 0
284
271
  if is_positive and (sign is ' ' or sign is '+'):
285
272
  value = sign + value
286
-
287
273
  def repeat(char, num):
288
274
  return v'(new Array(num+1)).join(char)'
289
-
290
275
  if is_numeric and width and width[0] is '0':
291
276
  width = width[1:]
292
277
  fill, align = '0', '='
293
-
294
278
  width = parseInt(width or '-1', 10)
295
279
  if isNaN(width):
296
280
  raise ValueError('Invalid width specification: ' + width)
297
-
298
281
  if fill and value.length < width:
299
282
  if align is '<':
300
283
  value = value + repeat(fill, width - value.length)
@@ -305,15 +288,13 @@ define_str_func('format', def ():
305
288
  right = width - left - value.length
306
289
  value = repeat(fill, left) + value + repeat(fill, right)
307
290
  elif align is '=':
308
- if value[0] in "+- ":
291
+ if value[0] in '+- ':
309
292
  value = value[0] + repeat(fill, width - value.length) + value[1:]
310
293
  else:
311
294
  value = repeat(fill, width - value.length) + value
312
295
  else:
313
296
  raise ValueError('Unrecognized alignment: ' + align)
314
-
315
297
  return value
316
-
317
298
  def parse_markup(markup):
318
299
  key = transformer = format_spec = ''
319
300
  pos = 0
@@ -336,7 +317,6 @@ define_str_func('format', def ():
336
317
  format_spec += ch
337
318
  pos += 1
338
319
  return key, transformer, format_spec
339
-
340
320
  def render_markup(markup):
341
321
  nonlocal explicit, implicit, idx
342
322
  key, transformer, format_spec = parse_markup(markup)
@@ -373,8 +353,6 @@ define_str_func('format', def ():
373
353
  if ends_with_equal:
374
354
  ans = f'{key}={ans}'
375
355
  return ans
376
-
377
-
378
356
  ans = ''
379
357
  pos = 0
380
358
  in_brace = 0
@@ -395,7 +373,7 @@ define_str_func('format', def ():
395
373
  markup += ch
396
374
  else:
397
375
  if ch is '{':
398
- if template[pos+1] is '{':
376
+ if template[pos + 1] is '{':
399
377
  pos += 1
400
378
  ans += '{'
401
379
  else:
@@ -403,14 +381,11 @@ define_str_func('format', def ():
403
381
  markup = ''
404
382
  else:
405
383
  ans += ch
406
- if ch is '}' and template[pos+1] is '}':
384
+ if ch is '}' and template[pos + 1] is '}':
407
385
  pos += 1
408
-
409
386
  pos += 1
410
-
411
387
  if in_brace:
412
388
  raise ValueError("expected '}' before end of string")
413
-
414
389
  return ans
415
390
  )
416
391
  # }}}
@@ -422,14 +397,14 @@ define_str_func('capitalize', def ():
422
397
  return string
423
398
  )
424
399
 
425
- define_str_func('center', def(width, fill):
400
+ define_str_func('center', def (width, fill):
426
401
  left = (width - this.length) // 2
427
402
  right = width - left - this.length # noqa:unused-local
428
403
  fill = fill or ' '
429
404
  return v'new Array(left+1).join(fill)' + this + v'new Array(right+1).join(fill)'
430
405
  )
431
406
 
432
- define_str_func('count', def(needle, start, end):
407
+ define_str_func('count', def (needle, start, end):
433
408
  string = this
434
409
  start = start or 0
435
410
  end = end or string.length
@@ -449,7 +424,7 @@ define_str_func('count', def(needle, start, end):
449
424
  return ans
450
425
  )
451
426
 
452
- define_str_func('endswith', def(suffixes, start, end):
427
+ define_str_func('endswith', def (suffixes, start, end):
453
428
  string = this
454
429
  start = start or 0
455
430
  if jstype(suffixes) is 'string':
@@ -463,7 +438,7 @@ define_str_func('endswith', def(suffixes, start, end):
463
438
  return False
464
439
  )
465
440
 
466
- define_str_func('startswith', def(prefixes, start, end):
441
+ define_str_func('startswith', def (prefixes, start, end):
467
442
  start = start or 0
468
443
  if jstype(prefixes) is 'string':
469
444
  prefixes = v'[prefixes]'
@@ -475,7 +450,7 @@ define_str_func('startswith', def(prefixes, start, end):
475
450
  return False
476
451
  )
477
452
 
478
- define_str_func('find', def(needle, start, end):
453
+ define_str_func('find', def (needle, start, end):
479
454
  while start < 0:
480
455
  start += this.length
481
456
  ans = this.indexOf(needle, start)
@@ -487,7 +462,7 @@ define_str_func('find', def(needle, start, end):
487
462
  return ans
488
463
  )
489
464
 
490
- define_str_func('rfind', def(needle, start, end):
465
+ define_str_func('rfind', def (needle, start, end):
491
466
  while end < 0:
492
467
  end += this.length
493
468
  ans = this.lastIndexOf(needle, end - 1)
@@ -499,33 +474,33 @@ define_str_func('rfind', def(needle, start, end):
499
474
  return ans
500
475
  )
501
476
 
502
- define_str_func('index', def(needle, start, end):
477
+ define_str_func('index', def (needle, start, end):
503
478
  ans = ρσ_str.prototype.find.apply(this, arguments)
504
479
  if ans is -1:
505
480
  raise ValueError('substring not found')
506
481
  return ans
507
482
  )
508
483
 
509
- define_str_func('rindex', def(needle, start, end):
484
+ define_str_func('rindex', def (needle, start, end):
510
485
  ans = ρσ_str.prototype.rfind.apply(this, arguments)
511
486
  if ans is -1:
512
487
  raise ValueError('substring not found')
513
488
  return ans
514
489
  )
515
490
 
516
- define_str_func('islower', def():
491
+ define_str_func('islower', def ():
517
492
  return this.length > 0 and this.toLowerCase() is this.toString()
518
493
  )
519
494
 
520
- define_str_func('isupper', def():
495
+ define_str_func('isupper', def ():
521
496
  return this.length > 0 and this.toUpperCase() is this.toString()
522
497
  )
523
498
 
524
- define_str_func('isspace', def():
499
+ define_str_func('isspace', def ():
525
500
  return this.length > 0 and /^\s+$/.test(this)
526
501
  )
527
502
 
528
- define_str_func('join', def(iterable):
503
+ define_str_func('join', def (iterable):
529
504
  if Array.isArray(iterable):
530
505
  return iterable.join(this)
531
506
  ans = ''
@@ -538,7 +513,7 @@ define_str_func('join', def(iterable):
538
513
  return ans
539
514
  )
540
515
 
541
- define_str_func('ljust', def(width, fill):
516
+ define_str_func('ljust', def (width, fill):
542
517
  string = this
543
518
  if width > string.length:
544
519
  fill = fill or ' '
@@ -546,7 +521,7 @@ define_str_func('ljust', def(width, fill):
546
521
  return string
547
522
  )
548
523
 
549
- define_str_func('rjust', def(width, fill):
524
+ define_str_func('rjust', def (width, fill):
550
525
  string = this
551
526
  if width > string.length:
552
527
  fill = fill or ' '
@@ -554,15 +529,15 @@ define_str_func('rjust', def(width, fill):
554
529
  return string
555
530
  )
556
531
 
557
- define_str_func('lower', def():
532
+ define_str_func('lower', def ():
558
533
  return this.toLowerCase()
559
534
  )
560
535
 
561
- define_str_func('upper', def():
536
+ define_str_func('upper', def ():
562
537
  return this.toUpperCase()
563
538
  )
564
539
 
565
- define_str_func('lstrip', def(chars):
540
+ define_str_func('lstrip', def (chars):
566
541
  string = this
567
542
  pos = 0
568
543
  chars = chars or ρσ_str.whitespace
@@ -573,7 +548,7 @@ define_str_func('lstrip', def(chars):
573
548
  return string
574
549
  )
575
550
 
576
- define_str_func('rstrip', def(chars):
551
+ define_str_func('rstrip', def (chars):
577
552
  string = this
578
553
  pos = string.length - 1
579
554
  chars = chars or ρσ_str.whitespace
@@ -584,25 +559,25 @@ define_str_func('rstrip', def(chars):
584
559
  return string
585
560
  )
586
561
 
587
- define_str_func('strip', def(chars):
562
+ define_str_func('strip', def (chars):
588
563
  return ρσ_str.prototype.lstrip.call(ρσ_str.prototype.rstrip.call(this, chars), chars)
589
564
  )
590
565
 
591
- define_str_func('partition', def(sep):
566
+ define_str_func('partition', def (sep):
592
567
  idx = this.indexOf(sep)
593
568
  if idx is -1:
594
569
  return this, '', ''
595
570
  return this[:idx], sep, this[idx + sep.length:]
596
571
  )
597
572
 
598
- define_str_func('rpartition', def(sep):
573
+ define_str_func('rpartition', def (sep):
599
574
  idx = this.lastIndexOf(sep)
600
575
  if idx is -1:
601
576
  return '', '', this
602
577
  return this[:idx], sep, this[idx + sep.length:]
603
578
  )
604
579
 
605
- define_str_func('replace', def(old, repl, count):
580
+ define_str_func('replace', def (old, repl, count):
606
581
  string = this
607
582
  if count is 1:
608
583
  return ρσ_orig_replace(string, old, repl)
@@ -620,7 +595,7 @@ define_str_func('replace', def(old, repl, count):
620
595
  return string
621
596
  )
622
597
 
623
- define_str_func('split', def(sep, maxsplit):
598
+ define_str_func('split', def (sep, maxsplit):
624
599
  if maxsplit is 0:
625
600
  return [this]
626
601
  split = ρσ_orig_split
@@ -649,7 +624,7 @@ define_str_func('split', def(sep, maxsplit):
649
624
  return ans
650
625
  )
651
626
 
652
- define_str_func('rsplit', def(sep, maxsplit):
627
+ define_str_func('rsplit', def (sep, maxsplit):
653
628
  if not maxsplit:
654
629
  return ρσ_str.prototype.split.call(this, sep)
655
630
  split = ρσ_orig_split
@@ -695,7 +670,7 @@ define_str_func('rsplit', def(sep, maxsplit):
695
670
  return ans
696
671
  )
697
672
 
698
- define_str_func('splitlines', def(keepends):
673
+ define_str_func('splitlines', def (keepends):
699
674
  split = ρσ_orig_split
700
675
  if keepends:
701
676
  parts = split(this, /((?:\r?\n)|\r)/)
@@ -710,7 +685,7 @@ define_str_func('splitlines', def(keepends):
710
685
  return ans
711
686
  )
712
687
 
713
- define_str_func('swapcase', def():
688
+ define_str_func('swapcase', def ():
714
689
  ans = v'new Array(this.length)'
715
690
  for v'var i = 0; i < ans.length; i++':
716
691
  a = this[i]
@@ -722,21 +697,21 @@ define_str_func('swapcase', def():
722
697
  return ans.join('')
723
698
  )
724
699
 
725
- define_str_func('zfill', def(width):
700
+ define_str_func('zfill', def (width):
726
701
  string = this
727
702
  if width > string.length:
728
703
  string = v'new Array(width - string.length + 1).join("0")' + string
729
704
  return string
730
705
  )
731
706
 
732
- ρσ_str.uchrs = def(string, with_positions):
707
+ ρσ_str.uchrs = def (string, with_positions):
733
708
  # Return iterator over unicode chars in string. Will yield the unicode
734
709
  # replacement char U+FFFD for broken surrogate pairs
735
710
  return {
736
711
  '_string': string,
737
712
  '_pos': 0,
738
- ρσ_iterator_symbol: def(): return this;,
739
- 'next' : def():
713
+ ρσ_iterator_symbol: def (): return this;,
714
+ 'next': def ():
740
715
  length = this._string.length
741
716
  if this._pos >= length:
742
717
  return {'done': True}
@@ -747,17 +722,17 @@ define_str_func('zfill', def(width):
747
722
  if this._pos < length:
748
723
  # high surrogate, and there is a next character
749
724
  extra = v'this._string.charCodeAt(this._pos++)'
750
- if (extra & 0xDC00) is 0xDC00: # low surrogate
725
+ if (extra & 0xDC00) is 0xDC00: # low surrogate
751
726
  ans = String.fromCharCode(value, extra)
752
- elif (value & 0xDC00) is not 0xDC00: # not a low surrogate
727
+ elif (value & 0xDC00) is not 0xDC00: # not a low surrogate
753
728
  ans = String.fromCharCode(value)
754
729
  if with_positions:
755
- return {'done':False, 'value':[pos, ans]}
730
+ return {'done': False, 'value': [pos, ans]}
756
731
  else:
757
- return {'done':False, 'value':ans}
732
+ return {'done': False, 'value': ans}
758
733
  }
759
734
 
760
- ρσ_str.uslice = def(string, start, end):
735
+ ρσ_str.uslice = def (string, start, end):
761
736
  items = v'[]'
762
737
  iterator = ρσ_str.uchrs(string)
763
738
  r = iterator.next()
@@ -766,7 +741,7 @@ define_str_func('zfill', def(width):
766
741
  r = iterator.next()
767
742
  return items[start or 0:items.length if end is undefined else end].join('')
768
743
 
769
- ρσ_str.ulen = def(string):
744
+ ρσ_str.ulen = def (string):
770
745
  iterator = ρσ_str.uchrs(string)
771
746
  r = iterator.next()
772
747
  ans = 0
@@ -777,11 +752,11 @@ define_str_func('zfill', def(width):
777
752
 
778
753
  ρσ_str.ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
779
754
  ρσ_str.ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
780
- ρσ_str.ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
781
- ρσ_str.digits = '0123456789'
755
+ ρσ_str.ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
756
+ ρσ_str.digits = '0123456789'
782
757
  ρσ_str.punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
783
758
  ρσ_str.printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
784
- ρσ_str.whitespace = ' \t\n\r\x0b\x0c'
759
+ ρσ_str.whitespace = ' \t\n\r\x0b\x0c'
785
760
 
786
761
  v'define_str_func = undefined'
787
762
  v'var str = ρσ_str, repr = ρσ_repr'
package/src/compiler.pyj CHANGED
@@ -3,12 +3,12 @@
3
3
  # Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
4
4
  # globals: console
5
5
 
6
- from utils import DefaultsError, string_template
7
6
  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
7
  from output.codegen import generate_code
8
+ from output.stream import OutputStream
9
+ from parse import parse, NATIVE_CLASSES, compile_time_decorators
10
+ from tokenizer import ALL_KEYWORDS, IDENTIFIER_PAT, tokenizer
11
+ from utils import DefaultsError, string_template
12
12
 
13
13
  generate_code() # create the print methods on the AST nodes
14
14
 
package/src/errors.pyj CHANGED
@@ -2,8 +2,8 @@
2
2
  # License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
3
3
  from __python__ import hash_literals
4
4
 
5
- class SyntaxError(Error):
6
5
 
6
+ class SyntaxError(Error):
7
7
  def __init__(self, message, filename, line, col, pos, is_eof):
8
8
  self.stack = Error().stack
9
9
  self.message = message
@@ -17,14 +17,13 @@ class SyntaxError(Error):
17
17
  self.fileName = filename
18
18
 
19
19
  def toString(self):
20
- ans = self.message + " (line: " + self.line + ", col: " + self.col + ", pos: " + self.pos + ")"
20
+ ans = self.message + ' (line: ' + self.line + ', col: ' + self.col + ', pos: ' + self.pos + ')'
21
21
  if self.filename:
22
22
  ans = self.filename + ':' + ans
23
23
  if self.stack:
24
- ans += "\n\n" + self.stack
24
+ ans += '\n\n' + self.stack
25
25
  return ans
26
26
 
27
27
 
28
28
  class ImportError(SyntaxError):
29
29
  pass
30
-