News for hackers. Stuff that matters.
Re:Which Parsing Approach? by drakmaniso on Tuesday September 15, 2020 @02:33PM (#24484922)
I believe the way it's usually done is to always parse a tuple, then parse the arrow as a binary operator applied to the two surrounding expressions. This potentially produce a syntactically incorrect AST (e.g. if there is an arrow following a tuple containing numbers), so you need to detect those in another pass and produce the corresponding error.
Re:Which Parsing Approach? by tgv on Tuesday September 15, 2020 @04:28PM (#24486342)
Can be done in one go: just check the type of the left and right operand at the end of X -> expr "=>" expr, or assign "=>" the highest priority when following a tuple, X -> tuple ("=>" "{" body "}")?.
Re:Which Parsing Approach? by hardwaregeek on Tuesday September 15, 2020 @04:32PM (#24486380)
What's subtly tricky about my language is that not all function arguments are valid expressions. For instance I allow:

   (a: int, b: float, c) => { ....
which is not a valid tuple expression. Just had to make my life harder haha