ether-code 0.7.4 → 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 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.7.4'
9
+ const VERSION = '0.7.6'
10
10
 
11
11
  const COLORS = {
12
12
  reset: '\x1b[0m',
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
@@ -2232,11 +2247,14 @@ class EtherParser {
2232
2247
  const params = []
2233
2248
  if (this.match(TokenType.LPAREN)) {
2234
2249
  while (!this.isAtEnd() && !this.match(TokenType.RPAREN)) {
2250
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2251
+ if (this.check(TokenType.RPAREN)) break
2235
2252
  const param = this.parseParameter(lang)
2236
2253
  if (param) {
2237
2254
  params.push(param)
2238
2255
  }
2239
2256
  this.match(TokenType.COMMA)
2257
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2240
2258
  }
2241
2259
  } else {
2242
2260
  while (!this.isAtEnd()) {
@@ -2269,7 +2287,9 @@ class EtherParser {
2269
2287
  name: name,
2270
2288
  params: params,
2271
2289
  returnType: returnType,
2272
- body: body
2290
+ body: body,
2291
+ async: isAsync,
2292
+ generator: isGenerator
2273
2293
  }
2274
2294
  }
2275
2295
 
@@ -2289,11 +2309,14 @@ class EtherParser {
2289
2309
  const params = []
2290
2310
  if (this.match(TokenType.LPAREN)) {
2291
2311
  while (!this.isAtEnd() && !this.match(TokenType.RPAREN)) {
2312
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2313
+ if (this.check(TokenType.RPAREN)) break
2292
2314
  const param = this.parseParameter(lang)
2293
2315
  if (param) {
2294
2316
  params.push(param)
2295
2317
  }
2296
2318
  this.match(TokenType.COMMA)
2319
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2297
2320
  }
2298
2321
  }
2299
2322
 
@@ -2718,6 +2741,14 @@ class EtherParser {
2718
2741
  break
2719
2742
  }
2720
2743
 
2744
+ if (current && current.type === TokenType.COMMA) {
2745
+ break
2746
+ }
2747
+
2748
+ if (current && current.type === TokenType.RPAREN) {
2749
+ break
2750
+ }
2751
+
2721
2752
  if (current && (current.type === TokenType.INDENT || current.type === TokenType.NEWLINE)) {
2722
2753
  this.advance()
2723
2754
  continue
@@ -2832,6 +2863,9 @@ class EtherParser {
2832
2863
  } else if (this.match(TokenType.GT) || this.matchValue('superieur') || this.matchValue('supérieur')) {
2833
2864
  const right = this.parseAdditive(lang)
2834
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 }
2835
2869
  } else {
2836
2870
  break
2837
2871
  }
@@ -2871,6 +2905,9 @@ class EtherParser {
2871
2905
  } else if (this.match(TokenType.PERCENT) || this.matchValue('modulo')) {
2872
2906
  const right = this.parseUnary(lang)
2873
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 }
2874
2911
  } else {
2875
2912
  break
2876
2913
  }
@@ -2890,7 +2927,12 @@ class EtherParser {
2890
2927
  return { type: 'UnaryExpression', operator: '-', operand }
2891
2928
  }
2892
2929
 
2893
- if (this.matchValue('nouveau') || this.matchValue('new')) {
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')) {
2894
2936
  const callee = this.parseCall(lang)
2895
2937
  if (callee.type === 'CallExpression') {
2896
2938
  return { type: 'NewExpression', callee: callee.callee, arguments: callee.arguments }
@@ -2908,8 +2950,11 @@ class EtherParser {
2908
2950
  if (this.match(TokenType.LPAREN)) {
2909
2951
  const args = []
2910
2952
  while (!this.isAtEnd() && !this.match(TokenType.RPAREN)) {
2953
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2954
+ if (this.check(TokenType.RPAREN)) break
2911
2955
  args.push(this.parseExpression(lang))
2912
2956
  this.match(TokenType.COMMA)
2957
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2913
2958
  }
2914
2959
  expr = { type: 'CallExpression', callee: expr, arguments: args }
2915
2960
  } else if (this.match(TokenType.DOT)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ether-code",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "Ether - Le langage intentionnel",
5
5
  "main": "cli/compiler.js",
6
6
  "bin": {