Skip to content

feat[venom]: add venom parser#4381

Merged
charles-cooper merged 32 commits intovyperlang:masterfrom
Philogy:master
Dec 14, 2024
Merged

feat[venom]: add venom parser#4381
charles-cooper merged 32 commits intovyperlang:masterfrom
Philogy:master

Conversation

@Philogy
Copy link
Copy Markdown
Contributor

@Philogy Philogy commented Nov 29, 2024

What I did

I added a "frontend" for venom, allowing you to compile independent venom files.

How I did it

I defined a new grammar (a bit simpler than what the readme initially suggested) & parser using the lark parser generator library.

How to verify it

Run the venom CLI against the example in the readme by putting it in a example.venom file and running venom example.venom

Commit message

this commit adds a frontend (parser) for venom. it uses the lark
library to define a grammar for venom, and constructs an `IRContext`
which can be used to emit bytecode.

the entry point to the venom compiler is `vyper/cli/venom_main.py`.

possible improvements in the future include:
- make data section optional in the grammar
- make the entry block optional in the grammar (a la llvm)
- add asm and opcodes output formats

Description for the changelog

Added independent CLI for compiling venom

Cute Animal Picture

image

@socket-security
Copy link
Copy Markdown

socket-security bot commented Nov 29, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
pypi/[email protected] eval, filesystem, unsafe 0 704 kB erez

View full report↗︎

@harkal
Copy link
Copy Markdown
Collaborator

harkal commented Nov 29, 2024

🚀

@harkal harkal changed the title feat[venom]: Add venom parser feat[venom]: add venom parser Nov 29, 2024
@Philogy
Copy link
Copy Markdown
Contributor Author

Philogy commented Nov 30, 2024

@charles-cooper btw how I would I toggle optimizations on-off for faster venom compilation?

Copy link
Copy Markdown
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

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

very slick -- much simpler than i was expecting! left a few comments

@charles-cooper
Copy link
Copy Markdown
Member

i think it would be good to have a couple test cases! e.g. in tests/functional/venom/parser/

@Philogy
Copy link
Copy Markdown
Contributor Author

Philogy commented Dec 14, 2024

@charles-cooper should be ready to merge now

Copy link
Copy Markdown
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

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

lgtm. a couple things for future scope:

  • make data section optional in the grammar
  • make entry block optional in the grammar (similarly to llvm)
  • more output formats (-f asm, opcodes, bytecode)

@charles-cooper charles-cooper enabled auto-merge (squash) December 14, 2024 18:11
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.

4 participants