ether-code 0.4.7 → 0.4.8

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.4.7'
9
+ const VERSION = '0.4.8'
10
10
 
11
11
  const COLORS = {
12
12
  reset: '\x1b[0m',
package/ether-parser.js CHANGED
@@ -2026,6 +2026,14 @@ class EtherParser {
2026
2026
  return { type: 'UnaryExpression', operator: '-', operand }
2027
2027
  }
2028
2028
 
2029
+ if (this.matchValue('nouveau') || this.matchValue('new')) {
2030
+ const callee = this.parseCall(lang)
2031
+ if (callee.type === 'CallExpression') {
2032
+ return { type: 'NewExpression', callee: callee.callee, arguments: callee.arguments }
2033
+ }
2034
+ return { type: 'NewExpression', callee, arguments: [] }
2035
+ }
2036
+
2029
2037
  return this.parseCall(lang)
2030
2038
  }
2031
2039
 
@@ -2141,26 +2149,32 @@ class EtherParser {
2141
2149
  this.match(TokenType.COMMA)
2142
2150
  }
2143
2151
 
2144
- return { type: 'ArrayLiteral', elements }
2152
+ return { type: 'ArrayExpression', elements }
2145
2153
  }
2146
2154
 
2147
2155
  parseObjectLiteral(lang) {
2148
2156
  this.expect(TokenType.LBRACE)
2149
2157
  const properties = []
2150
2158
 
2151
- while (!this.isAtEnd() && !this.match(TokenType.RBRACE)) {
2159
+ this.skipWhitespace()
2160
+
2161
+ while (!this.isAtEnd() && !this.check(TokenType.RBRACE)) {
2162
+ this.skipWhitespace()
2163
+
2152
2164
  const keyToken = this.current()
2153
- if (!keyToken) break
2165
+ if (!keyToken || keyToken.type === TokenType.RBRACE) break
2154
2166
 
2155
2167
  let key
2156
2168
  if (keyToken.type === TokenType.STRING) {
2157
- key = keyToken.value.replace(/^["']|["']$/g, '')
2169
+ const keyValue = keyToken.value.replace(/^["']|["']$/g, '')
2170
+ key = { type: 'Literal', value: keyValue }
2171
+ this.advance()
2158
2172
  } else if (keyToken.type === TokenType.IDENTIFIER) {
2159
- key = keyToken.value
2173
+ key = { type: 'Identifier', name: keyToken.value }
2174
+ this.advance()
2160
2175
  } else {
2161
2176
  break
2162
2177
  }
2163
- this.advance()
2164
2178
 
2165
2179
  this.match(TokenType.COLON) || this.match(TokenType.EQUALS)
2166
2180
 
@@ -2168,9 +2182,21 @@ class EtherParser {
2168
2182
  properties.push({ key, value })
2169
2183
 
2170
2184
  this.match(TokenType.COMMA)
2185
+ this.skipWhitespace()
2171
2186
  }
2172
2187
 
2173
- return { type: 'ObjectLiteral', properties }
2188
+ this.match(TokenType.RBRACE)
2189
+
2190
+ return { type: 'ObjectExpression', properties }
2191
+ }
2192
+
2193
+ skipWhitespace() {
2194
+ while (this.match(TokenType.NEWLINE) || this.match(TokenType.INDENT) || this.match(TokenType.DEDENT)) {}
2195
+ }
2196
+
2197
+ check(type) {
2198
+ const token = this.current()
2199
+ return token && token.type === type
2174
2200
  }
2175
2201
 
2176
2202
  parseSQLProgram() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ether-code",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "Ether - Le langage intentionnel",
5
5
  "main": "cli/compiler.js",
6
6
  "bin": {