ether-code 0.1.5 → 0.1.7
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 +1 -1
- package/generators/css-generator.js +42 -55
- package/generators/graphql-generator.js +19 -22
- package/generators/html-generator.js +51 -182
- package/generators/js-generator.js +76 -157
- package/generators/node-generator.js +49 -93
- package/generators/php-generator.js +46 -68
- package/generators/python-generator.js +35 -54
- package/generators/react-generator.js +37 -47
- package/generators/ruby-generator.js +59 -119
- package/generators/sql-generator.js +42 -63
- package/generators/ts-generator.js +59 -133
- package/i18n/i18n-css.json +147 -147
- package/i18n/i18n-graphql.json +6 -6
- package/i18n/i18n-html.json +135 -135
- package/i18n/i18n-js.json +107 -107
- package/i18n/i18n-node.json +14 -14
- package/i18n/i18n-php.json +177 -177
- package/i18n/i18n-python.json +16 -16
- package/i18n/i18n-react.json +97 -97
- package/i18n/i18n-ruby.json +22 -22
- package/i18n/i18n-sql.json +153 -153
- package/i18n/i18n-ts.json +10 -10
- package/lexer/ether-lexer.js +175 -34
- package/lexer/tokens.js +6 -6
- package/package.json +1 -1
- package/parsers/ast-css.js +0 -545
- package/parsers/ast-graphql.js +0 -424
- package/parsers/ast-html.js +0 -886
- package/parsers/ast-js.js +0 -750
- package/parsers/ast-node.js +0 -2440
- package/parsers/ast-php.js +0 -957
- package/parsers/ast-react.js +0 -580
- package/parsers/ast-ruby.js +0 -895
- package/parsers/ast-ts.js +0 -1352
- package/parsers/css-parser.js +0 -1981
- package/parsers/graphql-parser.js +0 -2011
- package/parsers/html-parser.js +0 -1182
- package/parsers/js-parser.js +0 -2564
- package/parsers/node-parser.js +0 -2644
- package/parsers/php-parser.js +0 -3037
- package/parsers/react-parser.js +0 -1035
- package/parsers/ruby-parser.js +0 -2680
- package/parsers/ts-parser.js +0 -3881
package/i18n/i18n-ts.json
CHANGED
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"ja": "パブリック"
|
|
57
57
|
},
|
|
58
58
|
"private": {
|
|
59
|
-
"fr": "
|
|
59
|
+
"fr": "prive",
|
|
60
60
|
"en": "private",
|
|
61
61
|
"es": "privado",
|
|
62
62
|
"ru": "приватный",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"ja": "プライベート"
|
|
65
65
|
},
|
|
66
66
|
"protected": {
|
|
67
|
-
"fr": "
|
|
67
|
+
"fr": "protege",
|
|
68
68
|
"en": "protected",
|
|
69
69
|
"es": "protegido",
|
|
70
70
|
"ru": "защищенный",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"ja": "抽象"
|
|
81
81
|
},
|
|
82
82
|
"implements": {
|
|
83
|
-
"fr": "
|
|
83
|
+
"fr": "implemente",
|
|
84
84
|
"en": "implements",
|
|
85
85
|
"es": "implementa",
|
|
86
86
|
"ru": "реализует",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"ja": "実装"
|
|
89
89
|
},
|
|
90
90
|
"extends": {
|
|
91
|
-
"fr": "
|
|
91
|
+
"fr": "etend",
|
|
92
92
|
"en": "extends",
|
|
93
93
|
"es": "extiende",
|
|
94
94
|
"ru": "расширяет",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"ja": "名前空間"
|
|
105
105
|
},
|
|
106
106
|
"declare": {
|
|
107
|
-
"fr": "
|
|
107
|
+
"fr": "declarer",
|
|
108
108
|
"en": "declare",
|
|
109
109
|
"es": "declarar",
|
|
110
110
|
"ru": "объявить",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"ja": "型"
|
|
137
137
|
},
|
|
138
138
|
"infer": {
|
|
139
|
-
"fr": "
|
|
139
|
+
"fr": "inferer",
|
|
140
140
|
"en": "infer",
|
|
141
141
|
"es": "inferir",
|
|
142
142
|
"ru": "выводить",
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"ja": "ボイド"
|
|
177
177
|
},
|
|
178
178
|
"string": {
|
|
179
|
-
"fr": "
|
|
179
|
+
"fr": "chaine",
|
|
180
180
|
"en": "string",
|
|
181
181
|
"es": "cadena",
|
|
182
182
|
"ru": "строка",
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
"ja": "数値"
|
|
193
193
|
},
|
|
194
194
|
"boolean": {
|
|
195
|
-
"fr": "
|
|
195
|
+
"fr": "booleen",
|
|
196
196
|
"en": "boolean",
|
|
197
197
|
"es": "booleano",
|
|
198
198
|
"ru": "логический",
|
|
@@ -336,7 +336,7 @@
|
|
|
336
336
|
"ja": "戻り型"
|
|
337
337
|
},
|
|
338
338
|
"Parameters": {
|
|
339
|
-
"fr": "
|
|
339
|
+
"fr": "Parametres",
|
|
340
340
|
"en": "Parameters",
|
|
341
341
|
"es": "Parametros",
|
|
342
342
|
"ru": "Параметры",
|
|
@@ -416,7 +416,7 @@
|
|
|
416
416
|
"ja": "ゲット"
|
|
417
417
|
},
|
|
418
418
|
"set": {
|
|
419
|
-
"fr": "
|
|
419
|
+
"fr": "definir",
|
|
420
420
|
"en": "set",
|
|
421
421
|
"es": "establecer",
|
|
422
422
|
"ru": "установить",
|
package/lexer/ether-lexer.js
CHANGED
|
@@ -1,11 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
1
|
+
class Token {
|
|
2
|
+
constructor(type, value, line, column, indent = 0) {
|
|
3
|
+
this.type = type
|
|
4
|
+
this.value = value
|
|
5
|
+
this.line = line
|
|
6
|
+
this.column = column
|
|
7
|
+
this.indent = indent
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
toString() {
|
|
11
|
+
return `Token(${this.type}, ${JSON.stringify(this.value)}, L${this.line}:${this.column})`
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const TokenType = {
|
|
16
|
+
IDENTIFIER: 'IDENTIFIER',
|
|
17
|
+
STRING: 'STRING',
|
|
18
|
+
BLOCK_STRING: 'BLOCK_STRING',
|
|
19
|
+
NUMBER: 'NUMBER',
|
|
20
|
+
INTEGER: 'INTEGER',
|
|
21
|
+
FLOAT: 'FLOAT',
|
|
22
|
+
HEX: 'HEX',
|
|
23
|
+
|
|
24
|
+
COLON: 'COLON',
|
|
25
|
+
DOUBLE_COLON: 'DOUBLE_COLON',
|
|
26
|
+
EQUALS: 'EQUALS',
|
|
27
|
+
DOUBLE_EQUALS: 'DOUBLE_EQUALS',
|
|
28
|
+
NOT_EQUALS: 'NOT_EQUALS',
|
|
29
|
+
COMMA: 'COMMA',
|
|
30
|
+
DOT: 'DOT',
|
|
31
|
+
SPREAD: 'SPREAD',
|
|
32
|
+
ARROW: 'ARROW',
|
|
33
|
+
FAT_ARROW: 'FAT_ARROW',
|
|
34
|
+
|
|
35
|
+
PLUS: 'PLUS',
|
|
36
|
+
MINUS: 'MINUS',
|
|
37
|
+
STAR: 'STAR',
|
|
38
|
+
DOUBLE_STAR: 'DOUBLE_STAR',
|
|
39
|
+
SLASH: 'SLASH',
|
|
40
|
+
DOUBLE_SLASH: 'DOUBLE_SLASH',
|
|
41
|
+
PERCENT: 'PERCENT',
|
|
42
|
+
|
|
43
|
+
BANG: 'BANG',
|
|
44
|
+
QUESTION: 'QUESTION',
|
|
45
|
+
AMPERSAND: 'AMPERSAND',
|
|
46
|
+
DOUBLE_AMPERSAND: 'DOUBLE_AMPERSAND',
|
|
47
|
+
PIPE: 'PIPE',
|
|
48
|
+
DOUBLE_PIPE: 'DOUBLE_PIPE',
|
|
49
|
+
CARET: 'CARET',
|
|
50
|
+
TILDE: 'TILDE',
|
|
51
|
+
|
|
52
|
+
LT: 'LT',
|
|
53
|
+
GT: 'GT',
|
|
54
|
+
LTE: 'LTE',
|
|
55
|
+
GTE: 'GTE',
|
|
56
|
+
SPACESHIP: 'SPACESHIP',
|
|
57
|
+
|
|
58
|
+
AT: 'AT',
|
|
59
|
+
HASH: 'HASH',
|
|
60
|
+
UNDERSCORE: 'UNDERSCORE',
|
|
61
|
+
BACKSLASH: 'BACKSLASH',
|
|
62
|
+
|
|
63
|
+
LPAREN: 'LPAREN',
|
|
64
|
+
RPAREN: 'RPAREN',
|
|
65
|
+
LBRACKET: 'LBRACKET',
|
|
66
|
+
RBRACKET: 'RBRACKET',
|
|
67
|
+
LBRACE: 'LBRACE',
|
|
68
|
+
RBRACE: 'RBRACE',
|
|
69
|
+
|
|
70
|
+
NEWLINE: 'NEWLINE',
|
|
71
|
+
INDENT: 'INDENT',
|
|
72
|
+
DEDENT: 'DEDENT',
|
|
73
|
+
|
|
74
|
+
LANG_BLOCK: 'LANG_BLOCK',
|
|
75
|
+
|
|
76
|
+
COMMENT: 'COMMENT',
|
|
77
|
+
BLOCK_COMMENT: 'BLOCK_COMMENT',
|
|
78
|
+
|
|
79
|
+
EOF: 'EOF',
|
|
80
|
+
ERROR: 'ERROR'
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const LANG_BLOCKS = [
|
|
84
|
+
'html', 'css', 'style', 'script', 'js', 'javascript',
|
|
85
|
+
'php', 'python', 'py', 'ruby', 'rb',
|
|
86
|
+
'sql', 'graphql', 'gql',
|
|
87
|
+
'node', 'nodejs', 'ts', 'typescript',
|
|
88
|
+
'react', 'jsx', 'tsx',
|
|
89
|
+
'json', 'xml', 'yaml', 'markdown', 'md'
|
|
90
|
+
]
|
|
9
91
|
|
|
10
92
|
class EtherLexer {
|
|
11
93
|
constructor(source, options = {}) {
|
|
@@ -51,6 +133,16 @@ class EtherLexer {
|
|
|
51
133
|
return false
|
|
52
134
|
}
|
|
53
135
|
|
|
136
|
+
matchSequence(seq) {
|
|
137
|
+
for (let i = 0; i < seq.length; i++) {
|
|
138
|
+
if (this.peek(i) !== seq[i]) return false
|
|
139
|
+
}
|
|
140
|
+
for (let i = 0; i < seq.length; i++) {
|
|
141
|
+
this.advance()
|
|
142
|
+
}
|
|
143
|
+
return true
|
|
144
|
+
}
|
|
145
|
+
|
|
54
146
|
isAtEnd() {
|
|
55
147
|
return this.pos >= this.source.length
|
|
56
148
|
}
|
|
@@ -201,7 +293,7 @@ class EtherLexer {
|
|
|
201
293
|
this.tokens.push(new Token(TokenType.DEDENT, '', this.line, 1, indent))
|
|
202
294
|
}
|
|
203
295
|
if (this.indentStack[this.indentStack.length - 1] !== indent) {
|
|
204
|
-
this.tokens.push(new Token(TokenType.ERROR, 'Indentation
|
|
296
|
+
this.tokens.push(new Token(TokenType.ERROR, 'Indentation incohérente', this.line, 1, indent))
|
|
205
297
|
}
|
|
206
298
|
}
|
|
207
299
|
}
|
|
@@ -277,7 +369,7 @@ class EtherLexer {
|
|
|
277
369
|
break
|
|
278
370
|
}
|
|
279
371
|
if (this.peek() === '\n') {
|
|
280
|
-
this.tokens.push(new Token(TokenType.ERROR, '
|
|
372
|
+
this.tokens.push(new Token(TokenType.ERROR, 'Chaîne non terminée', startLine, startCol, this.currentIndent))
|
|
281
373
|
return
|
|
282
374
|
}
|
|
283
375
|
}
|
|
@@ -459,7 +551,7 @@ class EtherLexer {
|
|
|
459
551
|
|
|
460
552
|
if (nextWord) {
|
|
461
553
|
const combined = value + ' ' + nextWord
|
|
462
|
-
if (isCompoundKeyword(combined) || couldBeCompoundStart(combined)) {
|
|
554
|
+
if (this.isCompoundKeyword(combined) || this.couldBeCompoundStart(combined)) {
|
|
463
555
|
value = combined
|
|
464
556
|
} else {
|
|
465
557
|
this.pos = savedPos
|
|
@@ -485,6 +577,53 @@ class EtherLexer {
|
|
|
485
577
|
this.tokens.push(new Token(TokenType.IDENTIFIER, value, startLine, startCol, this.currentIndent))
|
|
486
578
|
}
|
|
487
579
|
|
|
580
|
+
couldBeCompoundStart(partial) {
|
|
581
|
+
const normalized = this.normalizeAccents(partial)
|
|
582
|
+
const compounds = [
|
|
583
|
+
'retour a la ligne', 'a la soumission', 'a la reinitialisation',
|
|
584
|
+
'inferieur ou egal', 'superieur ou egal',
|
|
585
|
+
'gauche a droite', 'droite a gauche',
|
|
586
|
+
'mettre a jour', 'case a cocher'
|
|
587
|
+
]
|
|
588
|
+
return compounds.some(c => c.startsWith(normalized + ' '))
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
normalizeAccents(str) {
|
|
592
|
+
const accentsMap = {
|
|
593
|
+
'à ': 'a', 'â': 'a', 'ä': 'a', 'á': 'a',
|
|
594
|
+
'è': 'e', 'ê': 'e', 'ë': 'e', 'é': 'e',
|
|
595
|
+
'ì': 'i', 'î': 'i', 'ï': 'i', 'Ã': 'i',
|
|
596
|
+
'ò': 'o', 'ô': 'o', 'ö': 'o', 'ó': 'o',
|
|
597
|
+
'ù': 'u', 'û': 'u', 'ü': 'u', 'ú': 'u',
|
|
598
|
+
'ç': 'c', 'ñ': 'n'
|
|
599
|
+
}
|
|
600
|
+
return str.toLowerCase().split('').map(c => accentsMap[c] || c).join('')
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
isCompoundKeyword(phrase) {
|
|
604
|
+
const normalized = this.normalizeAccents(phrase)
|
|
605
|
+
const compounds = [
|
|
606
|
+
'en ligne', 'hors ligne', 'au survol', 'au clic', 'au focus',
|
|
607
|
+
'au double clic', 'au changement', 'a la soumission',
|
|
608
|
+
'retour a la ligne', 'lecture seule', 'zone texte',
|
|
609
|
+
'case a cocher', 'bouton radio', 'premiere lettre',
|
|
610
|
+
'premiere ligne', 'inferieur ou egal',
|
|
611
|
+
'superieur ou egal',
|
|
612
|
+
'espace de noms', 'element liste', 'racine carree',
|
|
613
|
+
'nouvelle fenetre', 'gauche a droite',
|
|
614
|
+
'droite a gauche',
|
|
615
|
+
'definir defaut', 'mettre a jour',
|
|
616
|
+
'cle primaire', 'cle etrangere',
|
|
617
|
+
'non nul', 'par defaut',
|
|
618
|
+
'au focus dans', 'pointeur bas', 'pointeur haut',
|
|
619
|
+
'obtenir contenu', 'erreur type', 'erreur syntaxe',
|
|
620
|
+
'nettoyer gauche', 'nettoyer droite', 'vers date',
|
|
621
|
+
'si null', 'creer role',
|
|
622
|
+
'a la reinitialisation'
|
|
623
|
+
]
|
|
624
|
+
return compounds.includes(normalized)
|
|
625
|
+
}
|
|
626
|
+
|
|
488
627
|
scanOperator() {
|
|
489
628
|
const startLine = this.line
|
|
490
629
|
const startCol = this.column
|
|
@@ -502,7 +641,7 @@ class EtherLexer {
|
|
|
502
641
|
case '=':
|
|
503
642
|
if (this.match('=')) {
|
|
504
643
|
if (this.match('=')) {
|
|
505
|
-
this.tokens.push(new Token(TokenType.
|
|
644
|
+
this.tokens.push(new Token(TokenType.DOUBLE_EQUALS, '===', startLine, startCol, this.currentIndent))
|
|
506
645
|
} else {
|
|
507
646
|
this.tokens.push(new Token(TokenType.DOUBLE_EQUALS, '==', startLine, startCol, this.currentIndent))
|
|
508
647
|
}
|
|
@@ -516,7 +655,7 @@ class EtherLexer {
|
|
|
516
655
|
case '!':
|
|
517
656
|
if (this.match('=')) {
|
|
518
657
|
if (this.match('=')) {
|
|
519
|
-
this.tokens.push(new Token(TokenType.
|
|
658
|
+
this.tokens.push(new Token(TokenType.NOT_EQUALS, '!==', startLine, startCol, this.currentIndent))
|
|
520
659
|
} else {
|
|
521
660
|
this.tokens.push(new Token(TokenType.NOT_EQUALS, '!=', startLine, startCol, this.currentIndent))
|
|
522
661
|
}
|
|
@@ -544,9 +683,9 @@ class EtherLexer {
|
|
|
544
683
|
|
|
545
684
|
case '+':
|
|
546
685
|
if (this.match('+')) {
|
|
547
|
-
this.tokens.push(new Token(TokenType.
|
|
686
|
+
this.tokens.push(new Token(TokenType.PLUS, '++', startLine, startCol, this.currentIndent))
|
|
548
687
|
} else if (this.match('=')) {
|
|
549
|
-
this.tokens.push(new Token(TokenType.
|
|
688
|
+
this.tokens.push(new Token(TokenType.PLUS, '+=', startLine, startCol, this.currentIndent))
|
|
550
689
|
} else {
|
|
551
690
|
this.tokens.push(new Token(TokenType.PLUS, '+', startLine, startCol, this.currentIndent))
|
|
552
691
|
}
|
|
@@ -554,11 +693,11 @@ class EtherLexer {
|
|
|
554
693
|
|
|
555
694
|
case '-':
|
|
556
695
|
if (this.match('-')) {
|
|
557
|
-
this.tokens.push(new Token(TokenType.
|
|
696
|
+
this.tokens.push(new Token(TokenType.MINUS, '--', startLine, startCol, this.currentIndent))
|
|
558
697
|
} else if (this.match('>')) {
|
|
559
698
|
this.tokens.push(new Token(TokenType.ARROW, '->', startLine, startCol, this.currentIndent))
|
|
560
699
|
} else if (this.match('=')) {
|
|
561
|
-
this.tokens.push(new Token(TokenType.
|
|
700
|
+
this.tokens.push(new Token(TokenType.MINUS, '-=', startLine, startCol, this.currentIndent))
|
|
562
701
|
} else {
|
|
563
702
|
this.tokens.push(new Token(TokenType.MINUS, '-', startLine, startCol, this.currentIndent))
|
|
564
703
|
}
|
|
@@ -567,12 +706,12 @@ class EtherLexer {
|
|
|
567
706
|
case '*':
|
|
568
707
|
if (this.match('*')) {
|
|
569
708
|
if (this.match('=')) {
|
|
570
|
-
this.tokens.push(new Token(TokenType.
|
|
709
|
+
this.tokens.push(new Token(TokenType.DOUBLE_STAR, '**=', startLine, startCol, this.currentIndent))
|
|
571
710
|
} else {
|
|
572
711
|
this.tokens.push(new Token(TokenType.DOUBLE_STAR, '**', startLine, startCol, this.currentIndent))
|
|
573
712
|
}
|
|
574
713
|
} else if (this.match('=')) {
|
|
575
|
-
this.tokens.push(new Token(TokenType.
|
|
714
|
+
this.tokens.push(new Token(TokenType.STAR, '*=', startLine, startCol, this.currentIndent))
|
|
576
715
|
} else {
|
|
577
716
|
this.tokens.push(new Token(TokenType.STAR, '*', startLine, startCol, this.currentIndent))
|
|
578
717
|
}
|
|
@@ -580,7 +719,7 @@ class EtherLexer {
|
|
|
580
719
|
|
|
581
720
|
case '/':
|
|
582
721
|
if (this.match('=')) {
|
|
583
|
-
this.tokens.push(new Token(TokenType.
|
|
722
|
+
this.tokens.push(new Token(TokenType.SLASH, '/=', startLine, startCol, this.currentIndent))
|
|
584
723
|
} else if (this.match('/')) {
|
|
585
724
|
this.tokens.push(new Token(TokenType.DOUBLE_SLASH, '//', startLine, startCol, this.currentIndent))
|
|
586
725
|
} else {
|
|
@@ -590,7 +729,7 @@ class EtherLexer {
|
|
|
590
729
|
|
|
591
730
|
case '%':
|
|
592
731
|
if (this.match('=')) {
|
|
593
|
-
this.tokens.push(new Token(TokenType.
|
|
732
|
+
this.tokens.push(new Token(TokenType.PERCENT, '%=', startLine, startCol, this.currentIndent))
|
|
594
733
|
} else {
|
|
595
734
|
this.tokens.push(new Token(TokenType.PERCENT, '%', startLine, startCol, this.currentIndent))
|
|
596
735
|
}
|
|
@@ -604,7 +743,7 @@ class EtherLexer {
|
|
|
604
743
|
this.tokens.push(new Token(TokenType.LTE, '<=', startLine, startCol, this.currentIndent))
|
|
605
744
|
}
|
|
606
745
|
} else if (this.match('<')) {
|
|
607
|
-
this.tokens.push(new Token(TokenType.
|
|
746
|
+
this.tokens.push(new Token(TokenType.LT, '<<', startLine, startCol, this.currentIndent))
|
|
608
747
|
} else {
|
|
609
748
|
this.tokens.push(new Token(TokenType.LT, '<', startLine, startCol, this.currentIndent))
|
|
610
749
|
}
|
|
@@ -615,9 +754,9 @@ class EtherLexer {
|
|
|
615
754
|
this.tokens.push(new Token(TokenType.GTE, '>=', startLine, startCol, this.currentIndent))
|
|
616
755
|
} else if (this.match('>')) {
|
|
617
756
|
if (this.match('>')) {
|
|
618
|
-
this.tokens.push(new Token(TokenType.
|
|
757
|
+
this.tokens.push(new Token(TokenType.GT, '>>>', startLine, startCol, this.currentIndent))
|
|
619
758
|
} else {
|
|
620
|
-
this.tokens.push(new Token(TokenType.
|
|
759
|
+
this.tokens.push(new Token(TokenType.GT, '>>', startLine, startCol, this.currentIndent))
|
|
621
760
|
}
|
|
622
761
|
} else {
|
|
623
762
|
this.tokens.push(new Token(TokenType.GT, '>', startLine, startCol, this.currentIndent))
|
|
@@ -628,7 +767,7 @@ class EtherLexer {
|
|
|
628
767
|
if (this.match('&')) {
|
|
629
768
|
this.tokens.push(new Token(TokenType.DOUBLE_AMPERSAND, '&&', startLine, startCol, this.currentIndent))
|
|
630
769
|
} else if (this.match('=')) {
|
|
631
|
-
this.tokens.push(new Token(TokenType.
|
|
770
|
+
this.tokens.push(new Token(TokenType.AMPERSAND, '&=', startLine, startCol, this.currentIndent))
|
|
632
771
|
} else {
|
|
633
772
|
this.tokens.push(new Token(TokenType.AMPERSAND, '&', startLine, startCol, this.currentIndent))
|
|
634
773
|
}
|
|
@@ -638,9 +777,9 @@ class EtherLexer {
|
|
|
638
777
|
if (this.match('|')) {
|
|
639
778
|
this.tokens.push(new Token(TokenType.DOUBLE_PIPE, '||', startLine, startCol, this.currentIndent))
|
|
640
779
|
} else if (this.match('=')) {
|
|
641
|
-
this.tokens.push(new Token(TokenType.
|
|
780
|
+
this.tokens.push(new Token(TokenType.PIPE, '|=', startLine, startCol, this.currentIndent))
|
|
642
781
|
} else if (this.match('>')) {
|
|
643
|
-
this.tokens.push(new Token(TokenType.
|
|
782
|
+
this.tokens.push(new Token(TokenType.PIPE, '|>', startLine, startCol, this.currentIndent))
|
|
644
783
|
} else {
|
|
645
784
|
this.tokens.push(new Token(TokenType.PIPE, '|', startLine, startCol, this.currentIndent))
|
|
646
785
|
}
|
|
@@ -648,7 +787,7 @@ class EtherLexer {
|
|
|
648
787
|
|
|
649
788
|
case '^':
|
|
650
789
|
if (this.match('=')) {
|
|
651
|
-
this.tokens.push(new Token(TokenType.
|
|
790
|
+
this.tokens.push(new Token(TokenType.CARET, '^=', startLine, startCol, this.currentIndent))
|
|
652
791
|
} else {
|
|
653
792
|
this.tokens.push(new Token(TokenType.CARET, '^', startLine, startCol, this.currentIndent))
|
|
654
793
|
}
|
|
@@ -661,12 +800,12 @@ class EtherLexer {
|
|
|
661
800
|
case '?':
|
|
662
801
|
if (this.match('?')) {
|
|
663
802
|
if (this.match('=')) {
|
|
664
|
-
this.tokens.push(new Token(TokenType.
|
|
803
|
+
this.tokens.push(new Token(TokenType.QUESTION, '??=', startLine, startCol, this.currentIndent))
|
|
665
804
|
} else {
|
|
666
|
-
this.tokens.push(new Token(TokenType.
|
|
805
|
+
this.tokens.push(new Token(TokenType.QUESTION, '??', startLine, startCol, this.currentIndent))
|
|
667
806
|
}
|
|
668
807
|
} else if (this.match('.')) {
|
|
669
|
-
this.tokens.push(new Token(TokenType.
|
|
808
|
+
this.tokens.push(new Token(TokenType.QUESTION, '?.', startLine, startCol, this.currentIndent))
|
|
670
809
|
} else {
|
|
671
810
|
this.tokens.push(new Token(TokenType.QUESTION, '?', startLine, startCol, this.currentIndent))
|
|
672
811
|
}
|
|
@@ -709,11 +848,10 @@ class EtherLexer {
|
|
|
709
848
|
break
|
|
710
849
|
|
|
711
850
|
case ';':
|
|
712
|
-
this.tokens.push(new Token(TokenType.SEMICOLON, ';', startLine, startCol, this.currentIndent))
|
|
713
851
|
break
|
|
714
852
|
|
|
715
853
|
default:
|
|
716
|
-
this.tokens.push(new Token(TokenType.ERROR, `
|
|
854
|
+
this.tokens.push(new Token(TokenType.ERROR, `Caractère inattendu: ${char}`, startLine, startCol, this.currentIndent))
|
|
717
855
|
}
|
|
718
856
|
}
|
|
719
857
|
|
|
@@ -724,5 +862,8 @@ class EtherLexer {
|
|
|
724
862
|
}
|
|
725
863
|
|
|
726
864
|
module.exports = {
|
|
727
|
-
EtherLexer
|
|
865
|
+
EtherLexer,
|
|
866
|
+
Token,
|
|
867
|
+
TokenType,
|
|
868
|
+
LANG_BLOCKS
|
|
728
869
|
}
|
package/lexer/tokens.js
CHANGED
|
@@ -260,12 +260,12 @@ class Token {
|
|
|
260
260
|
|
|
261
261
|
function normalizeAccents(str) {
|
|
262
262
|
const accentsMap = {
|
|
263
|
-
'
|
|
264
|
-
'
|
|
265
|
-
'
|
|
266
|
-
'
|
|
267
|
-
'
|
|
268
|
-
'
|
|
263
|
+
'à ': 'a', 'â': 'a', 'ä': 'a', 'á': 'a',
|
|
264
|
+
'è': 'e', 'ê': 'e', 'ë': 'e', 'é': 'e',
|
|
265
|
+
'ì': 'i', 'î': 'i', 'ï': 'i', 'Ã': 'i',
|
|
266
|
+
'ò': 'o', 'ô': 'o', 'ö': 'o', 'ó': 'o',
|
|
267
|
+
'ù': 'u', 'û': 'u', 'ü': 'u', 'ú': 'u',
|
|
268
|
+
'ç': 'c', 'ñ': 'n'
|
|
269
269
|
}
|
|
270
270
|
return str.toLowerCase().split('').map(c => accentsMap[c] || c).join('')
|
|
271
271
|
}
|