Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document peg$ variables and methods within a generated parser #527

Open
4 tasks
futagoza opened this issue Sep 3, 2017 · 2 comments
Open
4 tasks

Document peg$ variables and methods within a generated parser #527

futagoza opened this issue Sep 3, 2017 · 2 comments

Comments

@futagoza
Copy link
Member

futagoza commented Sep 3, 2017

As mentioned by @felix9 in #526, variables (as well as methods) that are prefixed with peg$ in the generated parser are not exactly well known, with developers only discovering them when they either:

  1. dig through the generated parser
  2. look through the source for PEG.js
  3. find out from another PEG.js developer (the most common case I guess)

Let's fix this with more documentation (the joy 😑), as well as document reserved identifiers within the peg$ namespace (e.g. peg$c is used by actions, tokens, etc) so that developers know what not to overwrite, and hackers know exactly what to overwrite 🤣

  • Usable variables
  • Usable methods (internal helpers)
  • Reserved identifiers not recommended for overwriting
  • Examples of what could be accomplished using these
@futagoza futagoza added this to the 1.0.0 milestone Sep 3, 2017
@dmajda
Copy link
Contributor

dmajda commented Oct 14, 2017

The peg$ variables and functions were meant as internal. They are tied to the specifics of the PEG.js implementation and the idea was that they can change any time between versions (and they did so in the past). They are definitely not an API!

It may make sense to document the peg$ variables and functions as part of documenting PEG.js internals, but I’d strongly advise against the idea of making them officially available for parser authors and/or plugin writers. It would limit the development of PEG.js in the future. Better to build the API on top of them.

@felix9
Copy link
Contributor

felix9 commented Oct 14, 2017

So maybe there should be explicit documentation that "peg$" identifiers are not guaranteed to be stable across releases, and should not be relied upon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants