kaleidoscope-hs.git
4 years agoParse more binary ops
Luke Lau [Sat, 18 May 2019 16:17:41 +0000 (17:17 +0100)]
Parse more binary ops

We can parameterise the precedence that we parse so that * is parsed
before +/- etc.
Try it out with `ghci AST.hs`, and see the difference between
*AST> read "1 * 2 - 3"
and
*AST> read "1 + 2 - 3"

4 years agoStart parsing expressions
Luke Lau [Sat, 18 May 2019 15:53:40 +0000 (16:53 +0100)]
Start parsing expressions

This starts off with defining not the AST, but just what expressions we
want to be able to parse.
So far we just handle numbers, and addition involving 2 numbers.
We use the built-in ReadPrec parser combinators, which allow us to
recursively parse the binary op of addition, and even allow us to reuse
the Read instance on Int!
prec and step are needed since without them, parseAdd will just get
stuck repeatedly trying to parse the left expression (a).

4 years agoInitial commit
Luke Lau [Sat, 18 May 2019 15:28:49 +0000 (16:28 +0100)]
Initial commit