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 +0 -7
- package/lib/Parser.js +5 -7
- package/package.json +6 -6
package/lib/Lexer.js
CHANGED
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 (`*` | `/` | `%`)
|
|
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
|
-
|
|
251
|
+
while (this.peek('+', '-')) {
|
|
252
252
|
var op = this.consume()
|
|
253
|
-
|
|
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
|
-
|
|
261
|
+
while (this.peek('*', '/', '%')) {
|
|
263
262
|
op = this.consume()
|
|
264
|
-
|
|
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.
|
|
4
|
-
"description": "
|
|
5
|
-
"bugs": "https://github.com/
|
|
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
|
|
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/
|
|
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-
|
|
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
|
}
|