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

Refactor codegen: split FunC AST generation and pretty-printing #526

Open
anton-trunov opened this issue Jul 4, 2024 · 3 comments · May be fixed by #559
Open

Refactor codegen: split FunC AST generation and pretty-printing #526

anton-trunov opened this issue Jul 4, 2024 · 3 comments · May be fixed by #559
Assignees
Labels
func refactoring scope: codegen Code generation, a.k.a. compiler backend
Milestone

Comments

@anton-trunov
Copy link
Member

anton-trunov commented Jul 4, 2024

Some remarks on the design of the new codegen architecture:

  • Code generation should be a two-step transformation: (1) produce FunC ASTs, (2) pretty-print FunC ASTs which we then use to feed into the FunC compiler as we do new;
  • Special care should be taken to avoid clashes between identifiers and FunC keywords;
  • The FunC pretty-printer should produce human readable code that should look like the currently produced FunC code;
  • The FunC pretty-printer should have configuration options to support fully-parenthesized expressions and more human-readable version (we should focus on the easier fully-parenthesized version first);
  • The TypeScript representation of FunC AST and the pretty-printer should be available as a separate NPM package so it can be re-used by TON community.

Related issue in the ongoing series of refactorings: #458.

@anton-trunov anton-trunov added refactoring scope: codegen Code generation, a.k.a. compiler backend labels Jul 4, 2024
@anton-trunov anton-trunov added this to the v1.5.0 milestone Jul 4, 2024
@anton-trunov
Copy link
Member Author

@byakuren-hijiri Btw, the pretty-printer and the FunC AST data structure should be adaptable to #420

@novusnota
Copy link
Member

novusnota commented Jul 5, 2024

If we were to parse FunC via Ohm, FuncParser.bnf and FuncLexer.flex from ton-blockchain/intellij-ton can be helpful guidances as there's no formal description of FunC. Also, it's parser is almost exclusively located in one file, which is helpful too: parse-func.cpp

@byakuren-hijiri byakuren-hijiri linked a pull request Jul 12, 2024 that will close this issue
84 tasks
@anton-trunov
Copy link
Member Author

Retracting the requirement

as not planned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
func refactoring scope: codegen Code generation, a.k.a. compiler backend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants