{"id":16636767,"url":"https://github.com/takamin/lex-bnf","last_synced_at":"2025-03-21T15:31:48.201Z","repository":{"id":32688905,"uuid":"139713971","full_name":"takamin/lex-bnf","owner":"takamin","description":"General-purpose recursive descent parser and evaluator","archived":false,"fork":false,"pushed_at":"2024-09-28T05:59:16.000Z","size":1525,"stargazers_count":8,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-23T12:33:46.950Z","etag":null,"topics":["analyzer","bnf","bnf-parser","javascript","lex-bnf","lexical-analysis","npm","parser-generator"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/takamin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-04T11:39:29.000Z","updated_at":"2024-09-28T05:43:57.000Z","dependencies_parsed_at":"2024-06-21T20:22:51.207Z","dependency_job_id":"505229b9-4a58-4850-81c3-51d42b4ae878","html_url":"https://github.com/takamin/lex-bnf","commit_stats":{"total_commits":53,"total_committers":2,"mean_commits":26.5,"dds":"0.26415094339622647","last_synced_commit":"a73194f4485ce9334f34b2b4c0e7f5d352bed3f7"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takamin%2Flex-bnf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takamin%2Flex-bnf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takamin%2Flex-bnf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takamin%2Flex-bnf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takamin","download_url":"https://codeload.github.com/takamin/lex-bnf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244811321,"owners_count":20514276,"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":["analyzer","bnf","bnf-parser","javascript","lex-bnf","lexical-analysis","npm","parser-generator"],"created_at":"2024-10-12T06:22:46.697Z","updated_at":"2025-03-21T15:31:47.928Z","avatar_url":"https://github.com/takamin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Lex-BNF\n=======\n\n\u003cspan class=\"display:inline-block;\"\u003e [![Build Status](https://travis-ci.org/takamin/lex-bnf.svg?branch=master)](https://travis-ci.org/takamin/lex-bnf)\n[![Coverage Status](https://coveralls.io/repos/github/takamin/lex-bnf/badge.svg?branch=master)](https://coveralls.io/github/takamin/lex-bnf?branch=master)\n![version](https://img.shields.io/npm/v/lex-bnf)\n![license](https://img.shields.io/npm/l/lex-bnf)\n\u003c/span\u003e\n\nThis is a **general-purpose recursive descent parser and evaluator**.\n\nUsing this module, You can:\n\n1. Defines a syntax rule such as programming languages, expressions, or structured statements.\n1. Parses the code written based on the rules.\n1. Evaluates the result of the parsing.\n\n__NOTE: The class `BNF` exported in v0.3.3 is deprecated and it can be used as `Language.BNF`.__\n\nCreate A `Language` Definition\n----\n\nThe parser is defined as an instance of `Language` class by using objects of BNF-like\nnotation and its evaluator functions. Those can run in dynamically and immediately.\n\nThe `Language` constructor takes one array of syntax rule.\nTo create the syntax rule, use `Language.syntax()` function.\n\n__Paramters of `Language.syntax()`:__\n\n1. A name of the syntax rule.\n1. An array of a rule which is an array of terms.\n    * A character '*' at the end of a rule name as an element of the terms is __Repetition Specifier__ that means the rule is repeatable.\n    * See the rule declaration part of `additive-expression` in [sample/calc.js](https://github.com/takamin/lex-bnf/blob/master/sample/calc.js) to use the feature.\n1. An evaluator function (optional). It can be omitted when the second parameter contains only one rule which containing only one other name of syntax rule.\n\n\n\nDemo: Evaluating arithmetic expression\n----\n\nWith following files, those shows how define a syntax of language.\n\n* [sample/eval-expr.js](https://github.com/takamin/lex-bnf/blob/master/sample/eval-expr.js)  \nA simple calculator script to parse and evaluate an expression from CLI.\n* [sample/calc.js](https://github.com/takamin/lex-bnf/blob/master/sample/calc.js)  \nAn implementation of the calculator syntax.\n\n__run on bash__\n\n```bash\n$ node sample/eval-expr.js '(1 + 2) * ((3 + 4) / 2)'\n10.5\n$\n```\n\nDocuments\n----\n\n* [GitHub Pages](https://takamin.github.io/lex-bnf/)\n* API Reference\n    * [v1.1.1](https://takamin.github.io/lex-bnf/docs/lex-bnf/1.1.1/)\n        * Fix the issue [#16](https://github.com/takamin/lex-bnf/issues/16)\n    * [v1.1.0](https://takamin.github.io/lex-bnf/docs/lex-bnf/1.1.0/)\n        * Repetition specifier `*` is available for the rule name. It is important for getting correct answer of multi term arithmetic expressions such as `1 - 2 - 3 = ?`.\n    * [v1.0.1](https://takamin.github.io/lex-bnf/docs/lex-bnf/1.0.1/)\n    * [v1.0.0](https://takamin.github.io/lex-bnf/docs/lex-bnf/1.0.0/)\n\nLICENSE\n-------\n\nThis software is released under the MIT License, see [LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakamin%2Flex-bnf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakamin%2Flex-bnf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakamin%2Flex-bnf/lists"}