tokay-lang / tokay

Tokay is a programming language designed for ad-hoc parsing, inspired by awk.
https://tokay.dev
MIT License
236 stars 7 forks source link

Alternative keyword syntax for `parselet` and `function` definitions #108

Open phorward opened 1 year ago

phorward commented 1 year ago

In my aoc2022 wishlist, I proposed an alternative syntax to define parselets and functions in Tokay, using the keywords parselet and function.

The syntax is considered as alternative, because the grammar-style of Tokay's program files should still remain and used in first place.

The naming convention for parselet and function applies the same way as established.

parselet-keyword

# Current syntax
Statement : @<T> x = 1{
    # ...
}

# Alternative syntax
parselet Statement<T>(x = 1) {
    # ...
}

function-keyword

# Current syntax
get_index : @<x> i = 1, j = 2 {
    # ...
}

# Alternative syntax
function get_index<x>(i = 1, j = 2) {
    # ...
}