ether-code 0.1.9 → 0.2.0

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Steve
3
+ Copyright (c) 2025 Steve
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,130 +1,68 @@
1
1
  # Ether
2
2
 
3
- **Le langage intentionnel** - Programmez dans votre langue naturelle.
4
-
5
- Ether est un compilateur qui transforme du code écrit en langage naturel (français, anglais, espagnol, russe, chinois, japonais) en code exécutable dans les langages cibles : JavaScript, TypeScript, HTML, CSS, PHP, Python, Ruby, SQL, Node.js, React, GraphQL.
3
+ **Le langage intentionnel** - Écrivez du code comme vous pensez.
6
4
 
7
5
  ## Installation
8
6
 
9
7
  ```bash
10
- npm install -g ether-lang
8
+ npm install -g ether-code
11
9
  ```
12
10
 
13
11
  ## Utilisation
14
12
 
15
- ### Compiler un projet
13
+ ### Initialiser un projet
16
14
 
17
15
  ```bash
18
- ether build
16
+ ether init
19
17
  ```
20
18
 
21
- ### Mode développement (watch)
19
+ ### Compiler
22
20
 
23
21
  ```bash
24
- ether dev
22
+ ether build
25
23
  ```
26
24
 
27
- ### Compiler un fichier spécifique
25
+ ### Mode développement (watch)
28
26
 
29
27
  ```bash
30
- ether build fichier.eth
31
- ```
32
-
33
- ## Configuration
34
-
35
- Créez un fichier `ether.config.json` à la racine de votre projet :
36
-
37
- ```json
38
- {
39
- "lang": "fr",
40
- "src": "./src",
41
- "out": "./dist",
42
- "targets": ["js", "css", "html"]
43
- }
28
+ ether dev
44
29
  ```
45
30
 
46
- ### Options
47
-
48
- | Option | Description | Défaut |
49
- |--------|-------------|--------|
50
- | `lang` | Langue source (fr, en, es, ru, zh, ja) | `fr` |
51
- | `src` | Dossier source | `./src` |
52
- | `out` | Dossier de sortie | `./dist` |
53
- | `targets` | Langages cibles | tous |
54
-
55
31
  ## Exemple
56
32
 
57
- ### Code Ether (français)
33
+ Créez un fichier `src/index.eth`:
58
34
 
59
- ```ether
60
- // style.eth
61
- sélecteur ".bouton"
62
- couleur fond: bleu
63
- couleur texte: blanc
64
- marge: 1rem
65
- bordure arrondie: 0.5rem
66
35
  ```
67
-
68
- ### Résultat CSS
69
-
70
- ```css
71
- .bouton {
72
- background-color: blue;
73
- color: white;
74
- margin: 1rem;
75
- border-radius: 0.5rem;
76
- }
36
+ // cible: html
37
+
38
+ document
39
+ tete
40
+ titre "Ma page"
41
+ corps
42
+ titre1 "Bienvenue"
43
+ paragraphe "Ether permet d'écrire du code naturellement."
77
44
  ```
78
45
 
79
- ### Code Ether (JavaScript)
80
-
81
- ```ether
82
- // app.eth
83
- fonction saluer avec nom
84
- retourner "Bonjour, " + nom + "!"
85
-
86
- afficher saluer("Monde")
87
- ```
88
-
89
- ### Résultat JavaScript
90
-
91
- ```javascript
92
- function saluer(nom) {
93
- return "Bonjour, " + nom + "!";
94
- }
95
-
96
- console.log(saluer("Monde"));
97
- ```
46
+ Compilez avec `ether build` pour générer `dist/index.html`.
98
47
 
99
48
  ## Langages supportés
100
49
 
101
- ### Langues source
102
- - 🇫🇷 Français
103
- - 🇬🇧 English
104
- - 🇪🇸 Español
105
- - 🇷🇺 Русский
106
- - 🇨🇳 中文
107
- - 🇯🇵 日本語
108
-
109
- ### Langages cibles
110
- - JavaScript / TypeScript
111
- - HTML / CSS
50
+ - HTML
51
+ - CSS
52
+ - JavaScript
53
+ - TypeScript
112
54
  - PHP
113
55
  - Python
114
56
  - Ruby
115
57
  - SQL
116
58
  - Node.js
117
- - React / JSX
59
+ - React
118
60
  - GraphQL
119
61
 
