ether-code 0.1.6 → 0.1.8

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 (45) hide show
  1. package/cli/compiler.js +9 -53
  2. package/cli/ether.js +1 -1
  3. package/generators/css-generator.js +42 -55
  4. package/generators/graphql-generator.js +19 -22
  5. package/generators/html-generator.js +51 -220
  6. package/generators/js-generator.js +76 -157
  7. package/generators/node-generator.js +49 -93
  8. package/generators/php-generator.js +46 -68
  9. package/generators/python-generator.js +35 -54
  10. package/generators/react-generator.js +37 -47
  11. package/generators/ruby-generator.js +59 -119
  12. package/generators/sql-generator.js +42 -63
  13. package/generators/ts-generator.js +59 -133
  14. package/i18n/i18n-css.json +147 -147
  15. package/i18n/i18n-graphql.json +6 -6
  16. package/i18n/i18n-html.json +135 -135
  17. package/i18n/i18n-js.json +107 -107
  18. package/i18n/i18n-node.json +14 -14
  19. package/i18n/i18n-php.json +177 -177
  20. package/i18n/i18n-python.json +16 -16
  21. package/i18n/i18n-react.json +97 -97
  22. package/i18n/i18n-ruby.json +22 -22
  23. package/i18n/i18n-sql.json +153 -153
  24. package/i18n/i18n-ts.json +10 -10
  25. package/lexer/ether-lexer.js +175 -34
  26. package/lexer/tokens.js +6 -6
  27. package/package.json +1 -1
  28. package/parsers/ast-css.js +0 -545
  29. package/parsers/ast-graphql.js +0 -424
  30. package/parsers/ast-html.js +0 -886
  31. package/parsers/ast-js.js +0 -750
  32. package/parsers/ast-node.js +0 -2440
  33. package/parsers/ast-php.js +0 -957
  34. package/parsers/ast-react.js +0 -580
  35. package/parsers/ast-ruby.js +0 -895
  36. package/parsers/ast-ts.js +0 -1352
  37. package/parsers/css-parser.js +0 -1981
  38. package/parsers/graphql-parser.js +0 -2011
  39. package/parsers/html-parser.js +0 -1182
  40. package/parsers/js-parser.js +0 -2564
  41. package/parsers/node-parser.js +0 -2644
  42. package/parsers/php-parser.js +0 -3037
  43. package/parsers/react-parser.js +0 -1035
  44. package/parsers/ruby-parser.js +0 -2680
  45. package/parsers/ts-parser.js +0 -3881
