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

`Self`/`self`-reference currently unclear #140

Open phorward opened 2 weeks ago

phorward commented 2 weeks ago

This issue resulted from further investigation into #127, when using the Self reference.

# Problem: XAssignment defaults to Self, which becomes __main__, but should be XAssignment<Int>
XAssignment : @<Expression, InnerAssignment: Self, ext: void> {
    # Ident _ '=' _ XAssignment  ast("assign" + ext + " " + $1)
    print(*InnerAssignment)
    Ident _ '=' _ Expect<InnerAssignment>  ast("assign" + ext + " " + $1)
    Expression  ast("value")
}

ast_print(XAssignment<Int>)

The Self-default of InnerAssignment is derived by the Self of the parselet instance in __main__, but it should refer to the constructed derive of XAssignment<Int>.