{"_id":"mr-parser","_rev":"9-1374a4397abeeab01fd450456b4cb4bd","name":"mr-parser","dist-tags":{"latest":"0.2.2"},"versions":{"0.1.0":{"name":"mr-parser","version":"0.1.0","keywords":["mr-parser","parser","math","expression"],"author":{"name":"Mauricio Poppe","email":"mauricio.poppe@gmail.com"},"license":"MIT","_id":"mr-parser@0.1.0","maintainers":[{"name":"maurizzzio","email":"mauricio.poppe@gmail.com"}],"homepage":"https://github.com/maurizzzio/mr-parser#readme","bugs":{"url":"https://github.com/maurizzzio/mr-parser/issues"},"dist":{"shasum":"531b624c2764dd9cc64bad74c44fa308ac79b183","tarball":"https://registry.npmjs.org/mr-parser/-/mr-parser-0.1.0.tgz","integrity":"sha512-vXqBlfwfbmsuFrOCvFjDWgHsd2aa4FqWCm7vUOOuam9HWNkfZ4h6GvsbUh4UwBvnVJr7uPjBLvSzqU2CcVKvZw==","signatures":[{"sig":"MEUCIQCPGTGmUnlLFQ+vEjEuViDXn3rLzjEz3DJbV+sh01CtqgIgeGscB63d/KLXX0VjKQVr9eNHZjcC5cmDhYqzdJorrdc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","files":["index.js","lib","LICENSE"],"_shasum":"531b624c2764dd9cc64bad74c44fa308ac79b183","gitHead":"e6763a1a968c3f18eafa2f86c13132a2b95f7670","scripts":{"lint":"standard","test":"node test/index.js | tap-dot","start":"npm run test:watch","istanbul":"istanbul cover test/index.js","test:watch":"gaze 'npm test' 'test/**/*.js' 'lib/**/*.js' 'index.js'"},"_npmUser":{"name":"maurizzzio","email":"mauricio.poppe@gmail.com"},"repository":{"url":"git+https://github.com/maurizzzio/mr-parser.git","type":"git"},"_npmVersion":"2.11.2","description":"parse mathematical expressions into an ast","_nodeVersion":"0.12.6","dependencies":{},"devDependencies":{"tape":"^4.0.1","tap-dot":"^1.0.0","gaze-cli":"^0.2.0","istanbul":"^0.3.8","standard":"^4.5.0","tap-spec":"^4.0.2","coveralls":"^2.11.2"},"directories":{}},"0.2.0":{"name":"mr-parser","version":"0.2.0","keywords":["mr-parser","parser","math","expression"],"author":{"name":"Mauricio Poppe","email":"mauricio.poppe@gmail.com"},"license":"MIT","_id":"mr-parser@0.2.0","maintainers":[{"name":"maurizzzio","email":"mauricio.poppe@gmail.com"}],"homepage":"https://github.com/maurizzzio/mr-parser#readme","bugs":{"url":"https://github.com/maurizzzio/mr-parser/issues"},"dist":{"shasum":"1553a8c6f2074b36a689be8a7f5cbaa29507d651","tarball":"https://registry.npmjs.org/mr-parser/-/mr-parser-0.2.0.tgz","integrity":"sha512-Mof1+ypPEmqL1Bpd17joPc5s7QrvoPqID4+DtbeBgGNWGd215398pmk/HTxExqfJBpA/k0TWQbuCcQfLuD2j2w==","signatures":[{"sig":"MEUCIQCxK+5UVs2v40GWJ/UK09BbBbDw7xSMpJtNNubCry8vCwIgdMigjMGksP9RWAg3DbIgse4LWcJJmVtQMgGq8kdg4gM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","files":["index.js","lib","LICENSE"],"_shasum":"1553a8c6f2074b36a689be8a7f5cbaa29507d651","gitHead":"78b6c53e788453caf8b37c3240b1395debb0e8d4","scripts":{"lint":"standard","test":"node test/index.js | tap-dot","start":"npm run test:watch","doctoc":"doctoc .","istanbul":"istanbul cover test/index.js","test:watch":"gaze 'npm test' 'test/**/*.js' 'lib/**/*.js' 'index.js'"},"_npmUser":{"name":"maurizzzio","email":"mauricio.poppe@gmail.com"},"repository":{"url":"git+https://github.com/maurizzzio/mr-parser.git","type":"git"},"_npmVersion":"2.11.2","description":"parse mathematical expressions into an ast","_nodeVersion":"0.12.6","dependencies":{},"devDependencies":{"tape":"^4.0.1","doctoc":"^0.14.2","tap-dot":"^1.0.0","gaze-cli":"^0.2.0","istanbul":"^0.3.8","standard":"^4.5.0","tap-spec":"^4.0.2","coveralls":"^2.11.2"},"directories":{}},"0.2.1":{"name":"mr-parser","version":"0.2.1","keywords":["mr-parser","parser","math","expression"],"author":{"name":"Mauricio Poppe","email":"mauricio.poppe@gmail.com"},"license":"MIT","_id":"mr-parser@0.2.1","maintainers":[{"name":"maurizzzio","email":"mauricio.poppe@gmail.com"}],"homepage":"https://github.com/maurizzzio/mr-parser#readme","bugs":{"url":"https://github.com/maurizzzio/mr-parser/issues"},"dist":{"shasum":"8618b9ba417e28e9f439a41c695b554eafeed927","tarball":"https://registry.npmjs.org/mr-parser/-/mr-parser-0.2.1.tgz","integrity":"sha512-hug+mpbSSKnH13rFqy3zm+XiG+QTStiDAgMTHK355TIstQE0qBkBtSJsa5YHP94AuarVX9b/4dcebdTRZ9YiEw==","signatures":[{"sig":"MEUCIH0qiMIcSEdJscdwLBDmCkk0g7c5UY2XiSm4jGv0bvHtAiEAsfoHkAL1D5X7fRfr0KC20E48kBmWYuOIRLIbtx6uino=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","files":["index.js","lib","LICENSE"],"_shasum":"8618b9ba417e28e9f439a41c695b554eafeed927","gitHead":"e60f3d23ac3b803205c7ff6b357a8e2c2ee766a9","scripts":{"lint":"standard","test":"node test/index.js | tap-spec","start":"npm run test:watch","doctoc":"doctoc .","istanbul":"istanbul cover test/index.js","test:watch":"gaze 'npm test' 'test/**/*.js' 'lib/**/*.js' 'index.js'"},"_npmUser":{"name":"maurizzzio","email":"mauricio.poppe@gmail.com"},"repository":{"url":"git+https://github.com/maurizzzio/mr-parser.git","type":"git"},"_npmVersion":"2.11.2","description":"parses mathematical expressions and outputs an AST that represents the expression","_nodeVersion":"0.12.6","dependencies":{},"devDependencies":{"tape":"^4.0.1","doctoc":"^0.14.2","tap-dot":"^1.0.0","gaze-cli":"^0.2.0","istanbul":"^0.3.8","standard":"^4.5.0","tap-spec":"^4.0.2","coveralls":"^2.11.2"},"directories":{}},"0.2.2":{"name":"mr-parser","version":"0.2.2","keywords":["mr-parser","parser","math","expression"],"author":{"url":"https://mauriciopoppe.com","name":"Mauricio Poppe"},"license":"MIT","_id":"mr-parser@0.2.2","maintainers":[{"name":"maurizzzio","email":"mauricio.poppe@gmail.com"},{"name":"mauriciopoppe","email":"5gl9sqyff@mozmail.com"}],"homepage":"https://github.com/mauriciopoppe/mr-parser#readme","bugs":{"url":"https://github.com/mauriciopoppe/mr-parser/issues"},"dist":{"shasum":"4a85706f6e8c88950480628fadb51bafc7e1f717","tarball":"https://registry.npmjs.org/mr-parser/-/mr-parser-0.2.2.tgz","fileCount":17,"integrity":"sha512-9pMgttJp8pZtiYfoHkhBc9ncOHKmEwLMNBQpS/ZXgj4ORnPMKznYR0lZ1We3ZrD71RevQ34hKyKzDV1p/agXuw==","signatures":[{"sig":"MEUCIQC+2+bgdQk0wpIuEWfGQo9d5+R9kWQWsAoN+0UuGQh8QAIgM6csI08rK61XX7AraKDq7V7IaD56riX4EBe1E6mvIeI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23906},"main":"index.js","gitHead":"ee915a4f6209a2c3965554ba5dc0fa6ee4c9a96a","scripts":{"lint":"standard","test":"node test/index.js | tap-spec","start":"npm run test:watch","doctoc":"doctoc .","istanbul":"istanbul cover test/index.js","test:watch":"gaze 'npm test' 'test/**/*.js' 'lib/**/*.js' 'index.js'"},"_npmUser":{"name":"mauriciopoppe","email":"5gl9sqyff@mozmail.com"},"repository":{"url":"git+https://github.com/mauriciopoppe/mr-parser.git","type":"git"},"_npmVersion":"10.9.2","description":"parses mathematical expressions and outputs an AST that represents the expression","directories":{},"_nodeVersion":"22.15.0","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"tape":"^4.0.1","doctoc":"^0.14.2","tap-dot":"^1.0.0","gaze-cli":"^0.2.0","istanbul":"^0.3.8","standard":"^4.5.0","tap-spec":"^4.0.2","coveralls":"^2.11.2"},"_npmOperationalInternal":{"tmp":"tmp/mr-parser_0.2.2_1766773321743_0.02940751374054007","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2015-07-22T06:18:07.482Z","modified":"2025-12-31T05:37:33.404Z","0.1.0":"2015-07-22T06:18:07.482Z","0.2.0":"2015-07-22T08:27:25.888Z","0.2.1":"2015-07-22T20:18:27.553Z","0.2.2":"2025-12-26T18:22:01.894Z"},"bugs":{"url":"https://github.com/mauriciopoppe/mr-parser/issues"},"author":{"url":"https://mauriciopoppe.com","name":"Mauricio Poppe"},"license":"MIT","homepage":"https://github.com/mauriciopoppe/mr-parser#readme","keywords":["mr-parser","parser","math","expression"],"repository":{"url":"git+https://github.com/mauriciopoppe/mr-parser.git","type":"git"},"description":"parses mathematical expressions and outputs an AST that represents the expression","maintainers":[{"email":"5gl9sqyff@mozmail.com","name":"mauriciopoppe"}],"readme":"# mr-parser \n\n[![Build Status][travis-image]][travis-url] [![npm][npm-image]][npm-url]  [![Coverage Status][coveralls-image]][coveralls-url] ![Stability][stability-image]\n\n[stability-image]: https://img.shields.io/badge/stability-stable-green.svg\n[travis-image]: https://travis-ci.org/maurizzzio/mr-parser.svg?branch=master\n[travis-url]: https://travis-ci.org/maurizzzio/mr-parser\n[npm-image]: https://img.shields.io/npm/v/mr-parser.svg?style=flat\n[npm-url]: https://npmjs.org/package/mr-parser\n[coveralls-image]: https://coveralls.io/repos/maurizzzio/mr-parser/badge.svg\n[coveralls-url]: https://coveralls.io/r/maurizzzio/mr-parser\n\n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n\n> Parses mathematical expressions and outputs an AST\n\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n\n\n- [Description](#description)\n  - [why?](#why)\n  - [Grammar](#grammar)\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n  - [`Parser = require('mr-parser').Parser`](#parser--requiremr-parserparser)\n    - [`Parser.parse(expression)`](#parserparseexpression)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n## Description\n\n`mr-parser` is a lightweight mathematical parser inspired by [math.js expression parser][math-js], unlike [math.js expression parser][math-js] the AST nodes contain no info on how to compile a node which makes the parser modular\n\n### why?\n\nI felt that I had to make another parser because:\n\n- [math-parser](https://www.npmjs.com/package/math-parser) is too simple for me, it just operates on numbers and has the following operators `+, -, *, / and ^` and doesn't have variable substitution\n- [math.js expression parser][math-js] is perfect but it's not modularized yet, to use it one would have to include all the source code of math.js\n- [math.js expression parser][math-js] AST nodes have info about how to compile a node, I think it's better to let another module do that\n\n### Grammar\n\n```text\nprogram          : block (; block)*\n\nblock            : assignment\n\nassignment       : ternary\n                 | symbol `=` assignment\n\nternary          : logicalOR\n                 | logicalOR `?` ternary `:` ternary\n\nlogicalOR        : logicalXOR\n                 | logicalXOR (`||`,`or`) logicalOR\n\nlogicalXOR       : logicalAND\n                 : logicalAND `xor` logicalXOR\n\nlogicalAND       : bitwiseOR\n                 | bitwiseOR (`&&`,`and`) logicalAND\n\nbitwiseOR        : bitwiseXOR\n                 | bitwiseXOR `|` bitwiseOR\n\nbitwiseXOR       : bitwiseAND\n                 | bitwiseAND `^|` bitwiseXOR\n\nbitwiseAND       : relational\n                 | relational `&` bitwiseAND\n\nrelational       : shift\n                 | shift (`!=` | `==` | `>` | '<' | '<=' |'>=') shift)\n\nshift            : additive\n                 | additive (`>>` | `<<` | `>>>`) shift\n\nadditive         : multiplicative\n                 | multiplicative (`+` | `-`) additive\n\nmultiplicative   : unary\n                 | unary (`*` | `/` | `%`) multiplicative\n                 | unary symbol\n\nunary            : pow\n                 | (`-` | `+` | `~`) unary\n\npow              : factorial\n                 | factorial (`^`, '**') unary\n\nfactorial        : symbol\n                 | symbol (`!`)\n\nsymbol           : symbolToken\n                 | symbolToken functionCall\n                 | string\n\nfunctionCall     : `(` `)`\n                 | `(` ternary (, ternary)* `)`\n\nstring           : `'` (character)* `'`\n                 : `\"` (character)* `\"`\n                 | array\n\narray            : `[` `]`\n                 | `[` assignment (, assignment)* `]`\n                 | number\n\nnumber           : number-token\n                 | parentheses\n\nparentheses      : `(` assignment `)`\n                 : end\n\nend              : null-token\n```\n\n## Install\n\n```sh\n$ npm install --save mr-parser\n```\n\n## Usage\n\n```js\nvar Parser = require('mr-parser').Parser;\nParser.parse('1 * (2 + 3) * 4')\n\n// returns\n{\n  blocks:[{\n    op: '*',\n    args: [{\n      value: '1',\n      valueType: 'number'\n    }, {\n      op: '*',\n      args: [{\n        op: '+',\n        args: [\n          { value: '2', valueType: 'number' },\n          { value: '3', valueType: 'number' }\n        ]\n      }, {\n        value: '4',\n        valueType: 'number'\n      }]\n    }]\n  }]\n} \n\nParser.parse('2x')\n\n// returns\n{\n  blocks: [{\n    op: '*',\n    args: [\n      { value: '2', valueType: 'number' },\n      { name: 'x' }\n    ]\n  }]\n}\n```\n\n## API\n\n### `Parser = require('mr-parser').Parser`\n\n#### `Parser.parse(expression)`\n\n**params**\n* `expression` {string} the expression to be parsed\n\n**returns**\n* Returns an array of possibly nested nodes which is the AST that represents the expression\n\n[math-js]: http://mathjs.org/docs/expressions/index.html\n\n2015 MIT © [Mauricio Poppe]()\n","readmeFilename":"README.md"}