Skip to content

FunC v0.5.0 support, diagnostics, and quickfixes #11

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

Closed
wants to merge 14 commits into from
Closed

Conversation

tolk-vm
Copy link
Collaborator

@tolk-vm tolk-vm commented Jun 14, 2024

UPD. We decided not to develop FunC, but to fork it and start developing a new language, named TOLK.
See ton-blockchain/ton#1345


This MR introduces FunC v0.5.0 support, a new setting "FunC language level" ("v0.4.x" and "v0.5.x" for now), as well as diagnostics/quickfixes related to language levels.

FunC v0.5.0 brief changelog

  1. Traditional comment syntax // and /* is now supported (and preferred), block comments are no longer nested
  2. All functions are impure by default. Keyword impure has become deprecated, but its antonym keyword pure is introduced
  3. Keyword method_id is deprecated, also. It was replaced as too obscure. Now there is get, written on the left: get int seqno() { ... }
  4. Pragmas compute-asm-ltr and allow-post-modification are deprecated (always on)
  5. FunC compiler auto-inlines simple function wrappers, it's a kernel for potential camelCase and stdlib renamings
  6. FunC compiler can drop unused functions from Fift output, activated by #pragma remove-unused-functions
  7. Changed priorities of operators & | ^ to more intuitive ones
  8. Built-in functions are also placed into stdlib
  9. Other minor changes and bugfixes

For detailed description, see the MR to FunC itself: ton-blockchain/ton#1026

When ton-blockchain/ton#1026 is merged, this MR will become non-draft

IDE plugins (both for JetBrains and VS Code) have to be updated to reflect new syntax and introduce a setting "FunC language level", encoupled with inspections to remove impure, replace method_id with get, etc.

What does this MR contain

  1. Added some tests for parsing. Every change in grammar is reflected in tests.
  2. Support all new syntax and keywords from v0.5.0. Changes in grammar are done in grammar.js, whereas files like parser.c are auto-generated via tree-sitter generate. WASM file is generated using yarn grammar:compile.
  3. Enriched readme, added development instructions.
  4. Moved grammar/func to tree-sitter-func folder, let's follow the suggested pattern.
  5. A setting "FunC language level" and diagnostics/quickfixes related to it, see below.

By the way, since a new stdlib contains built-in functions, VS Code plugin will no longer treat them as unknown symbols.

FunC language level

To provide better development experience for the end user, there is a new setting:

If "v0.4.x" is selected, new syntax is highlighted as errors. Of course, if a programmer actually uses a new FunC compiler (a latest blueprint version, for example), he has to specify "v0.5.x" in settings, but for old compilers, they are errors, as IDE reports.

Screen.Recording.2024-06-11.at.23.01.21.mov

If "v0.5.x" is selected, then method_id is suggested to be replaced by get, impure is suggested to be removed, and so on. It's very handy for migrating old code to a new compiler.

Screen.Recording.2024-06-11.at.23.04.12.mov

Probably, in the future, the language level for a project can be auto-detected by some heruistics. But for now, a user sets it manually.

Previously, this VS Code extension had no ability of quick fixes. I've implemented a kernel via LSP, which is related to diagnostics. These all will be also useful in the future.

Note, that grammar always parses the latest version of FunC, error highlighting is just done by diagnostics with appropriate messages.

It's supposed, that future changes in the FunC language (v0.6.x, etc.) should also be supported in a similar way.

How to review this pull request?

Chronologically, by commits. Every commit contains a completed feature with green tests.

Copy link

@wlofman021 wlofman021 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upgared

@tolk-vm tolk-vm closed this Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants