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

[FEATURE] Include a Cadence parser in FCL #1678

Open
JeffreyDoyle opened this issue Jun 6, 2023 · 2 comments
Open

[FEATURE] Include a Cadence parser in FCL #1678

JeffreyDoyle opened this issue Jun 6, 2023 · 2 comments
Assignees
Labels

Comments

@JeffreyDoyle
Copy link
Member

Issue to be solved

In order to robustly parse Cadence, to do things such as understand which arguments are used in a transaction or script, we must include the ability to parse Cadence in FCL.

Suggest A Solution

Investigate tooling such as:

See if there is a way to convert the Cadence grammar to PEG format: https://github.com/onflow/cadence/blob/master/docs/cadence.ebnf

We must ensure the bundle size of FCL doesn't increase beyond a reasonable amount. To do so, we should consider if we can use a tool like pegjs or peggy to generate a parser on the client using a supplied Cadence grammar, rather than include the parser as part of the FCL bundle.

What are you currently working on that this is blocking?

We need this feature in order to complete the updated FCL query/mutate argument syntax: #1656

@turbolent
Copy link
Member

turbolent commented Jun 6, 2023

A simple and effective way to reduce the size of the parser and making it more efficient for this use case (reduce memory consumption) could be to refactor the parser to not depend on the AST package (and transitively on the pretty printing package code and library as @bluesign pointed out), by changing the productions from allocations of AST nodes to interface callbacks.

In Cadence, the callbacks would perform the node creation as currently.

In the stripped down parser you would not have to allocate any nodes in the callbacks, except for function parameters (and that could be further filtered to just parameter lists you are interested in).

@turbolent
Copy link
Member

Opened onflow/cadence#2549 with an idea how we can reduce the size

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🏗 In Progress
Development

No branches or pull requests

4 participants