{"id":17537708,"url":"https://github.com/bates64/nearley-moo","last_synced_at":"2025-08-01T05:37:54.661Z","repository":{"id":57309598,"uuid":"85503474","full_name":"bates64/nearley-moo","owner":"bates64","description":"ultra-fast tokenizer plugin for nearley :cow2:","archived":false,"fork":false,"pushed_at":"2017-07-11T15:17:45.000Z","size":3,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T07:46:02.375Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bates64.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-19T19:41:45.000Z","updated_at":"2025-01-10T06:37:54.000Z","dependencies_parsed_at":"2022-08-27T04:21:49.763Z","dependency_job_id":null,"html_url":"https://github.com/bates64/nearley-moo","commit_stats":null,"previous_names":["nanalan/nearley-moo","bates64/nearley-moo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bates64%2Fnearley-moo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bates64%2Fnearley-moo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bates64%2Fnearley-moo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bates64%2Fnearley-moo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bates64","download_url":"https://codeload.github.com/bates64/nearley-moo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248465341,"owners_count":21108244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-20T20:42:35.445Z","updated_at":"2025-04-11T19:09:33.415Z","avatar_url":"https://github.com/bates64.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## nearley-moo\n#### [moo (ultra-fast tokenizer)](https://github.com/tjvr/moo) plugin for [nearley](https://github.com/Hardmath123/nearley) :cow2:\n\n[![npm](https://img.shields.io/npm/v/nearley-moo.svg)](https://npmjs.com/package/nearley-moo)\n\n## install\n\n**with npm**\n```sh\nnpm install nearley-moo --save\n```\n\n**with yarn**\n```sh\nyarn add nearley-moo\n```\n\n## usage\n\n**index.js**\n```js\nconst moo = require('moo')\nconst nearley = require('nearley')\nconst grammar = require('./grammar.js') // compiled from grammar.ne\nconst tokens = require('./tokens.js')\n\nconst nm = require('nearley-moo').parser(nearley, grammar) // curried\n\nlet parser = nm(moo.compile(tokens))\n\n// ignored tokens will not be passed to nearley\n// helpful for whitespace and/or comments\nparser.ignore('whitespace') // may be Array\u003cstring\u003e or String\n\n// feed your lexer+parser combo as normal\nparser.feed('if true then moomoomoo else cows')\n\nconsole.log(parser.results) // just like nearley\n```\n\n**tokens.js**\n```js\nmodule.exports = {\n  whitespace: /[ \\t]+/,\n  moo: /(moo)+/,\n  cows: /cows/,\n  boolean: [ 'true', 'false' ],\n  keyword: [ 'if', 'then', 'else'],\n}\n```\n\n**grammar.ne**\n```ne\n@{%\n\nconst nm = require('nearley-moo')\nconst tokens = require('./tokens.js')\n\nnm(tokens)\n\n%}\n\nmain -\u003e %keyword_if expression %keyword_then expression %keyword_else expression\n\nexpression -\u003e boolean\n            | %moo\n            | %cows\n\nboolean -\u003e %boolean_true  {% d =\u003e true %}\n         | %boolean_false {% d =\u003e false %}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbates64%2Fnearley-moo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbates64%2Fnearley-moo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbates64%2Fnearley-moo/lists"}