Skip to content

Conversation

@hflsmax
Copy link
Collaborator

@hflsmax hflsmax commented Aug 11, 2025

This PR adds the Lexa language.

https://github.com/lexa-lang/lexa

@hflsmax hflsmax changed the title Add Lexa Add the Lexa language Aug 11, 2025
@hflsmax hflsmax requested a review from jasigal August 11, 2025 20:50
@hflsmax hflsmax marked this pull request as ready for review August 11, 2025 20:50
@hflsmax
Copy link
Collaborator Author

hflsmax commented Aug 15, 2025

@jasigal Hi Jesse, can you review this PR?

@jasigal
Copy link
Collaborator

jasigal commented Aug 18, 2025

Will do later this week!

Copy link
Collaborator

@jasigal jasigal left a comment

Choose a reason for hiding this comment

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

Looks great, just some small changes suggested to be consistent with the other implementations, and some questions about Lexa.


def set(i) {
s[0] := i;
0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: Why does this return 0 instead of the unit value?


type generator =
| Empty
| Thunk of int * (cont <> unit -> generator)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change: The other implementations appear to store functions here instead of continuations. I think to maintain consistency the same should be done here.

def generate(f: <> [; yield_stub: Yield] () -> int): generator {
handle <> {
f:[; yield_stub]();
Empty()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Does Lexa have return clauses? It would be nice to maintain consistency if it does.

Empty()
} with yield_stub: Yield {
hdl_1 yield(x, k) {
Thunk(x, k)
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above comment about storing functions versus continuations.

match g with
| Empty -> { a }
| Thunk (v, f) -> {
sum(v + a, resume_final f (()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above comment about storing functions versus continuations.

@@ -0,0 +1,56 @@
effect Search {
pick: (int) -> int
fail: () -> int
Copy link
Collaborator

Choose a reason for hiding this comment

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

Technically the return type of fail is prescribed to be void/empty. Does Lexa have this?

parse:[;read_stub, emit_stub, stop_stub](0)
}

def sum_action [;emit_stub: Emit] (n: int): int {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you mind explaining what's going on here? Are the functions being passed by reference?

@@ -0,0 +1,50 @@
effect Choice {
flip: () -> int
fail: () -> int
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question about void/empty.

val j = choice:[; choice_stub](i - 1);
val k = choice:[; choice_stub](j - 1);
if i + j + k == s then
hash(i, j, k)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: Does Lexa have tuples? If so, hash should be moved to run to maintain consistency.


def run(n: int, s: int): int {
handle <> {
triple:[; choice_stub](n, s)
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above, hash would be here.

@hflsmax
Copy link
Collaborator Author

hflsmax commented Aug 22, 2025

Thanks Jesse, these are very useful comments! Some need modification to the Lexa compiler itself, and I'll resolve them next week.

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