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

Expose API to get the current CSTNode #1032

Open
bd82 opened this issue Sep 4, 2019 · 2 comments
Open

Expose API to get the current CSTNode #1032

bd82 opened this issue Sep 4, 2019 · 2 comments

Comments

@bd82
Copy link
Member

bd82 commented Sep 4, 2019

Lets say we want to modify the CSTNode being created.

For Example:

        $.RULE("array", () => {
            const from = this.currIdx
           $.CONSUME(LSquare)
            // ...
            $.CONSUME(RSquare)
            const to = this.currIdx

            // Ugly way to access the current CSTNode using internal APIs
            this.CST_STACK[this.CST_STACK.length - 1].tokVectorRange = {
                from: from,
                to: to
            }
        })

It seems there should be a better way to access the current CSTNode.
Both in terms of being documented on the public API and in terms of conciseness.
Perhaps something like this.currCSTNode or maybe just this.currNode

@bd82
Copy link
Member Author

bd82 commented Sep 4, 2019

Tasks

  • Expose relevant method on the tree builder parser trait.
  • Document the new API in api.d.ts CstParser class.
  • Should there be special handling if this API is called from an EmbeddedActionsParser?
    - e.g throw an error?
  • Tests and 100% Coverage.
  • Create small example in examples/parser for this scenario.
  • Update CST Guide Docs on the website (also link above example).

@bd82 bd82 added the API label Sep 4, 2019
@drayavannie drayavannie mentioned this issue Feb 6, 2020
6 tasks
@bd82
Copy link
Member Author

bd82 commented Feb 6, 2020

Thanks for helping @drayavannie, lets track everything in this single issue?

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

1 participant