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

WIP feat: new asm parser #1064

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

WIP feat: new asm parser #1064

wants to merge 3 commits into from

Conversation

novusnota
Copy link
Member

@novusnota novusnota commented Nov 21, 2024

This is another attempt at making the asm parser — now we're deliberately limiting ourselves to TVM instructions. In the current iteration it's still possible to write code in a very limited subset of Fift, but only if we won't restrict the list of supported TVM instructions in grammar.ts, i.e. during semantical actions on the lexed tokens.

TODO:

  • check that I'm going in the right direction before proceeding further (@anton-trunov)
  • grammar.ohm
  • ast.ts
  • grammar.ts
  • prettyPrinter.tswriteFunction.ts (to actually have asm instructions written)
  • hash.ts
  • compare.ts

Issue

Closes #837.
Closes #1030 (once the grammar.ts is written, there will be a small check for such gotchas).

Checklist

  • I have updated CHANGELOG.md
  • I have added tests to demonstrate the contribution is correctly implemented: this usually includes both positive and negative tests, showing the happy path(s) and featuring intentionally broken cases
  • I have run all the tests locally and no test failure was reported
  • I have run the linter, formatter and spellchecker
  • I did not do unrelated and/or undiscussed refactorings

@novusnota novusnota added this to the v1.6.0 milestone Nov 21, 2024
@anton-trunov
Copy link
Member

Let's start with concrete examples of asm-functions we would like to write and then try to develop some grammar for it. As of now, we should start with instruction sequences and comments (let's use the Tact/Fift syntax for comments).

@novusnota
Copy link
Member Author

we should start with instruction sequences and comments

i.e. no WHILE:<{ … }>DO<{ … }> loops and no similar constructs for now, right?

@anton-trunov
Copy link
Member

i.e. no WHILE:<{ … }>DO<{ … }> loops and no similar constructs for now, right?

definitely not using this syntax :)

@anton-trunov
Copy link
Member

we might allow asm-blocks to avoid introducing high-level constructions into the assembly language, so the user might able to insert those into loops, etc.

@novusnota
Copy link
Member Author

novusnota commented Nov 21, 2024

Hmm, then, something like this we've showed earlier (and have in our tests) won't work anymore:

asm fun isIntAnInt(x: Int): Bool {
    <{
        TRY:<{
            0 PUSHINT ADD DROP -1 PUSHINT
        }>CATCH<{
            2DROP 0 PUSHINT
        }>
    }>CONT 1 1 CALLXARGS
}

Proceed with removing that? This kinda goes against POLA.

UPD: Edited the original post, saying that the full range of Fift+TVM syntax there was highly experimental and subject to change in next releases. Ok, now we can proceed.

@anton-trunov
Copy link
Member

we haven't documented it, so there is no backwards compatibility violation

@anton-trunov
Copy link
Member

and Tact Kitchen posts are about raw immature things, sneak peek

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.

Malformed asm functions pass Tact compiler but fail during FunC compilation stage asm-blocks parser
2 participants