package/parsers/ast-js.js DELETED
@@ -1,750 +0,0 @@
1
- class ASTNode {
2
- constructor(type, loc = null) {
3
- this.type = type
4
- this.loc = loc
5
- }
6
- }
7
-
8
- class Program extends ASTNode {
9
- constructor(body = [], sourceType = 'script', loc = null) {
10
- super('Program', loc)
11
- this.body = body
12
- this.sourceType = sourceType
13
- }
14
- }
15
-
16
- class Identifier extends ASTNode {
17
- constructor(name, loc = null) {
18
- super('Identifier', loc)
19
- this.name = name
20
- }
21
- }
22
-
23
- class Literal extends ASTNode {
24
- constructor(value, raw = null, loc = null) {
25
- super('Literal', loc)
26
- this.value = value
27
- this.raw = raw || String(value)
28
- }
29
- }
30
-
31
- class StringLiteral extends ASTNode {
32
- constructor(value, raw = null, loc = null) {
33
- super('StringLiteral', loc)
34
- this.value = value
35
- this.raw = raw
36
- }
37
- }
38
-
39
- class NumericLiteral extends ASTNode {
40
- constructor(value, raw = null, loc = null) {
41
- super('NumericLiteral', loc)
42
- this.value = value
43
- this.raw = raw
44
- }
45
- }
46
-
47
- class BooleanLiteral extends ASTNode {
48
- constructor(value, loc = null) {
49
- super('BooleanLiteral', loc)
50
- this.value = value
51
- }
52
- }
53
-
54
- class NullLiteral extends ASTNode {
55
- constructor(loc = null) {
56
- super('NullLiteral', loc)
57
- this.value = null
58
- }
59
- }
60
-
61
- class BigIntLiteral extends ASTNode {
62
- constructor(value, raw = null, loc = null) {
63
- super('BigIntLiteral', loc)
64
- this.value = value
65
- this.raw = raw
66
- }
67
- }
68
-
69
- class RegExpLiteral extends ASTNode {
70
- constructor(pattern, flags = '', loc = null) {
71
- super('RegExpLiteral', loc)
72
- this.pattern = pattern
73
- this.flags = flags
74
- }
75
- }
76
-
77
- class TemplateLiteral extends ASTNode {
78
- constructor(quasis = [], expressions = [], loc = null) {
79
- super('TemplateLiteral', loc)
80
- this.quasis = quasis
81
- this.expressions = expressions
82
- }
83
- }
84
-
85
- class TemplateElement extends ASTNode {
86
- constructor(value, tail = false, loc = null) {
87
- super('TemplateElement', loc)
88
- this.value = value
89
- this.tail = tail
90
- }
91
- }
92
-
93
- class TaggedTemplateExpression extends ASTNode {
94
- constructor(tag, quasi, loc = null) {
95
- super('TaggedTemplateExpression', loc)
96
- this.tag = tag
97
- this.quasi = quasi
98
- }
99
- }
100
-
101
- class VariableDeclaration extends ASTNode {
102
- constructor(kind, declarations = [], loc = null) {
103
- super('VariableDeclaration', loc)
104
- this.kind = kind
105
- this.declarations = declarations
106
- }
107
- }
108
-
109
- class VariableDeclarator extends ASTNode {
110
- constructor(id, init = null, loc = null) {
111
- super('VariableDeclarator', loc)
112
- this.id = id
113
- this.init = init
114
- }
115
- }
116
-
117
- class FunctionDeclaration extends ASTNode {
118
- constructor(id, params = [], body, async = false, generator = false, loc = null) {
119
- super('FunctionDeclaration', loc)
120
- this.id = id
121
- this.params = params
122
- this.body = body
123
- this.async = async
124
- this.generator = generator
125
- }
126
- }
127
-
128
- class FunctionExpression extends ASTNode {
129
- constructor(id = null, params = [], body, async = false, generator = false, loc = null) {
130
- super('FunctionExpression', loc)
131
- this.id = id
132
- this.params = params
133
- this.body = body
134
- this.async = async
135
- this.generator = generator
136
- }
137
- }
138
-
139
- class ArrowFunctionExpression extends ASTNode {
140
- constructor(params = [], body, async = false, expression = false, loc = null) {
141
- super('ArrowFunctionExpression', loc)
142
- this.params = params
143
- this.body = body
144
- this.async = async
145
- this.expression = expression
146
- }
147
- }
148
-
149
- class ClassDeclaration extends ASTNode {
150
- constructor(id, superClass = null, body, loc = null) {
151
- super('ClassDeclaration', loc)
152
- this.id = id
153
- this.superClass = superClass
154
- this.body = body
155
- }
156
- }
157
-
158
- class ClassExpression extends ASTNode {
159
- constructor(id = null, superClass = null, body, loc = null) {
160
- super('ClassExpression', loc)
161
- this.id = id
162
- this.superClass = superClass
163
- this.body = body
164
- }
165
- }
166
-
167
- class ClassBody extends ASTNode {
168
- constructor(body = [], loc = null) {
169
- super('ClassBody', loc)
170
- this.body = body
171
- }
172
- }
173
-
174
- class MethodDefinition extends ASTNode {
175
- constructor(key, value, kind = 'method', computed = false, isStatic = false, loc = null) {
176
- super('MethodDefinition', loc)
177
- this.key = key
178
- this.value = value
179
- this.kind = kind
180
- this.computed = computed
181
- this.static = isStatic
182
- }
183
- }
184
-
185
- class PropertyDefinition extends ASTNode {
186
- constructor(key, value = null, computed = false, isStatic = false, loc = null) {
187
- super('PropertyDefinition', loc)
188
- this.key = key
189
- this.value = value
190
- this.computed = computed
191
- this.static = isStatic
192
- }
193
- }
194
-
195
- class PrivateIdentifier extends ASTNode {
196
- constructor(name, loc = null) {
197
- super('PrivateIdentifier', loc)
198
- this.name = name
199
- }
200
- }
201
-
202
- class StaticBlock extends ASTNode {
203
- constructor(body = [], loc = null) {
204
- super('StaticBlock', loc)
205
- this.body = body
206
- }
207
- }
208
-
209
- class BlockStatement extends ASTNode {
210
- constructor(body = [], loc = null) {
211
- super('BlockStatement', loc)
212
- this.body = body
213
- }
214
- }
215
-
216
- class ExpressionStatement extends ASTNode {
217
- constructor(expression, loc = null) {
218
- super('ExpressionStatement', loc)
219
- this.expression = expression
220
- }
221
- }
222
-
223
- class EmptyStatement extends ASTNode {
224
- constructor(loc = null) {
225
- super('EmptyStatement', loc)
226
- }
227
- }
228
-
229
- class ReturnStatement extends ASTNode {
230
- constructor(argument = null, loc = null) {
231
- super('ReturnStatement', loc)
232
- this.argument = argument
233
- }
234
- }
235
-
236
- class BreakStatement extends ASTNode {
237
- constructor(label = null, loc = null) {
238
- super('BreakStatement', loc)
239
- this.label = label
240
- }
241
- }
242
-
243
- class ContinueStatement extends ASTNode {
244
- constructor(label = null, loc = null) {
245
- super('ContinueStatement', loc)
246
- this.label = label
247
- }
248
- }
249
-
250
- class LabeledStatement extends ASTNode {
251
- constructor(label, body, loc = null) {
252
- super('LabeledStatement', loc)
253
- this.label = label
254
- this.body = body
255
- }
256
- }
257
-
258
- class IfStatement extends ASTNode {
259
- constructor(test, consequent, alternate = null, loc = null) {
260
- super('IfStatement', loc)
261
- this.test = test
262
- this.consequent = consequent
263
- this.alternate = alternate
264
- }
265
- }
266
-
267
- class SwitchStatement extends ASTNode {
268
- constructor(discriminant, cases = [], loc = null) {
269
- super('SwitchStatement', loc)
270
- this.discriminant = discriminant
271
- this.cases = cases
272
- }
273
- }
274
-
275
- class SwitchCase extends ASTNode {
276
- constructor(test = null, consequent = [], loc = null) {
277
- super('SwitchCase', loc)
278
- this.test = test
279
- this.consequent = consequent
280
- }
281
- }
282
-
283
- class WhileStatement extends ASTNode {
284
- constructor(test, body, loc = null) {
285
- super('WhileStatement', loc)
286
- this.test = test
287
- this.body = body
288
- }
289
- }
290
-
291
- class DoWhileStatement extends ASTNode {
292
- constructor(body, test, loc = null) {
293
- super('DoWhileStatement', loc)
294
- this.body = body
295
- this.test = test
296
- }
297
- }
298
-
299
- class ForStatement extends ASTNode {
300
- constructor(init, test, update, body, loc = null) {
301
- super('ForStatement', loc)
302
- this.init = init
303
- this.test = test
304
- this.update = update
305
- this.body = body
306
- }
307
- }
308
-
309
- class ForInStatement extends ASTNode {
310
- constructor(left, right, body, loc = null) {
311
- super('ForInStatement', loc)
312
- this.left = left
313
- this.right = right
314
- this.body = body
315
- }
316
- }
317
-
318
- class ForOfStatement extends ASTNode {
319
- constructor(left, right, body, await_ = false, loc = null) {
320
- super('ForOfStatement', loc)
321
- this.left = left
322
- this.right = right
323
- this.body = body
324
- this.await = await_
325
- }
326
- }
327
-
328
- class TryStatement extends ASTNode {
329
- constructor(block, handler = null, finalizer = null, loc = null) {
330
- super('TryStatement', loc)
331
- this.block = block
332
- this.handler = handler
333
- this.finalizer = finalizer
334
- }
335
- }
336
-
337
- class CatchClause extends ASTNode {
338
- constructor(param = null, body, loc = null) {
339
- super('CatchClause', loc)
340
- this.param = param
341
- this.body = body
342
- }
343
- }
344
-
345
- class ThrowStatement extends ASTNode {
346
- constructor(argument, loc = null) {
347
- super('ThrowStatement', loc)
348
- this.argument = argument
349
- }
350
- }
351
-
352
- class WithStatement extends ASTNode {
353
- constructor(object, body, loc = null) {
354
- super('WithStatement', loc)
355
- this.object = object
356
- this.body = body
357
- }
358
- }
359
-
360
- class DebuggerStatement extends ASTNode {
361
- constructor(loc = null) {
362
- super('DebuggerStatement', loc)
363
- }
364
- }
365
-
366
- class BinaryExpression extends ASTNode {
367
- constructor(operator, left, right, loc = null) {
368
- super('BinaryExpression', loc)
369
- this.operator = operator
370
- this.left = left
371
- this.right = right
372
- }
373
- }
374
-
375
- class LogicalExpression extends ASTNode {
376
- constructor(operator, left, right, loc = null) {
377
- super('LogicalExpression', loc)
378
- this.operator = operator
379
- this.left = left
380
- this.right = right
381
- }
382
- }
383
-
384
- class UnaryExpression extends ASTNode {
385
- constructor(operator, argument, prefix = true, loc = null) {
386
- super('UnaryExpression', loc)
387
- this.operator = operator
388
- this.argument = argument
389
- this.prefix = prefix
390
- }
391
- }
392
-
393
- class UpdateExpression extends ASTNode {
394
- constructor(operator, argument, prefix = false, loc = null) {
395
- super('UpdateExpression', loc)
396
- this.operator = operator
397
- this.argument = argument
398
- this.prefix = prefix
399
- }
400
- }
401
-
402
- class AssignmentExpression extends ASTNode {
403
- constructor(operator, left, right, loc = null) {
404
- super('AssignmentExpression', loc)
405
- this.operator = operator
406
- this.left = left
407
- this.right = right
408
- }
409
- }
410
-
411
- class ConditionalExpression extends ASTNode {
412
- constructor(test, consequent, alternate, loc = null) {
413
- super('ConditionalExpression', loc)
414
- this.test = test
415
- this.consequent = consequent
416
- this.alternate = alternate
417
- }
418
- }
419
-
420
- class CallExpression extends ASTNode {
421
- constructor(callee, arguments_ = [], optional = false, loc = null) {
422
- super('CallExpression', loc)
423
- this.callee = callee
424
- this.arguments = arguments_
425
- this.optional = optional
426
- }
427
- }
428
-
429
- class NewExpression extends ASTNode {
430
- constructor(callee, arguments_ = [], loc = null) {
431
- super('NewExpression', loc)
432
- this.callee = callee
433
- this.arguments = arguments_
434
- }
435
- }
436
-
437
- class MemberExpression extends ASTNode {
438
- constructor(object, property, computed = false, optional = false, loc = null) {
439
- super('MemberExpression', loc)
440
- this.object = object
441
- this.property = property
442
- this.computed = computed
443
- this.optional = optional
444
- }
445
- }
446
-
447
- class ChainExpression extends ASTNode {
448
- constructor(expression, loc = null) {
449
- super('ChainExpression', loc)
450
- this.expression = expression
451
- }
452
- }
453
-
454
- class SequenceExpression extends ASTNode {
455
- constructor(expressions = [], loc = null) {
456
- super('SequenceExpression', loc)
457
- this.expressions = expressions
458
- }
459
- }
460
-
461
- class ThisExpression extends ASTNode {
462
- constructor(loc = null) {
463
- super('ThisExpression', loc)
464
- }
465
- }
466
-
467
- class Super extends ASTNode {
468
- constructor(loc = null) {
469
- super('Super', loc)
470
- }
471
- }
472
-
473
- class SpreadElement extends ASTNode {
474
- constructor(argument, loc = null) {
475
- super('SpreadElement', loc)
476
- this.argument = argument
477
- }
478
- }
479
-
480
- class RestElement extends ASTNode {
481
- constructor(argument, loc = null) {
482
- super('RestElement', loc)
483
- this.argument = argument
484
- }
485
- }
486
-
487
- class YieldExpression extends ASTNode {
488
- constructor(argument = null, delegate = false, loc = null) {
489
- super('YieldExpression', loc)
490
- this.argument = argument
491
- this.delegate = delegate
492
- }
493
- }
494
-
495
- class AwaitExpression extends ASTNode {
496
- constructor(argument, loc = null) {
497
- super('AwaitExpression', loc)
498
- this.argument = argument
499
- }
500
- }
501
-
502
- class ArrayExpression extends ASTNode {
503
- constructor(elements = [], loc = null) {
504
- super('ArrayExpression', loc)
505
- this.elements = elements
506
- }
507
- }
508
-
509
- class ObjectExpression extends ASTNode {
510
- constructor(properties = [], loc = null) {
511
- super('ObjectExpression', loc)
512
- this.properties = properties
513
- }
514
- }
515
-
516
- class Property extends ASTNode {
517
- constructor(key, value, kind = 'init', method = false, shorthand = false, computed = false, loc = null) {
518
- super('Property', loc)
519
- this.key = key
520
- this.value = value
521
- this.kind = kind
522
- this.method = method
523
- this.shorthand = shorthand
524
- this.computed = computed
525
- }
526
- }
527
-
528
- class ArrayPattern extends ASTNode {
529
- constructor(elements = [], loc = null) {
530
- super('ArrayPattern', loc)
531
- this.elements = elements
532
- }
533
- }
534
-
535
- class ObjectPattern extends ASTNode {
536
- constructor(properties = [], loc = null) {
537
- super('ObjectPattern', loc)
538
- this.properties = properties
539
- }
540
- }
541
-
542
- class AssignmentPattern extends ASTNode {
543
- constructor(left, right, loc = null) {
544
- super('AssignmentPattern', loc)
545
- this.left = left
546
- this.right = right
547
- }
548
- }
549
-
550
- class ImportDeclaration extends ASTNode {
551
- constructor(specifiers = [], source, loc = null) {
552
- super('ImportDeclaration', loc)
553
- this.specifiers = specifiers
554
- this.source = source
555
- }
556
- }
557
-
558
- class ImportSpecifier extends ASTNode {
559
- constructor(imported, local, loc = null) {
560
- super('ImportSpecifier', loc)
561
- this.imported = imported
562
- this.local = local
563
- }
564
- }
565
-
566
- class ImportDefaultSpecifier extends ASTNode {
567
- constructor(local, loc = null) {
568
- super('ImportDefaultSpecifier', loc)
569
- this.local = local
570
- }
571
- }
572
-
573
- class ImportNamespaceSpecifier extends ASTNode {
574
- constructor(local, loc = null) {
575
- super('ImportNamespaceSpecifier', loc)
576
- this.local = local
577
- }
578
- }
579
-
580
- class ExportNamedDeclaration extends ASTNode {
581
- constructor(declaration = null, specifiers = [], source = null, loc = null) {
582
- super('ExportNamedDeclaration', loc)
583
- this.declaration = declaration
584
- this.specifiers = specifiers
585
- this.source = source
586
- }
587
- }
588
-
589
- class ExportDefaultDeclaration extends ASTNode {
590
- constructor(declaration, loc = null) {
591
- super('ExportDefaultDeclaration', loc)
592
- this.declaration = declaration
593
- }
594
- }
595
-
596
- class ExportAllDeclaration extends ASTNode {
597
- constructor(source, exported = null, loc = null) {
598
- super('ExportAllDeclaration', loc)
599
- this.source = source
600
- this.exported = exported
601
- }
602
- }
603
-
604
- class ExportSpecifier extends ASTNode {
605
- constructor(local, exported, loc = null) {
606
- super('ExportSpecifier', loc)
607
- this.local = local
608
- this.exported = exported
609
- }
610
- }
611
-
612
- class ImportExpression extends ASTNode {
613
- constructor(source, loc = null) {
614
- super('ImportExpression', loc)
615
- this.source = source
616
- }
617
- }
618
-
619
- class MetaProperty extends ASTNode {
620
- constructor(meta, property, loc = null) {
621
- super('MetaProperty', loc)
622
- this.meta = meta
623
- this.property = property
624
- }
625
- }
626
-
627
- class Comment extends ASTNode {
628
- constructor(value, isBlock = false, loc = null) {
629
- super('Comment', loc)
630
- this.value = value
631
- this.isBlock = isBlock
632
- }
633
- }
634
-
635
- class Decorator extends ASTNode {
636
- constructor(expression, loc = null) {
637
- super('Decorator', loc)
638
- this.expression = expression
639
- }
640
- }
641
-
642
- class UsingDeclaration extends ASTNode {
643
- constructor(declarations = [], await_ = false, loc = null) {
644
- super('UsingDeclaration', loc)
645
- this.declarations = declarations
646
- this.await = await_
647
- }
648
- }
649
-
650
- class EtherNaturalExpression extends ASTNode {
651
- constructor(naturalText, jsEquivalent, loc = null) {
652
- super('EtherNaturalExpression', loc)
653
- this.naturalText = naturalText
654
- this.jsEquivalent = jsEquivalent
655
- }
656
- }
657
-
658
- class EtherPipeExpression extends ASTNode {
659
- constructor(value, functions = [], loc = null) {
660
- super('EtherPipeExpression', loc)
661
- this.value = value
662
- this.functions = functions
663
- }
664
- }
665
-
666
- module.exports = {
667
- ASTNode,
668
- Program,
669
- Identifier,
670
- Literal,
671
- StringLiteral,
672
- NumericLiteral,
673
- BooleanLiteral,
674
- NullLiteral,
675
- BigIntLiteral,
676
- RegExpLiteral,
677
- TemplateLiteral,
678
- TemplateElement,
679
- TaggedTemplateExpression,
680
- VariableDeclaration,
681
- VariableDeclarator,
682
- FunctionDeclaration,
683
- FunctionExpression,
684
- ArrowFunctionExpression,
685
- ClassDeclaration,
686
- ClassExpression,
687
- ClassBody,
688
- MethodDefinition,
689
- PropertyDefinition,
690
- PrivateIdentifier,
691
- StaticBlock,
692
- BlockStatement,
693
- ExpressionStatement,
694
- EmptyStatement,
695
- ReturnStatement,
696
- BreakStatement,
697
- ContinueStatement,
698
- LabeledStatement,
699
- IfStatement,
700
- SwitchStatement,
701
- SwitchCase,
702
- WhileStatement,
703
- DoWhileStatement,
704
- ForStatement,
705
- ForInStatement,
706
- ForOfStatement,
707
- TryStatement,
708
- CatchClause,
709
- ThrowStatement,
710
- WithStatement,
711
- DebuggerStatement,
712
- BinaryExpression,
713
- LogicalExpression,
714
- UnaryExpression,
715
- UpdateExpression,
716
- AssignmentExpression,
717
- ConditionalExpression,
718
- CallExpression,
719
- NewExpression,
720
- MemberExpression,
721
- ChainExpression,
722
- SequenceExpression,
723
- ThisExpression,
724
- Super,
725
- SpreadElement,
726
- RestElement,
727
- YieldExpression,
728
- AwaitExpression,
729
- ArrayExpression,
730
- ObjectExpression,
731
- Property,
732
- ArrayPattern,
733
- ObjectPattern,
734
- AssignmentPattern,
735
- ImportDeclaration,
736
- ImportSpecifier,
737
- ImportDefaultSpecifier,
738
- ImportNamespaceSpecifier,
739
- ExportNamedDeclaration,
740
- ExportDefaultDeclaration,
741
- ExportAllDeclaration,
742
- ExportSpecifier,
743
- ImportExpression,
744
- MetaProperty,
745
- Comment,
746
- Decorator,
747
- UsingDeclaration,
748
- EtherNaturalExpression,
749
- EtherPipeExpression
750
- }