ch-systems / petr

the petr programming language -- Programmable Effects TRacking
https://playground.petr.sh
5 stars 0 forks source link

Parser "map" function which takes a list of tokens and auto-populates the `ExpectedOneOf` error, maybe with a help message #111

Open sezna opened 3 months ago

sezna commented 3 months ago

Instead of just manually calling .oneOf and branching on the list of tokens, it would be more ergonomic to have a function (pseudo signature, the types don't have to be exact)map<ParserFunc, R>(vec![(Token, ParserFunc)]) where ParserFunc: FnOnce(p: &mut Parser) -> R:

.map(vec![
  Token::Tilde => parse_function_call,
  Token::At    => parse_intrinsic
   ...etc
])

https://github.com/sezna/petr/blob/5153249faabb44a3dca98ecdaa5840ca2cf139c7/petr-parse/src/parse_to_ast.rs#L271-L275


This issue was generated by todo-issue based on a TODO comment in 5153249faabb44a3dca98ecdaa5840ca2cf139c7. It's been assigned to @sezna because they committed the code.