3 ms·
I am very interested in this project as a "better awk" is something I have often fantasized about. I read all of the documentation that's available on https://
by ianthehenry 4y ago
I am very interested in this project as a "better awk" is something I have often fantasized about.
I read all of the documentation that's available on https://tokay.dev/tokay-docs/ https://tokay.dev/tokay-docs/, but unfortunately it never really... describes itself? Many sections, including the section on "parselets" are just unwritten. "Consumable" values are mentioned but never described (there is a "stub" section that doesn't really explain what the term means).
It begins with a pretty detailed description of value "severity" but doesn't really motivate why the concept exists. (I think that it's (basically) a way to very concisely discard certain matches? When there are "more important" matches around them?)
There are no examples of how I could use Tokay to "parse" something -- there are lots of examples dotted through the docs, but none of them demonstrate working with structured file formats, and they feel a little bit contrived.
I'm not complaining here: this project is not making any false claims about its status, the docs are clearly and explicitly unfinished, it is very clear that Tokay is still under active development.
But I want to learn more about it! I came away from this with a sense that it has the potential to be really useful to me, but without any concrete evidence to support that. I guess the next step is to download the source and start reading through the tests.
All this to say: please highlight some examples showcasing situations where Tokay shines! (Parsing CSVs containing quoted strings was making the rounds recently, right? What does that look like in Tokay?)
Oh, actually, the GitHub readme has an example that is more involved than any in the documentation: https://github.com/tokay-lang/tokay https://github.com/tokay-lang/tokay
_ : [ \t]+ # redefine whitespace to just tab and space
Factor : @{
Integer _ # built-in 64-bit signed integer token
'(' _ Expr ')' _
}
Term : @{
Term '*' _ Factor $1 * $4
Term '/' _ Factor $1 / $4
Factor
}
Expr : @{
Expr '+' _ Term $1 + $4
Expr '-' _ Term $1 - $4
Term
}
Expr _ print("= " + $1) # gives some neat result output
- rob74 4y agoNow you're doing it too ;) You copied the example, but didn't mention why it makes Tokay shine (it's a parser for mathematical expressions supporting the four basic operations and round brackets)
- fjfaase 4y agoI wrote an interactive/interpretting parser in JavaScript with which you can do the same. https://fransfaase.github.io/ParserWorkshop/Online_inter_parser.html#iparser https://fransfaase.github.io/ParserWorkshop/Online_inter_par... There the JavaScript is embedded in the page. I am in the process of developing a JavaScript library from this. See: https://github.com/FransFaase/MCH2022ParserWorkshop/blob/main/docs/IParse.js https://github.com/FransFaase/MCH2022ParserWorkshop/blob/mai...