rapydscript-ng 0.8.2 → 0.8.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/bin/build.ts +29 -0
  3. package/local-agent.md +4 -0
  4. package/package.json +1 -1
  5. package/release/baselib-plain-pretty.js +85 -61
  6. package/release/baselib-plain-ugly.js +3 -3
  7. package/release/compiler.js +9661 -9540
  8. package/release/signatures.json +26 -26
  9. package/src/ast.pyj +169 -64
  10. package/src/baselib-builtins.pyj +35 -14
  11. package/src/baselib-containers.pyj +70 -40
  12. package/src/baselib-internal.pyj +20 -8
  13. package/src/baselib-itertools.pyj +6 -2
  14. package/src/baselib-str.pyj +74 -28
  15. package/src/errors.pyj +4 -1
  16. package/src/lib/aes.pyj +664 -35
  17. package/src/lib/elementmaker.pyj +105 -13
  18. package/src/lib/encodings.pyj +31 -7
  19. package/src/lib/gettext.pyj +6 -3
  20. package/src/lib/math.pyj +38 -22
  21. package/src/lib/pythonize.pyj +5 -3
  22. package/src/lib/random.pyj +13 -5
  23. package/src/lib/re.pyj +81 -18
  24. package/src/lib/traceback.pyj +42 -10
  25. package/src/lib/uuid.pyj +2 -1
  26. package/src/output/classes.pyj +70 -26
  27. package/src/output/codegen.pyj +92 -20
  28. package/src/output/comments.pyj +11 -4
  29. package/src/output/exceptions.pyj +17 -4
  30. package/src/output/functions.pyj +145 -26
  31. package/src/output/literals.pyj +7 -2
  32. package/src/output/loops.pyj +79 -23
  33. package/src/output/modules.pyj +41 -12
  34. package/src/output/operators.pyj +154 -31
  35. package/src/output/statements.pyj +38 -10
  36. package/src/output/stream.pyj +43 -12
  37. package/src/output/utils.pyj +10 -3
  38. package/src/parse.pyj +740 -259
  39. package/src/string_interpolation.pyj +4 -1
  40. package/src/tokenizer.pyj +314 -57
  41. package/src/unicode_aliases.pyj +4 -2
  42. package/src/utils.pyj +19 -5
  43. package/test/functions.pyj +8 -0
  44. package/test/generic.pyj +9 -0
  45. package/test/lsp.pyj +16 -0
  46. package/test/str.pyj +10 -0
  47. package/tools/cli.mjs +4 -3
  48. package/tools/compile.mjs +9 -3
  49. package/tools/compiler.mjs +0 -6
  50. package/tools/fmt.mjs +41 -2
  51. package/tools/lint-worker.mjs +107 -0
  52. package/tools/lint.mjs +134 -8
  53. package/tools/lsp.mjs +11 -1
  54. package/tree-sitter/grammar.js +27 -6
  55. package/tree-sitter/queries/highlights.scm +10 -0
  56. package/tree-sitter/src/grammar.json +130 -5
  57. package/tree-sitter/src/node-types.json +73 -0
  58. package/tree-sitter/src/parser.c +119589 -114993
  59. package/tree-sitter/src/scanner.c +275 -17
  60. package/tree-sitter/test/corpus/strings.txt +41 -5
@@ -78,10 +78,17 @@ def _decode_source_map(smap):
78
78
  prev_src_line = src_line
79
79
  src_col = prev_src_col + fields[3]
80
80
  prev_src_col = src_col
81
- src_file = sources[src_idx] if src_idx >= 0 and src_idx < sources.length else ''
81
+ src_file = (
82
+ sources[src_idx]
83
+ if src_idx >= 0 and src_idx < sources.length
84
+ else ''
85
+ )
82
86
  if source_root and src_file:
83
87
  src_file = source_root + src_file
84
- line_entries.push({'gen_col': gen_col, 'src_file': src_file, 'src_line': src_line, 'src_col': src_col})
88
+ line_entries.push({
89
+ 'gen_col': gen_col, 'src_file': src_file,
90
+ 'src_line': src_line, 'src_col': src_col
91
+ })
85
92
  elif fields.length >= 1:
