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

feat[venom]: add venom parser #4381

Merged
merged 32 commits into from
Dec 14, 2024
Merged

feat[venom]: add venom parser #4381

merged 32 commits into from
Dec 14, 2024

Conversation

Philogy
Copy link
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

Copy link

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/lark@1.2.2 eval, filesystem, unsafe 0 704 kB erez

View full report↗︎

@harkal
Copy link
Collaborator

harkal commented Nov 29, 2024

🚀

@harkal harkal changed the title feat[venom]: Add venom parser feat[venom]: add venom parser Nov 29, 2024
vyper/venom/parser.py Fixed Show fixed Hide fixed
@Philogy
Copy link
Contributor Author

Philogy commented Nov 30, 2024

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

Copy link
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
Member

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

@Philogy
Copy link
Contributor Author

Philogy commented Dec 14, 2024

@charles-cooper should be ready to merge now

Copy link
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
@charles-cooper charles-cooper merged commit 537313b into vyperlang:master Dec 14, 2024
156 checks passed
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.

3 participants