mr-parser 0.2.0 → 0.2.2

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/lib/Lexer.js CHANGED
@@ -62,13 +62,6 @@ var DELIMITERS = {
62
62
  '>>': true
63
63
  }
64
64
 
65
- // var NAMED_DELIMETERS = {
66
- // 'mod': true,
67
- // 'and': true,
68
- // 'or': true,
69
- // 'xor': true
70
- // }
71
-
72
65
  // helpers
73
66
 
74
67
  function isDigit (c) {
package/lib/Parser.js CHANGED
@@ -52,7 +52,7 @@ var BlockNode = require('./node/BlockNode')
52
52
  * | multiplicative (`+` | `-`) additive
53
53
  *
54
54
  * multiplicative : unary
55
- * | unary (`*` | `/` | `%`) multiplicative
55
+ * | unary (`*` | `/` | `%`) unary
56
56
  * | unary symbol
57
57
  *
58
58
  * unary : pow
@@ -248,10 +248,9 @@ Parser.prototype.shift = function () {
248
248
 
249
249
  Parser.prototype.additive = function () {
250
250
  var left = this.multiplicative()
251
- if (this.peek('+', '-')) {
251
+ while (this.peek('+', '-')) {
252
252
  var op = this.consume()
253
- var right = this.additive()
254
- return new OperatorNode(op.value, [left, right])
253
+ left = new OperatorNode(op.value, [left, this.multiplicative()])
255
254
  }
256
255
  return left
257
256
  }
@@ -259,10 +258,9 @@ Parser.prototype.additive = function () {
259
258
  Parser.prototype.multiplicative = function () {
260
259
  var op, right
261
260
  var left = this.unary()
262
- if (this.peek('*', '/', '%')) {
261
+ while (this.peek('*', '/', '%')) {
263
262
  op = this.consume()
264
- right = this.multiplicative()
265
- return new OperatorNode(op.value, [left, right])
263
+ left = new OperatorNode(op.value, [left, this.unary()])
266
264
  }
267
265
 
268
266
  // implicit multiplication
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "mr-parser",
3
- "version": "0.2.0",
4
- "description": "parse mathematical expressions into an ast",
5
- "bugs": "https://github.com/maurizzzio/mr-parser/issues",
3
+ "version": "0.2.2",
4
+ "description": "parses mathematical expressions and outputs an AST that represents the expression",
5
+ "bugs": "https://github.com/mauriciopoppe/mr-parser/issues",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
8
- "author": "Mauricio Poppe <mauricio.poppe@gmail.com>",
8
+ "author": "Mauricio Poppe (https://mauriciopoppe.com)",
9
9
  "files": [
10
10
  "index.js",
11
11
  "lib",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/maurizzzio/mr-parser"
16
+ "url": "https://github.com/mauriciopoppe/mr-parser"
17
17
  },
18
18
  "keywords": [
19
19
  "mr-parser",
@@ -36,7 +36,7 @@
36
36
  "istanbul": "istanbul cover test/index.js",
37
37
  "lint": "standard",
38
38
  "doctoc": "doctoc .",
39
- "test": "node test/index.js | tap-dot",
39
+ "test": "node test/index.js | tap-spec",
40
40
  "test:watch": "gaze 'npm test' 'test/**/*.js' 'lib/**/*.js' 'index.js'",
41
41
  "start": "npm run test:watch"
42
42
  }