86
93
  prev_col += fields[0]
87
94
  decoded.push(line_entries)
@@ -106,21 +113,37 @@ def _parse_stack_frame(line):
106
113
  # Chrome/Node: " at functionName (file:line:col)"
107
114
  m = /^\s*at\s+(.*?)\s+\((.+):(\d+):(\d+)\)/.exec(line)
108
115
  if m:
109
- return {'func': m[1] or None, 'file': m[2], 'line': parseInt(m[3], 10) - 1, 'col': parseInt(m[4], 10) - 1}
116
+ return {
117
+ 'func': m[1] or None,
118
+ 'file': m[2],
119
+ 'line': parseInt(m[3], 10) - 1,
120
+ 'col': parseInt(m[4], 10) - 1,
121
+ }
110
122
  # Chrome/Node: " at file:line:col"
111
123
  m = /^\s*at (.+):(\d+):(\d+)$/.exec(line)
112
124
  if m:
113
- return {'func': None, 'file': m[1], 'line': parseInt(m[2], 10) - 1, 'col': parseInt(m[3], 10) - 1}
125
+ return {
126
+ 'func': None,
127
+ 'file': m[1],
128
+ 'line': parseInt(m[2], 10) - 1,
129
+ 'col': parseInt(m[3], 10) - 1,
130
+ }
114
131
  # Firefox: "functionName@file:line:col"
115
132
  m = /^(.*?)@(.+):(\d+):(\d+)$/.exec(line)
116
133
  if m:
117
- return {'func': m[1] or None, 'file': m[2], 'line': parseInt(m[3], 10) - 1, 'col': parseInt(m[4], 10) - 1}
134
+ return {
135
+ 'func': m[1] or None,
136
+ 'file': m[2],
137
+ 'line': parseInt(m[3], 10) - 1,
138
+ 'col': parseInt(m[4], 10) - 1,
139
+ }
118
140
  return None
119
141
 
120
142
 
121
143
  def _get_decoded_map():
122
144
  if _traceback_state['decoded'] is None and _traceback_state['source_map']:
123
- _traceback_state['decoded'] = _decode_source_map(_traceback_state['source_map'])
145
+ _traceback_state['decoded'] = _decode_source_map(
146
+ _traceback_state['source_map'])
124
147
  return _traceback_state['decoded']
125
148
 
126
149
 
@@ -131,7 +154,8 @@ def _get_internal_traceback(err):
131
154
  for i, line in enumerate(lines):
132
155
  if i > 0:
133
156
  line = line.trim()
134
- if line.startsWith('at new ' + err.name) or line.startsWith(err.name + '@'):
157
+ if (line.startsWith('at new ' + err.name) or
158
+ line.startsWith(err.name + '@')):
135
159
  # this is the constructor for a RapydScript Exception
136
160
  start_line_idx = i + 1
137
161
  break
@@ -140,7 +164,10 @@ def _get_internal_traceback(err):
140
164
  for i, xline in enumerate(lines):
141
165
  if i > 0:
142
166
  line = xline.trim()
143
- if v"line.startsWith('at ') || line.includes('@') || /:\d+:\d+$/.test(line)":
167
+ if (
168
+ v"line.startsWith('at ') || line.includes('@')" or
169
+ v"/:\d+:\d+$/.test(line)"
170
+ ):
144
171
  start_line_idx = i
145
172
  break
146
173
  frame_lines = lines[start_line_idx:]
@@ -153,7 +180,11 @@ def _get_internal_traceback(err):
153
180
  if frame:
154
181
  mapping = _find_mapping(decoded, frame.line, frame.col)
155
182
  if mapping:
156
- loc = ' File "' + mapping.src_file + '", line ' + (mapping.src_line + 1) + ', col ' + (mapping.src_col + 1)
183
+ loc = (
184
+ ' File "' + mapping.src_file + '", line ' +
185
+ (mapping.src_line + 1) + ', col ' +
186
+ (mapping.src_col + 1)
187
+ )
157
188
  if frame.func:
158
189
  loc += ', in ' + frame.func
159
190
  mapped_lines.push(loc)
@@ -177,7 +208,8 @@ def format_exception(exc, limit):
177
208
  js_lines.push(e)
