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

Closed
anton-trunov opened this issue Jul 4, 2024 · 3 comments
Closed
Labels
kind: refactoring Improve code readability misc: func Any issues related to FunC scope: codegen Code generation, a.k.a. compiler backend (src/generator)

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 kind: refactoring Improve code readability scope: codegen Code generation, a.k.a. compiler backend (src/generator) 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

@anton-trunov
Copy link
Member Author

Retracting the requirement

as not planned

@anton-trunov anton-trunov modified the milestones: v1.5.0, v1.6.0 Jul 30, 2024
@anton-trunov anton-trunov added the misc: func Any issues related to FunC label Aug 31, 2024
@anton-trunov anton-trunov removed this from the v1.6.0 milestone Jan 16, 2025
@anton-trunov anton-trunov closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: refactoring Improve code readability misc: func Any issues related to FunC scope: codegen Code generation, a.k.a. compiler backend (src/generator)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants