tact-lang / tact-vscode

Tact VS Code plugin
Apache License 2.0
22 stars 9 forks source link

feat: support of Tact 1.5.2 #45

Closed novusnota closed 1 month ago

novusnota commented 1 month ago

Wanted to help out a little, please review whenever you find convenient

Changes

  1. Added a lot of completions for all new functions, methods, extension functions, etc.
  2. Added the updated TextMate grammar for syntax highlighting*
  3. Added support for the asm functions in the parser

Notes

  1. pegjs used in the project can be seamlessly replaced by its maintained version — peggyjs (repo). There are only three small steps for migration: https://github.com/peggyjs/peggy#migrating-from-pegjs

  2. The current parser seems to be a tangled amalgamation of JavaScript, FunC and Tact parsers, none of which is complete nor correct. JavaScript made the biggest influence with its ASI, import...from statements, and other weird leftovers. Very tough to do anything productive with from the outside standpoint, just my 2 cents :heart: :)

  3. I hope I didn't butcher the formatting and did things there right. Please, double-check and/or correct :pray:

Closes #44

logvik commented 1 month ago

Can you add here some sample for the smart contract code that can be used to test the new features on the parser side? To test the new changes quickly we can use https://peggyjs.org/online.html

novusnota commented 1 month ago

@logvik thanks for the suggestion! I've refined the parser and checked that it works as intended on https://peggyjs.org/online.html. Also added a samples/ folder (and adjusted .vscodeignore) and placed the first sample with asm functions there. They were taken from the tests of grammar.ohm in Tact compiler repo.

Tact code to test on https://peggyjs.org/online.html ```tact asm fun keccak256(s: Slice): Int { 1 INT HASHEXT_KECCAK256 } asm( -> 1 0) extends fun loadCoins(self: Slice): Int { LDVARUINT16 } asm(c b) extends fun storeDict(b: Builder, c: Cell) { STDICT } asm(s len -> 1 0) extends fun loadInt(self: Slice, len: Int): Int { LDIX } asm fun checkAndRemoveAddExtensionPrefix(self: Slice): Int { x{02} SDBEGINSQ } asm fun checkAndRemoveAddExtensionPrefix() { -ROT } asm fun debugStr1() { "Works!" DEBUGSTR } asm fun debugStr2() { "Works!" } asm fun createWord() { { INC } } /// Tests list and binding to a new regular word asm fun createAndUseWord1(): Int { { INC } : incinc 41 incinc } /// Tests weird formatting asm fun createAndUseWord2(): Int { { INC } : incinc 41 incinc } /// Tests weird formatting asm fun createAndUseWord3(): Int { { INC } : incinc 41 incinc } /// Tests words with } inside of them asm fun isIntAnInt(x: Int): Int { <{ TRY:<{ 0 PUSHINT ADD DROP -1 PUSHINT }>CATCH<{ 2DROP 0 PUSHINT }> }>CONT 1 1 CALLXARGS } ```

image

logvik commented 1 month ago

LGTM! @logvik could you please leave your feedback? We would like to move on with Tact v1.5 support

I will update the extension on the marketplace this evening. Let's publish this PR and then I will add more, just don't have a time right now to test my own additional changes careful.

anton-trunov commented 1 month ago

Awesome! Thanks a bunch

logvik commented 1 month ago
2024-10-08 09_46_01- Extension Development Host  ● asm tact - locker-contracts (Workspace) - Visual

This code is from samples/items-asm-func.tact

I think we should fix this before publishing on the marketplace.

novusnota commented 1 month ago

@logvik that file was to test parsers only (pegjs here and Ohm in Tact compiler) and it wasn't really valid from semantical point of view. Only syntax there mattered :)

Also, to fix this exact snippet, try removing the first 1

logvik commented 1 month ago

It didn't help, but I have published because that error was related to the compiler warning, as you have been mentioned above.