ether-code 0.9.2 → 0.9.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.
package/cli/ether.js CHANGED
@@ -6,7 +6,7 @@ const http = require('http')
6
6
  const { EtherCompiler } = require('./compiler')
7
7
  const { Watcher } = require('./watcher')
8
8
 
9
- const VERSION = '0.9.2'
9
+ const VERSION = '0.9.4'
10
10
 
11
11
  const COLORS = {
12
12
  reset: '\x1b[0m',
@@ -308,6 +308,11 @@ class PHPGenerator {
308
308
  extractTypeName(typeNode) {
309
309
  if (!typeNode) return ''
310
310
  if (typeof typeNode === 'string') return this.translateKeyword(typeNode)
311
+ if (typeNode.type === 'TypeHint') {
312
+ const types = (typeNode.types || []).map(t => this.translateKeyword(t))
313
+ const result = types.join('|')
314
+ return typeNode.nullable ? '?' + result : result
315
+ }
311
316
  if (typeNode.name) return this.translateKeyword(typeNode.name)
312
317
  if (typeNode.type === 'Identifier') return this.translateKeyword(typeNode.name || typeNode.value || '')
313
318
  if (typeNode.value) return this.translateKeyword(typeNode.value)
@@ -474,9 +479,19 @@ class PHPGenerator {
474
479
  }
475
480
 
476
481
  generateUseStatement(node) {
477
- const name = node.name || node.source
478
- const alias = node.alias ? ` as ${node.alias}` : ''
479
- this.writeLine(`use ${name}${alias};`)
482
+ if (node.imports && node.imports.length > 0) {
483
+ for (const imp of node.imports) {
484
+ const name = imp.path || imp.name
485
+ const alias = imp.alias ? ` as ${imp.alias}` : ''
486
+ const useType = node.useType ? `${node.useType} ` : ''
487
+ this.writeLine(`use ${useType}${name}${alias};`)
488
+ }
489
+ } else {
490
+ const name = node.name || node.source
491
+ const alias = node.alias ? ` as ${node.alias}` : ''
492
+ const useType = node.useType ? `${node.useType} ` : ''
493
+ this.writeLine(`use ${useType}${name}${alias};`)
494
+ }
480
495
  return ''
481
496
  }
482
497
 
@@ -705,7 +720,8 @@ class PHPGenerator {
705
720
  let declaration = 'enum ' + (node.name || '')
706
721
 
707
722
  if (node.backingType) {
708
- declaration += ': ' + this.translateKeyword(node.backingType)
723
+ const type = this.extractTypeName(node.backingType)
724
+ if (type) declaration += ': ' + type
709
725
  }
710
726
 
711
727
  this.writeLine(declaration + ' {')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ether-code",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
4
4
  "description": "Ether - Le langage intentionnel",
5
5
  "main": "cli/compiler.js",
6
6
  "bin": {
@@ -635,6 +635,9 @@ class EtherParserPHP extends EtherParserBase {
635
635
  type: 'ClassDeclaration',
636
636
  name: name,
637
637
  modifiers: modifiers,
638
+ abstract: modifiers.includes('abstract'),
639
+ final: modifiers.includes('final'),
640
+ readonly: modifiers.includes('readonly'),
638
641
  superClass: superClass,
639
642
  interfaces: interfaces,
640
643
  body: body