178
209
  js_lines = v"['Traceback (most recent call last):'].concat(js_lines)"
179
210
  if rs_lines.length > 0:
180
- js_lines = js_lines.concat(['', 'Mapped Traceback (RapydScript):']).concat(rs_lines)
211
+ js_lines = js_lines.concat(
212
+ ['', 'Mapped Traceback (RapydScript):']).concat(rs_lines)
181
213
  return [l + '\n' for l in js_lines]
182
214
  return [exc.toString()]
183
215
 
package/src/lib/uuid.pyj CHANGED
@@ -29,7 +29,8 @@ def uuid4_bytes():
29
29
 
30
30
  def as_str():
31
31
  h = this.hex
32
- return h[:8] + '-' + h[8:12] + '-' + h[12:16] + '-' + h[16:20] + '-' + h[20:]
32
+ return (h[:8] + '-' + h[8:12] + '-' + h[12:16] +
33
+ '-' + h[16:20] + '-' + h[20:])
33
34
 
34
35
 
35
36
  def uuid4():
@@ -34,13 +34,16 @@ def print_class(output):
34
34
 
35
35
  # decorate the method
36
36
  if stmt.decorators and stmt.decorators.length:
37
- decorate(stmt.decorators, output, def (): function_definition(stmt, output, strip_first, True);)
37
+ decorate(
38
+ stmt.decorators, output,
39
+ def (): function_definition(stmt, output, strip_first, True);)
38
40
  output.end_statement()
39
41
  else:
40
42
  function_definition(stmt, output, strip_first)
41
43
  if not is_property:
42
44
  output.end_statement()
43
- fname = self.name.name + ('.' if is_static else '.prototype.') + name
45
+ fname = (self.name.name +
46
+ ('.' if is_static else '.prototype.') + name)
44
47
  function_annotation(stmt, output, strip_first, fname)
45
48
 
46
49
  def define_default_method(name, body):
@@ -51,8 +54,12 @@ def print_class(output):
51
54
 
52
55
  def add_hidden_property(name, proceed):
53
56
  output.indent(), output.print('Object.defineProperty(')
54
- self.name.print(output), output.print('.prototype'), output.comma(), output.print(JSON.stringify(name)), output.comma()
55
- output.spaced('{value:', ''), proceed(), output.print('})'), output.end_statement()
57
+ self.name.print(output), output.print('.prototype')
58
+ output.comma(), output.print(JSON.stringify(name)), output.comma()
59
+ output.spaced(
60
+ '{value:',
61
+ ''
62
+ ), proceed(), output.print('})'), output.end_statement()
56
63
 
57
64
  # generate constructor
58
65
  def write_constructor():
@@ -64,15 +71,22 @@ def print_class(output):
64
71
 
65
72
  output.with_block(def ():
66
73
  output.indent()
67
- output.spaced('if', '(this.ρσ_object_id', '===', 'undefined)', 'Object.defineProperty(this,', '"ρσ_object_id",', '{"value":++ρσ_object_counter})')
74
+ output.spaced(
75
+ 'if', '(this.ρσ_object_id',
76
+ '===', 'undefined)',
77
+ 'Object.defineProperty(this,',
78
+ '"ρσ_object_id",',
79
+ '{"value":++ρσ_object_counter})')
68
80
  output.end_statement()
69
81
  if self.bound.length:
70
82
  output.indent()
71
- self.name.print(output), output.print('.prototype.__bind_methods__.call(this)')
83
+ self.name.print(output)
84
+ output.print('.prototype.__bind_methods__.call(this)')
72
85
  output.end_statement()
73
86
  output.indent()
74
87
  self.name.print(output)
75
- output.print('.prototype.__init__.apply(this'), output.comma(), output.print('arguments)')
88
+ output.print('.prototype.__init__.apply(this')
89
+ output.comma(), output.print('arguments)')
76
90
  output.end_statement()
77
91
  )
78
92
 
@@ -116,15 +130,18 @@ def print_class(output):
116
130
  if self.bases.length:
117
131
  for v'var i = self.bases.length - 1; i >= 0; i--':
118
132
  base = self.bases[i]
