3 ms·
Interestingly enough, I've been playing around with parsing the same thing lately, albeit in Python with a simple recursive descent parser (with exceptions for
by TheLoneWolfling 11y ago
Interestingly enough, I've been playing around with parsing the same thing lately, albeit in Python with a simple recursive descent parser (with exceptions for control flow, which actually works surprisingly well.)
A lot of the same ideas. And indeed, much of the parser is pretty close to the same:
def parseAbst(self):
self.expect('λ')
varName = self.expect(self.parseVar)
self.pushVar(varName)
self.expect('.')
exprTree = self.expect(self.parseExpr)
return abst(varName, exprTree)
(I also have self.accept, etc.)
(Of course, much of the complexity is hosted to the class surrounding this)