120
- ## Philosophie
121
-
122
- Ether est un **langage intentionnel** : au lieu de forcer les humains à parler comme des machines, Ether permet aux machines de comprendre l'intention humaine.
62
+ ## Documentation
123
63
 
124
- - **Naturel** : Écrivez du code comme vous pensez
125
- - **Multilingue** : Programmez dans votre langue maternelle
126
- - **Universel** : Un seul langage, tous les frameworks
64
+ https://ether-code.com/docs
127
65
 
128
- ## Licence
66
+ ## License
129
67
 
130
- MIT © Steve
68
+ MIT
package/cli/compiler.js CHANGED
@@ -66,7 +66,6 @@ class EtherCompiler {
66
66
  ...config
67
67
  }
68
68
 
69
- this.lexer = new EtherLexer()
70
69
  this.generators = {}
71
70
  this.parser = null
72
71
 
@@ -111,12 +110,9 @@ class EtherCompiler {
111
110
  async compileFile(filePath) {
112
111
  const content = fs.readFileSync(filePath, 'utf-8')
113
112
  const fileName = path.basename(filePath, '.eth')
114
- const dirName = path.dirname(filePath)
115
113
 
116
114
  const target = this.detectTarget(content, filePath)
117
-
118
115
  const ast = this.parse(content, target)
119
-
120
116
  const code = this.generate(ast, target)
121
117
 
122
118
  const extension = this.getExtension(target)
@@ -179,38 +175,34 @@ class EtherCompiler {
179
175
  inferTargetFromContent(content) {
180
176
  const patterns = {
181
177
  html: [
178
+ /^document\b/im,
182
179
  /^html\b/im,
183
- /\b(html|page|document|entête|entete|corps|section|div|paragraphe|titre|lien|image|formulaire|bouton)\b/i,
184
- /\b(balise|élément|element|attribut)\b/i
180
+ /\b(page|entête|entete|corps|section|paragraphe|titre|lien|image|formulaire|bouton)\b/i
185
181
  ],
186
182
  css: [
187
- /\b(style|couleur|taille|marge|bordure|fond|police|largeur|hauteur)\s*[:=]/i,
188
- /\.([\w-]+)\s*\{/,
189
- /#([\w-]+)\s*\{/
183
+ /\b(fond|couleur|marge|bordure|police|largeur|hauteur)\s*:/i,
184
+ /^\s*\./m,
185
+ /^\s*#[\w-]+\s*$/m
190
186
  ],
191
187
  js: [
192
188
  /\b(fonction|variable|constante|si|sinon|pour|tant que|retourner)\b/i,
193
- /\b(classe|méthode|constructeur)\b/i,
194
- /=>\s*\{/
189
+ /\b(classe|méthode|constructeur)\b/i
195
190
  ],
196
191
  php: [
197
- /\b(<?php|echo|namespace|use)\b/i,
192
+ /\b(<\?php|echo|namespace|utiliser)\b/i,
198
193
  /\$\w+/
199
194
  ],
200
195
  sql: [
201
- /\b(sélectionner|insérer|mettre à jour|supprimer|créer table|depuis|où)\b/i,
202
- /\b(SELECT|INSERT|UPDATE|DELETE|CREATE|FROM|WHERE)\b/i
196
+ /\b(sélectionner|selectionner|insérer|mettre à jour|supprimer|créer|depuis|où)\b/i
203
197
  ],
204
198
  python: [
205
- /\b(def|class|import|from|if|elif|else|for|while|return)\b/,
206
- /:\s*$/m
199
+ /\b(définir|def|classe|importer)\b/i
207
200
  ],
208
201
  react: [
209
- /\b(composant|état|effet|props|rendu)\b/i,
210
- /<[\w]+[^>]*\/>/
202
+ /\b(composant|état|effet|props|rendu)\b/i
211
203
  ],
212
204
  graphql: [
213
- /\b(type|query|mutation|subscription|schema|input)\b/i
205
+ /\b(type|requête|mutation|subscription|schema|entrée)\b/i
214
206
  ]
215
207
  }
216
208
 
@@ -239,12 +231,6 @@ class EtherCompiler {
239
231
  const content = fs.readFileSync(filePath, 'utf-8')
240
232
  const target = this.detectTarget(content, filePath)
241
233
 
242
- try {
243
- this.lexer.tokenize(content)
244
- } catch (err) {
245
- throw new Error(`Erreur de lexer: ${err.message}`)
246
- }
247
-
248
234
  try {
249
235
  this.parse(content, target)
250
236
  } catch (err) {