ether-code 0.7.5 → 0.7.6
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/ether-parser.js +30 -2
- package/package.json +1 -1
package/cli/ether.js
CHANGED
package/ether-parser.js
CHANGED
|
@@ -2222,6 +2222,21 @@ class EtherParser {
|
|
|
2222
2222
|
parseFunctionDeclaration(lang) {
|
|
2223
2223
|
this.advance()
|
|
2224
2224
|
|
|
2225
|
+
let isAsync = false
|
|
2226
|
+
let isGenerator = false
|
|
2227
|
+
|
|
2228
|
+
const modifierToken = this.current()
|
|
2229
|
+
if (modifierToken && modifierToken.type === TokenType.IDENTIFIER) {
|
|
2230
|
+
const modVal = this.normalizeAccents(modifierToken.value.toLowerCase())
|
|
2231
|
+
if (modVal === 'asynchrone' || modVal === 'async') {
|
|
2232
|
+
isAsync = true
|
|
2233
|
+
this.advance()
|
|
2234
|
+
} else if (modVal === 'generatrice' || modVal === 'generator' || modVal === 'generateur') {
|
|
2235
|
+
isGenerator = true
|
|
2236
|
+
this.advance()
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2225
2240
|
const nameToken = this.current()
|
|
2226
2241
|
if (!nameToken || nameToken.type !== TokenType.IDENTIFIER) {
|
|
2227
2242
|
return null
|
|
@@ -2272,7 +2287,9 @@ class EtherParser {
|
|
|
2272
2287
|
name: name,
|
|
2273
2288
|
params: params,
|
|
2274
2289
|
returnType: returnType,
|
|
2275
|
-
body: body
|
|
2290
|
+
body: body,
|
|
2291
|
+
async: isAsync,
|
|
2292
|
+
generator: isGenerator
|
|
2276
2293
|
}
|
|
2277
2294
|
}
|
|
2278
2295
|
|
|
@@ -2846,6 +2863,9 @@ class EtherParser {
|
|
|
2846
2863
|
} else if (this.match(TokenType.GT) || this.matchValue('superieur') || this.matchValue('supérieur')) {
|
|
2847
2864
|
const right = this.parseAdditive(lang)
|
|
2848
2865
|
left = { type: 'BinaryExpression', operator: '>', left, right }
|
|
2866
|
+
} else if (this.matchValue('instance de') || this.matchValue('instanceof')) {
|
|
2867
|
+
const right = this.parseAdditive(lang)
|
|
2868
|
+
left = { type: 'BinaryExpression', operator: 'instanceof', left, right }
|
|
2849
2869
|
} else {
|
|
2850
2870
|
break
|
|
2851
2871
|
}
|
|
@@ -2885,6 +2905,9 @@ class EtherParser {
|
|
|
2885
2905
|
} else if (this.match(TokenType.PERCENT) || this.matchValue('modulo')) {
|
|
2886
2906
|
const right = this.parseUnary(lang)
|
|
2887
2907
|
left = { type: 'BinaryExpression', operator: '%', left, right }
|
|
2908
|
+
} else if (this.match(TokenType.DOUBLE_STAR) || this.matchValue('puissance')) {
|
|
2909
|
+
const right = this.parseUnary(lang)
|
|
2910
|
+
left = { type: 'BinaryExpression', operator: '**', left, right }
|
|
2888
2911
|
} else {
|
|
2889
2912
|
break
|
|
2890
2913
|
}
|
|
@@ -2904,7 +2927,12 @@ class EtherParser {
|
|
|
2904
2927
|
return { type: 'UnaryExpression', operator: '-', operand }
|
|
2905
2928
|
}
|
|
2906
2929
|
|
|
2907
|
-
if (this.matchValue('
|
|
2930
|
+
if (this.matchValue('type de') || this.matchValue('typeof')) {
|
|
2931
|
+
const operand = this.parseUnary(lang)
|
|
2932
|
+
return { type: 'UnaryExpression', operator: 'typeof', operand }
|
|
2933
|
+
}
|
|
2934
|
+
|
|
2935
|
+
if (this.matchValue('nouveau') || this.matchValue('new') || this.matchValue('nouvelle')) {
|
|
2908
2936
|
const callee = this.parseCall(lang)
|
|
2909
2937
|
if (callee.type === 'CallExpression') {
|
|
2910
2938
|
return { type: 'NewExpression', callee: callee.callee, arguments: callee.arguments }
|