ether-code 0.7.3 → 0.7.5

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.3'
9
+ const VERSION = '0.7.5'
10
10
 
11
11
  const COLORS = {
12
12
  reset: '\x1b[0m',
package/ether-parser.js CHANGED
@@ -2232,11 +2232,14 @@ class EtherParser {
2232
2232
  const params = []
2233
2233
  if (this.match(TokenType.LPAREN)) {
2234
2234
  while (!this.isAtEnd() && !this.match(TokenType.RPAREN)) {
2235
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2236
+ if (this.check(TokenType.RPAREN)) break
2235
2237
  const param = this.parseParameter(lang)
2236
2238
  if (param) {
2237
2239
  params.push(param)
2238
2240
  }
2239
2241
  this.match(TokenType.COMMA)
2242
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2240
2243
  }
2241
2244
  } else {
2242
2245
  while (!this.isAtEnd()) {
@@ -2289,11 +2292,14 @@ class EtherParser {
2289
2292
  const params = []
2290
2293
  if (this.match(TokenType.LPAREN)) {
2291
2294
  while (!this.isAtEnd() && !this.match(TokenType.RPAREN)) {
2295
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2296
+ if (this.check(TokenType.RPAREN)) break
2292
2297
  const param = this.parseParameter(lang)
2293
2298
  if (param) {
2294
2299
  params.push(param)
2295
2300
  }
2296
2301
  this.match(TokenType.COMMA)
2302
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2297
2303
  }
2298
2304
  }
2299
2305
 
@@ -2718,6 +2724,14 @@ class EtherParser {
2718
2724
  break
2719
2725
  }
2720
2726
 
2727
+ if (current && current.type === TokenType.COMMA) {
2728
+ break
2729
+ }
2730
+
2731
+ if (current && current.type === TokenType.RPAREN) {
2732
+ break
2733
+ }
2734
+
2721
2735
  if (current && (current.type === TokenType.INDENT || current.type === TokenType.NEWLINE)) {
2722
2736
  this.advance()
2723
2737
  continue
@@ -2908,8 +2922,11 @@ class EtherParser {
2908
2922
  if (this.match(TokenType.LPAREN)) {
2909
2923
  const args = []
2910
2924
  while (!this.isAtEnd() && !this.match(TokenType.RPAREN)) {
2925
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2926
+ if (this.check(TokenType.RPAREN)) break
2911
2927
  args.push(this.parseExpression(lang))
2912
2928
  this.match(TokenType.COMMA)
2929
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2913
2930
  }
2914
2931
  expr = { type: 'CallExpression', callee: expr, arguments: args }
2915
2932
  } else if (this.match(TokenType.DOT)) {
@@ -3001,6 +3018,7 @@ class EtherParser {
3001
3018
  this.advance()
3002
3019
  const expr = this.parseExpression(lang)
3003
3020
  this.expect(TokenType.RPAREN)
3021
+ expr.parenthesized = true
3004
3022
  return expr
3005
3023
  }
3006
3024
 
@@ -1764,7 +1764,8 @@ class JSGenerator {
1764
1764
  const left = this.generateNode(node.left)
1765
1765
  const right = this.generateNode(node.right)
1766
1766
  const op = this.translateOperator(node.operator)
1767
- return `${left} ${op} ${right}`
1767
+ const expr = `${left} ${op} ${right}`
1768
+ return node.parenthesized ? `(${expr})` : expr
1768
1769
  }
1769
1770
 
1770
1771
  generateUnaryExpression(node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ether-code",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "Ether - Le langage intentionnel",
5
5
  "main": "cli/compiler.js",
6
6
  "bin": {