119
- output.indent(), base.print(output), output.spaced('.prototype.__bind_methods__', '&&', '')
120
- base.print(output), output.print('.prototype.__bind_methods__.call(this)')
133
+ output.indent(), base.print(output)
134
+ output.spaced('.prototype.__bind_methods__', '&&', '')
135
+ base.print(output)
136
+ output.print('.prototype.__bind_methods__.call(this)')
121
137
  output.end_statement()
122
138
  for bname in self.bound:
123
139
  if seen_methods[bname] or self.dynamic_properties[bname]:
124
140
  continue
125
141
  seen_methods[bname] = True
126
142
  output.indent(), output.assign('this.' + bname)
127
- self.name.print(output), output.print('.prototype.' + bname + '.bind(this)')
143
+ self.name.print(output)
144
+ output.print('.prototype.' + bname + '.bind(this)')
128
145
  output.end_statement()
129
146
  )
130
147
  )
@@ -135,20 +152,32 @@ def print_class(output):
135
152
  output.indent()
136
153
  output.print('Object.defineProperties')
137
154
  output.with_parens(def ():
138
- self.name.print(output), output.print('.prototype'), output.comma(), output.space(), output.with_block(def ():
155
+ self.name.print(output), output.print('.prototype')
156
+ output.comma(), output.space()
157
+ output.with_block(def ():
139
158
  for name in property_names:
140
159
  prop = self.dynamic_properties[name]
141
- output.indent(), output.print(JSON.stringify(name) + ':'), output.space()
160
+ output.indent()
161
+ output.print(JSON.stringify(name) + ':'), output.space()
142
162
  output.with_block(def ():
143
- output.indent(), output.print('"enumerable":'), output.space(), output.print('true'), output.comma(), output.newline()
163
+ output.indent()
164
+ output.print('"enumerable":'), output.space()
165
+ output.print('true'), output.comma(), output.newline()
144
166
  if prop.getter:
145
- output.indent(), output.print('"get":'), output.space()
146
- define_method(prop.getter, True), output.comma(), output.newline()
167
+ output.indent()
168
+ output.print('"get":'), output.space()
169
+ define_method(prop.getter, True)
170
+ output.comma(), output.newline()
147
171
  output.indent(), output.print('"set":'), output.space()
148
172
  if prop.setter:
149
173
  define_method(prop.setter, True), output.newline()
150
174
  else:
151
- output.spaced('function', '()', '{', '''throw new AttributeError("can't set attribute")''', '}'), output.newline()
175
+ output.spaced(
176
+ 'function', '()', '{',
177
+ '''throw new AttributeError''' +
178
+ '''("can't set attribute")''',
179
+ '}')
180
+ output.newline()
152
181
  )
153
182
  output.comma(), output.newline()
154
183
  )
@@ -182,10 +211,17 @@ def print_class(output):
182
211
  defined_methods[stmt.name.name] = True
183
212
  sname = stmt.name.name
184
213
  if sname is '__init__':
185
- # Copy argument handling data so that kwarg interpolation works when calling the constructor
186
- for attr in ['.__argnames__', '.__handles_kwarg_interpolation__']:
187
- output.indent(), self.name.print(output), output.assign(attr)
188
- self.name.print(output), output.print('.prototype.__init__' + attr), output.end_statement()
214
+ # Copy argument handling data so that kwarg interpolation
215
+ # works when calling the constructor
216
+ for attr in [
217
+ '.__argnames__',
218
+ '.__handles_kwarg_interpolation__',
219
+ ]:
220
+ output.indent()
221
+ self.name.print(output), output.assign(attr)
222
+ self.name.print(output)
223
+ output.print('.prototype.__init__' + attr)
224
+ output.end_statement()
189
225
  if sname is '__iter__':
190
226
  class_def('ρσ_iterator_symbol', True)
191
227
  self.name.print(output)
@@ -198,9 +234,14 @@ def print_class(output):
198
234
  if not defined_methods['__repr__']:
199
235
  define_default_method('__repr__', def ():
200
236
  if self.parent:
201
- output.print('if('), self.parent.print(output), output.spaced('.prototype.__repr__)', 'return', self.parent)
202
- output.print('.prototype.__repr__.call(this)'), output.end_statement()
203
- output.indent(), output.spaced('return', '"<"', '+', '__name__', '+', '"."', '+', 'this.constructor.name', '')
237
+ output.print('if('), self.parent.print(output)
238
+ output.spaced('.prototype.__repr__)', 'return', self.parent)
239
+ output.print('.prototype.__repr__.call(this)')
240
+ output.end_statement()
241
+ output.indent()
242
+ output.spaced(
243
+ 'return', '"<"', '+', '__name__', '+',
244
+ '"."', '+', 'this.constructor.name', '')
204
245
  output.spaced('+', '" #"', '+', 'this.ρσ_object_id', '+', '">"')
205
246
  output.end_statement()
206
247
  )
@@ -208,8 +249,10 @@ def print_class(output):
208
249
  if not defined_methods['__str__']:
209
250
  define_default_method('__str__', def ():
210
251
  if self.parent:
211
- output.print('if('), self.parent.print(output), output.spaced('.prototype.__str__)', 'return', self.parent)
212
- output.print('.prototype.__str__.call(this)'), output.end_statement()
252
+ output.print('if('), self.parent.print(output)
253
+ output.spaced('.prototype.__str__)', 'return', self.parent)
254
+ output.print('.prototype.__str__.call(this)')
255
+ output.end_statement()
213
256
  output.spaced('return', 'this.__repr__()')
214
257
  output.end_statement()
215
258
  )
@@ -234,7 +277,8 @@ def print_class(output):
234
277
  output.print(')'), output.end_statement()
235
278
 
236
279
  # Docstring
237
- if self.docstrings and self.docstrings.length and output.options.keep_docstrings:
280
+ if (self.docstrings and self.docstrings.length
281
+ and output.options.keep_docstrings):
238
282
  add_hidden_property('__doc__', def ():
239
283
  output.print(JSON.stringify(create_doctring(self.docstrings)))
240
284
  )
@@ -3,32 +3,94 @@
3
3
  from __python__ import hash_literals
4
4
 
5
5
  from ast import (
6
- AST_Array, AST_Assign, AST_BaseCall, AST_Binary, AST_BlockStatement, AST_Break,
7
- AST_Class, AST_Conditional, AST_Constant, AST_Continue,
8
- AST_Debugger, AST_Definitions, AST_Directive, AST_Do, AST_Dot, is_node_type,
9
- AST_EmptyStatement, AST_Exit, AST_ExpressiveObject, AST_ForIn,
10
- AST_ForJS, AST_Function, AST_Hole, AST_If, AST_Imports, AST_Infinity,
11
- AST_Lambda, AST_ListComprehension, AST_LoopControl, AST_NaN, AST_New, AST_Node,
12
- AST_Number, AST_Object, AST_ObjectKeyVal, AST_ObjectProperty, AST_PropAccess,
13
- AST_RegExp, AST_Return, AST_Set, AST_Seq, AST_SimpleStatement, AST_Splice,
14
- AST_Statement, AST_StatementWithBody, AST_String, AST_Sub, AST_ItemAccess,
15
- AST_Symbol, AST_This, AST_Throw, AST_Toplevel, AST_Try, AST_Unary,
16
- AST_UnaryPrefix, AST_Undefined, AST_Var, AST_VarDef, AST_Assert,
17
- AST_Verbatim, AST_While, AST_With, AST_Yield, AST_Await, TreeWalker, AST_Existential
6
+ AST_Array,
7
+ AST_Assign,
8
+ AST_BaseCall,
9
+ AST_Binary,
10
+ AST_BlockStatement,
11
+ AST_Break,
12
+ AST_Class,
13
+ AST_Conditional,
14
+ AST_Constant,
15
+ AST_Continue,
16
+ AST_Debugger,
17
+ AST_Definitions,
18
+ AST_Directive,
19
+ AST_Do,
20
+ AST_Dot,
21
+ is_node_type,
22
+ AST_EmptyStatement,
23
+ AST_Exit,
24
+ AST_ExpressiveObject,
25
+ AST_ForIn,
26
+ AST_ForJS,
27
+ AST_Function,
28
+ AST_Hole,
29
+ AST_If,
30
+ AST_Imports,
31
+ AST_Infinity,
32
+ AST_Lambda,
33
+ AST_ListComprehension,
34
+ AST_LoopControl,
35
+ AST_NaN,
36
+ AST_New,
37
+ AST_Node,
38
+ AST_Number,
39
+ AST_Object,
40
+ AST_ObjectKeyVal,
41
+ AST_ObjectProperty,
42
+ AST_PropAccess,
43
+ AST_RegExp,
44
+ AST_Return,
45
+ AST_Set,
46
+ AST_Seq,
47
+ AST_SimpleStatement,
48
+ AST_Splice,
49
+ AST_Statement,
50
+ AST_StatementWithBody,
51
+ AST_String,
52
+ AST_Sub,
53
+ AST_ItemAccess,
54
+ AST_Symbol,
55
+ AST_This,
56
+ AST_Throw,
57
+ AST_Toplevel,
58
+ AST_Try,
59
+ AST_Unary,
60
+ AST_UnaryPrefix,
61
+ AST_Undefined,
62
+ AST_Var,
63
+ AST_VarDef,
64
+ AST_Assert,
65
+ AST_Verbatim,
66
+ AST_While,
67
+ AST_With,
68
+ AST_Yield,
69
+ AST_Await,
70
+ TreeWalker,
71
+ AST_Existential
18
72
  )
19
73
  from output.classes import print_class
20
74
  from output.comments import print_comments
21
75
  from output.exceptions import print_try
22
76
  from output.functions import print_function, print_function_call
23
- from output.literals import print_array, print_obj_literal, print_object, print_set, print_regexp
24
- from output.loops import print_do_loop, print_while_loop, print_for_loop_body, print_for_in, print_list_comprehension
77
+ from output.literals import (
78
+ print_array, print_obj_literal, print_object, print_set, print_regexp
79
+ )
80
+ from output.loops import (
81
+ print_do_loop, print_while_loop, print_for_loop_body, print_for_in,
82
+ print_list_comprehension
83
+ )
25
84
  from output.modules import print_top_level, print_imports
26
85
  from output.operators import (
27
86
  print_getattr, print_getitem, print_rich_getitem, print_splice_assignment,
28
87
  print_unary_prefix, print_binary_op, print_assign,
29
88
  print_conditional, print_seq, print_existential
30
89
  )
31
- from output.statements import print_bracketed, first_in_statement, force_statement, print_with, print_assert
90
+ from output.statements import (
91
+ print_bracketed, first_in_statement, force_statement,
92
+ print_with, print_assert
93
+ )
32
94
  from output.utils import make_block, make_num
33
95
  from parse import PRECEDENCE
34
96
  from utils import noop
@@ -85,7 +147,11 @@ def generate_code():
85
147
  )
86
148
  PARENS(AST_Seq, def (output):
87
149
  p = output.parent()
88
- return is_node_type(p, AST_Unary) or is_node_type(p, AST_VarDef) or is_node_type(p, AST_Dot) or is_node_type(p, AST_ObjectProperty) or is_node_type(p, AST_Conditional)
150
+ return (
151
+ is_node_type(p, AST_Unary) or is_node_type(p, AST_VarDef) or
152
+ is_node_type(p, AST_Dot) or is_node_type(p, AST_ObjectProperty) or
153
+ is_node_type(p, AST_Conditional)
154
+ )
89
155
  )
90
156
  PARENS(AST_Binary, def (output):
91
157
  p = output.parent()
@@ -104,7 +170,9 @@ def generate_code():
104
170
  pp = PRECEDENCE[po]
105
171
  so = this.operator
106
172
  sp = PRECEDENCE[so]
107
- if pp > sp or pp is sp and this is p.right and not (so is po and (so is '*' or so is '&&' or so is '||')):
173
+ if (pp > sp or pp is sp and this is p.right and
174
+ not (so is po and (so is '*' or so is '&&' or
175
+ so is '||'))):
108
176
  return True
109
177
  )
110
178
  PARENS(AST_PropAccess, def (output):
@@ -132,13 +200,16 @@ def generate_code():
132
200
  )
133
201
  PARENS(AST_New, def (output):
134
202
  p = output.parent()
135
- if this.args.args.length is 0 and (is_node_type(p, AST_PropAccess) or is_node_type(p, AST_BaseCall) and p.expression is this):
203
+ if (this.args.args.length is 0 and
204
+ (is_node_type(p, AST_PropAccess) or
205
+ is_node_type(p, AST_BaseCall) and p.expression is this)):
136
206
  # (new foo)(bar)
137
207
  return True
138
208
  )
139
209
  PARENS(AST_Number, def (output):
140
210
  p = output.parent()
141
- if this.value < 0 and is_node_type(p, AST_PropAccess) and p.expression is this:
211
+ if (this.value < 0 and
212
+ is_node_type(p, AST_PropAccess) and p.expression is this):
142
213
  return True
143
214
  )
144
215
  PARENS(AST_NaN, def (output):
@@ -437,7 +508,8 @@ def generate_code():
437
508
 
438
509
  DEFPRINT(AST_Symbol, def (self, output):
439
510
  def_ = self.definition()
440
- output.print_name((def_.mangled_name or def_.name) if def_ else self.name)
511
+ output.print_name(
512
+ (def_.mangled_name or def_.name) if def_ else self.name)
441
513
  )
442
514
  DEFPRINT(AST_Undefined, def (self, output):
443
515
  output.print('void 0')
@@ -26,11 +26,18 @@ def print_comments(self, output):
26
26
  if start and not start._comments_dumped:
27
27
  start._comments_dumped = True
28
28
  comments = start.comments_before
29
- # XXX: ugly fix for https://github.com/mishoo/RapydScript2/issues/112
30
- # if this node is `return` or `throw`, we cannot allow comments before
29
+ # XXX: ugly fix for
30
+ # https://github.com/mishoo/RapydScript2/issues/112
31
+ # if this node is `return` or `throw`, we cannot
32
+ # allow comments before
31
33
  # the returned or thrown value.
32
- if is_node_type(self, AST_Exit) and self.value and self.value.start.comments_before and self.value.start.comments_before.length > 0:
33
- comments = (comments or v'[]').concat(self.value.start.comments_before)
34
+ if is_node_type(
35
+ self,
36
+ AST_Exit
37
+ ) and self.value and self.value.start.comments_before and (
38
+ self.value.start.comments_before.length > 0):
39
+ comments = (comments or v'[]').concat(
40
+ self.value.start.comments_before)
34
41
  self.value.start.comments_before = v'[]'
35
42
 
36
43
  if c.test:
@@ -9,13 +9,25 @@ def print_try(self, output):
9
9
  else_var_name = None
10
10
 
11
11
  def update_output_var(output):
12
- output.indent(), output.assign(else_var_name), output.print('true'), output.end_statement()
12
+ output.indent()
13
+ output.assign(else_var_name)
14
+ output.print('true'), output.end_statement()
13
15
  if self.belse:
14
16
  else_var_name = output.new_try_else_counter()
15
- output.assign('var ' + else_var_name), output.print('false'), output.end_statement(), output.indent()
17
+ output.assign('var ' + else_var_name)
18
+ output.print('false')
19
+ output.end_statement()
20
+ output.indent()
16
21
  output.print('try')
17
22
  output.space()
18
- print_bracketed(self, output, False, None, None, update_output_var if else_var_name else None)
23
+ print_bracketed(
24
+ self,
25
+ output,
26
+ False,
27
+ None,
28
+ None,
29
+ update_output_var if else_var_name else None
30
+ )
19
31
  if self.bcatch:
20
32
  output.space()
21
33
  print_catch(self.bcatch, output)
@@ -37,7 +49,8 @@ def print_catch(self, output):
37
49
  output.space()
38
50
  output.with_block(def ():
39
51
  output.indent()
40
- output.spaced('ρσ_last_exception', '=', 'ρσ_Exception'), output.end_statement()
52
+ output.spaced('ρσ_last_exception', '=', 'ρσ_Exception')
53
+ output.end_statement()
41
54
  output.indent()
42
55
  no_default = True
43
56
  for i, exception in enumerate(self.body):