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

Add lexer for Typed and Untyped Plutus Core #579

Merged
merged 4 commits into from
Dec 2, 2021

Conversation

Niols
Copy link
Contributor

@Niols Niols commented Dec 1, 2021

Good day,

This PR attempts to add a lexer for Plutus Core, both Typed- and Untyped-. Plutus Core is the language that runs on the Cardano blockchain. Although it is an intermediary language not meant to be seen by users, it does have a concrete syntax and people might want to have syntax highlighting for it sometimes. If you are curious about Plutus Core, the following blog post can serve as a (steep) introduction:

https://blog.hachi.one/post/an-introduction-to-plutus-core/

It is also built on top of Hugo and would enjoy some highlighting with Chroma! This lexer is based on the Plutus Core specification as of April 2021, as provided by the designers of the language:

https://hydra.iohk.io/build/8205579/download/1/plutus-core-specification.pdf

The two languages (Typed- and Untyped-) are extremely similar and I think it makes a lot of sense to have only one lexer for both. Do tell me if that is not the right approach and if I should split it into two lexers.

I hope such a PR is welcome. I also hope I did things properly because that is my first contact with Chroma. (By the way, I discovered it very recently and I love it; thank you very much for this nice piece of software!)

Best,
-- Nicolas “Niols” Jeannerod

@alecthomas
Copy link
Owner

Thanks for this. If you'd like to add a test, there are instructions in lexers/README.

@Niols
Copy link
Contributor Author

Niols commented Dec 2, 2021

Yes, a test sounds like a good idea! I'll take care of that and of the linter.

@Niols
Copy link
Contributor Author

Niols commented Dec 2, 2021

I now added two simple tests for both typed and untyped flavours. I also ran gofmt for consistency with the rest of the repo (and to please the linter).

When regenerating .expected files, I noticed that it made a change to bashsession.expected. Nothing substential: a character getting replaced by its escaping sequence. I did not push it here as it is not the goal of this PR, but maybe we want to do that on the main branch.

Finally, I noticed that some languages (eg. OCaml) do not have tests. Are PR welcome for that sort of things? (I wouldn't do it in this one, obviously.)

@alecthomas
Copy link
Owner

Finally, I noticed that some languages (eg. OCaml) do not have tests. Are PR welcome for that sort of things? (I wouldn't do it in this one, obviously.)

Absolutely, that would be very welcome!

@alecthomas alecthomas merged commit 06f476d into alecthomas:master Dec 2, 2021
@alecthomas
Copy link
Owner

Thanks!

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