{"_id":"parser","_rev":"14-a966df21a750108b133fef971891d0c0","name":"parser","description":"A configurable parser to parse whatever you want","dist-tags":{"latest":"0.1.4"},"versions":{"0.1.0":{"name":"parser","description":"A configurable parser to parse whatever you want","version":"0.1.0","homepage":"http://github.com/floby/node-parser","repository":{"type":"git","url":"git://github.com/floby/node-parser.git"},"author":{"name":"Florent Jaby","email":"florent.jaby@gmail.com"},"main":"lib/Parser.js","directories":{"lib":"lib"},"engines":{"node":"0.4"},"dependencies":{"tokenizer":"*"},"_id":"parser@0.1.0","_engineSupported":true,"_npmVersion":"0.3.18","_nodeVersion":"v0.4.5","files":[""],"_defaultsLoaded":true,"dist":{"shasum":"84cb09bac75c2f4d4fc5ded4a7b7422f5195db56","tarball":"https://registry.npmjs.org/parser/-/parser-0.1.0.tgz","integrity":"sha512-mSKHYOBicf2vkv6idYcAonjIaWG3do5PnKc3dne6HByzdoeaqLjP+HZ56p8Z+5VT9tGkNoQytgVp8RLkcUxxBA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDA3HV0l1McB5TWaq6ghEEcK8PeLyqwvN+HLTb0nMTrygIgD/WP3sGiQMJL718KXcuuoiEnKeUPF2GHvnvoA6dgOdM="}]}},"0.1.1":{"name":"parser","description":"A configurable parser to parse whatever you want","version":"0.1.1","homepage":"http://github.com/floby/node-parser","repository":{"type":"git","url":"git://github.com/floby/node-parser.git"},"author":{"name":"Florent Jaby","email":"florent.jaby@gmail.com"},"main":"lib/Parser.js","directories":{"lib":"lib"},"engines":{"node":"0.4"},"dependencies":{"tokenizer":"*"},"_npmJsonOpts":{"file":"/home/floby/.npm/parser/0.1.1/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"parser@0.1.1","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.14","_nodeVersion":"v0.4.9-pre","_defaultsLoaded":true,"dist":{"shasum":"14cc8eec68da13ecacef6eec51883ca017735758","tarball":"https://registry.npmjs.org/parser/-/parser-0.1.1.tgz","integrity":"sha512-C/8mQComUdGnWxroqZKFTy9NBcRL7tMZSUgG5AQUy9L4h5lfjg56NA3qrF/903foO5luiNxFVmdoHDNN4kr2Ow==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHmM8ACzmEORGxphnPzPkY0Qx360M4p/veJxeFqP0OIyAiEAuwsBmAcHgn/0ds4S9PgWYSVsd2Hno/ZPX+KiC5RQD0s="}]},"scripts":{}},"0.1.2":{"name":"parser","description":"A configurable parser to parse whatever you want","version":"0.1.2","homepage":"http://github.com/floby/node-parser","repository":{"type":"git","url":"git://github.com/floby/node-parser.git"},"author":{"name":"Florent Jaby","email":"florent.jaby@gmail.com"},"main":"lib/Parser.js","directories":{"lib":"lib"},"engines":{"node":"0.6"},"dependencies":{"tokenizer":"*"},"_npmUser":{"name":"floby","email":"florent.jaby@gmail.com"},"_id":"parser@0.1.2","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.6.0","_defaultsLoaded":true,"dist":{"shasum":"963fa7a80ee4fb83f84e29269c196c960882809f","tarball":"https://registry.npmjs.org/parser/-/parser-0.1.2.tgz","integrity":"sha512-kqQOL0liIOKCMHLd1c8pkGWyNifUFR47T81NnSQRDjxSskXSq6X6O0SIomgPRVfh9nKVNSqCnpggPyA/beLeFg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGMS7s/UggxdzN8SFIpCYC27QLIdckq/qOEfkqI2M1kSAiBEy4vkGr8Hhec7a/fbc8X6wndk+hehQQN2IcqtJBMyag=="}]},"maintainers":[{"name":"floby","email":"florent.jaby@gmail.com"}]},"0.1.3":{"name":"parser","description":"A configurable parser to parse whatever you want","version":"0.1.3","homepage":"http://github.com/floby/node-parser","repository":{"type":"git","url":"git://github.com/floby/node-parser.git"},"author":{"name":"Florent Jaby","email":"florent.jaby@gmail.com"},"main":"lib/Parser.js","directories":{"lib":"lib"},"engines":{"node":"0.4-0.9"},"dependencies":{"tokenizer":"*"},"readme":"","_id":"parser@0.1.3","dist":{"shasum":"7cca54cc0dc9350e32b40a9ae5737b006d8cb428","tarball":"https://registry.npmjs.org/parser/-/parser-0.1.3.tgz","integrity":"sha512-ywH6K6CsFrt/mYc3SR/7EqLHfuq0CdAw5DpMr+qQE7CCC5m3msx6fhFZe3j3SpIIg/6Bzn9CRqS/71gi+kXGjw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDbkuT36D4xeTYWfwQTKcUpSH/4a99FX3GjdOzEQ3c6zAiEAll3rc/aMWBmrvDGnJq184LFbG57KC1pNW3k+8gmX38c="}]},"maintainers":[{"name":"floby","email":"florent.jaby@gmail.com"}]},"0.1.4":{"name":"parser","description":"A configurable parser to parse whatever you want","version":"0.1.4","homepage":"http://github.com/floby/node-parser","repository":{"type":"git","url":"git://github.com/floby/node-parser.git"},"author":{"name":"Florent Jaby","email":"florent.jaby@gmail.com"},"main":"lib/Parser.js","directories":{"lib":"lib"},"engines":{"node":"0.4-0.9"},"dependencies":{"tokenizer":"*"},"readme":"# Synopsis\nThis module is basically a class that provides general mechanisms for\nparsing strings. It works with my [tokenizer](http://github.com/floby/node-tokenizer)\nalthough it can be used with pretty much anything emitting tokens the same\nway.\nThe parser works with a queue of functions. For each token the next function\nin the queue is called.\n\n# write you own parser\n\n### tokenizer\nOnly one thing is required for the parser to work : a tokenizer.\nThese concepts are very different and that is why they are implemented\nseparately. The easiest solution is to use my [tokenizer](http://github.com/floby/node-tokenizer)\n\n\n### parser\nThe default behaviour upon receiving a new token is ignoring it. It prints\na warning when reaching EOF with the number of tokens that have been ignored.\nHowever this is probably not what you want to do!\n\nIn order to parse what you need to parse you have to provide the parser\nwith the functions which will be called for each token. Let's call these\nfunctions _'handlers'_.\nThis can be achieved through configuration of the basic parser or\nthrough inheritance.\n    \n``` javascript\nvar Parser = require('parser');\nvar util = require('util');\nvar MyTokenizer = require('./MyTokenizer');\n\nfunction MyParser() {\n    // MyTokenizer is the tokenizer we configured\n    // but it's not the subject of this module\n    Parser.apply(this, new MyTokenizer());\n\n    // override the default behaviour\n    this.defaultHandler(this.default);\n\n    // specify the function that will be called on the first token\n    this.initialHander(this.initial);\n}\nutil.inherits(MyParser, Parser);\n\n/**\n * Of course you will have to define these functions somewhere\n */\n```\n\nThis is very theoretic but you can have a look at what is in the example \nfolder\n\n## Handlers\nHandlers are just javascript functions accepting the following arguments:\n\n* `token` the actual token emitted by the tokenizer\n* `type` the type of this token (i.e. `'number'`, `'whitespace'`, `'word'`)\n* `next` a function to specify what needs to be called on the next token(s)\n\nthe `next` function takes a random number of handlers which will be pushed\nin front of the handlers queue (they will be _next_!).\nreturning `true` from a handler causes the same token to be reemitted\nto the next handler.\n\nThis allows you to define handlers doing some kind of \"sniffing\" if you find\nyourself in a state in which you cannot determine what will come next.\nThis kind of handlers _expand_ themselves to a greater number of handlers that\nwill effectively parse the following tokens. They do that by adding a few handlers\nto the queue with `next` and returning `true` to notify the parser that the token\nshould be reemitted.\n\n### Handlers utilities\nthere are a few handlers factories provided by this module.\n\n* `checkType(type)` returns a handler that only checks the type of the\ntoken without doing anything so the same token is pass down to the next\nhandler\n* `expect(type)` returns a handler that checks for the specified type\nand consumes the token\n* `list(separator, element, end)` returns a handler expanding to the\nhandlers needed to parse a list of elements able to be parsed by `element`\nand separated by tokens of type `separator`. The list should end by a\ntoken of type `end`\n\n# project\n## TODOs\n* more robustness / better error handling\n* features requests\n* Support for asynchronous handlers\n* allow for complex separator an ending tokens for handler utilities\n\n## Features requests / bugs\nIf you'd like the parser to do something that it doesn't do or want to report\na bug please use the github issue tracker on [github](http://github.com/floby/node-parser)\n\n## fork / patches / pull requests\nYou are very welcome to send patches or pull requests\n","readmeFilename":"README.markdown","_id":"parser@0.1.4","dist":{"shasum":"2d47a366cddcf6197d97f0aa91dd9077d923bd45","tarball":"https://registry.npmjs.org/parser/-/parser-0.1.4.tgz","integrity":"sha512-f6EM/mBtPzmIh96MpcbePfhkBOYRmLYWuOukJqMysMlvjp4s2MQSSQnFEekd9GV4JGTnDJ2uFt3Ztcqc9wCMJg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD40OU5pzW8CKFmv1h16EtjGq78PcQ8xVjExw+sKkGkQAIgJ1uzhM6M3HQSg6L9MPuRGGWhmcDtVLxgz8beLLRJPz4="}]},"_npmVersion":"1.1.66","_npmUser":{"name":"floby","email":"florent.jaby@gmail.com"},"maintainers":[{"name":"floby","email":"florent.jaby@gmail.com"}]}},"maintainers":[{"name":"floby","email":"florent.jaby@gmail.com"}],"time":{"modified":"2022-06-23T11:28:20.747Z","created":"2011-04-15T20:36:20.667Z","0.1.0":"2011-04-15T20:36:21.238Z","0.1.1":"2011-07-01T09:53:45.608Z","0.1.2":"2011-12-16T19:58:15.502Z","0.1.3":"2012-08-05T12:26:22.883Z","0.1.4":"2012-12-21T10:38:09.189Z"},"author":{"name":"Florent Jaby","email":"florent.jaby@gmail.com"},"repository":{"type":"git","url":"git://github.com/floby/node-parser.git"},"users":{"danpolitte":true}}