{"id":15974446,"url":"https://github.com/seb35/pegjs-syntactic-actions","last_synced_at":"2025-10-28T08:31:22.072Z","repository":{"id":35093717,"uuid":"205713544","full_name":"Seb35/pegjs-syntactic-actions","owner":"Seb35","description":"A PEG.js plugin to replace default actions and obtain syntactic trees","archived":false,"fork":false,"pushed_at":"2022-12-30T20:17:44.000Z","size":106,"stargazers_count":2,"open_issues_count":9,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-20T19:41:58.182Z","etag":null,"topics":["pegjs","pegjs-plugin"],"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/Seb35.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-01T18:02:38.000Z","updated_at":"2020-10-14T15:23:42.000Z","dependencies_parsed_at":"2023-01-15T13:41:20.213Z","dependency_job_id":null,"html_url":"https://github.com/Seb35/pegjs-syntactic-actions","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seb35%2Fpegjs-syntactic-actions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seb35%2Fpegjs-syntactic-actions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seb35%2Fpegjs-syntactic-actions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seb35%2Fpegjs-syntactic-actions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Seb35","download_url":"https://codeload.github.com/Seb35/pegjs-syntactic-actions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238618644,"owners_count":19502096,"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":["pegjs","pegjs-plugin"],"created_at":"2024-10-07T21:41:43.041Z","updated_at":"2025-10-28T08:31:16.767Z","avatar_url":"https://github.com/Seb35.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/Seb35/pegjs-syntactic-actions.svg?branch=master)](https://travis-ci.org/Seb35/pegjs-syntactic-actions)\n\npegjs-syntactic-actions\n=======================\n\nThis [PEG.js](https://pegjs.org) plugin removes all actions in a grammar and adds to rules actions returning text and location.\n\nAs a result:\n\n1. any potential bug in actions is removed, making the grammar strictly syntactic;\n2. the resulting tree documents captured rules.\n\nWhen writing complex grammars, it can be useful to first debug syntactic aspects of the grammar with this plugin, then execute the default actions.\n\n\nExample\n-------\n\n```javascript\nimport pegjs from \"pegjs\";\nimport SyntacticActionsPlugin from \"pegjs-syntactic-actions\";\n\nconst parser = pegjs.generate(\n  `\n    rule = \"a\"+ ( b / c )+\n    b = \"b\" { return bug; }\n    c = \"c\"\n  `,\n  {\n    plugins: [ new SyntacticActionsPlugin() ]\n  }\n);\n\nconsole.log( parser.parse( \"aabc\" ) );\n```\n\nreturns:\n\n```json\n{\n  \"rule\": \"rule\",\n  \"text\": \"aabc\",\n  \"start\": 0,\n  \"end\": 4,\n  \"children\": [\n    [\n      \"a\",\n      \"a\"\n    ],\n    [\n      {\n        \"rule\": \"b\",\n        \"text\": \"b\",\n        \"start\": 2,\n        \"end\": 3,\n        \"children\": \"b\"\n      },\n      {\n        \"rule\": \"c\",\n        \"text\": \"c\",\n        \"start\": 3,\n        \"end\": 4,\n        \"children\": \"c\"\n      }\n    ]\n  ]\n}\n```\n\nAlthough it would have returned an error without the plugin:\n\n```\nundefined:148\n        peg$c4 = function() { return bug; },\n                              ^\n\nReferenceError: bug is not defined\n```\n\n\nUsage\n-----\n\n### Installation\n\n```sh\nnpm install pegjs-syntactic-actions\n```\n\n### Use\n\nIn the second argument `options` of `pegjs.generate`, add the main object\n\n```javascript\n{\n  plugins: [ new SyntacticActionsPlugin() ]\n}\n```\n\n#### Options\n\nIt can be given an argument `options` in the constructor. Currently only one is supported:\n\n* `ignoredRules`: array of rules names to be completely ignored (these rules will keep their original actions).\n\nFor instance:\n\n```javascript\n{\n  plugins: [ new SyntacticActionsPlugin( { ignoredRules: [ \"rule1\" ] } ) ]\n}\n```\n\n#### Documentation\n\nA JSON schema is included in the `docs` directory, documenting the output of the parser modified by this plugin. Obviously, if there are ignored rules, these rules can detract the validity of the JSON schema.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseb35%2Fpegjs-syntactic-actions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseb35%2Fpegjs-syntactic-actions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseb35%2Fpegjs-syntactic-actions/lists"}