~jojo/Carth

ref: 1637b22ca36d9cbfbd72da5f47baeafb1e11fcc3 Carth/src/Parse.hs -rw-r--r-- 12.1 KiB
Allow Box in pattern to dereference
Disallow []. Add "case" keywords to match-expression to read better
Add basic import system. Basically C-style include
Allow integer and boolean literals in patterns

Could exploit the existing Match.PCon constructor to represent not
just datatypes, but these other enumerables as well. Didn't have to
make many additions/modifications at all -- quite nice!
Fix some harmless warnings
Add `box` and `deref`

Heap allocation and pointer dereferencing. Required for recursive
datatypes like lists.
Fix codegen of strings

The type of the GlobalReference was wrong before, also we've removed
TStr in favor of a datatype built on `TPtr Nat8`.

Also, add a system for adding builtin datatypes that doesn't require
any ugly hacks with dummy-positions and stuff.
Add type `TPtr`

Useful for FFI, and will probably serve as a building block for GC /
owned pointers later.
Add primitive types Nat,{Nat,Int}{8,16,32}

Useful for FFI. No way of constructing them or casting between them
yet (except for FFI).
Add external item declarations

To test it out, change print-int from being a builtin to being an
extern function.
Add phantom param to Id to encode upper/lower case

Will be useful when instancing Arbitrary, to have separate instances
for each case.
Integrate Match with rest of compiler

Until now, the Match module was just kind of for "testing". It wasn't
actually used in the rest of the compiler. This commit replaces my
earlier, quite bad implementation of pattern matching to decision
trees with Sestofts one.

One major change made along the way was to how sub-matchees are
accessed in the code-generator and interpreter. Previously, the
decision tree was assumed to be structured such that we could simply
extract sub-matchees and put them on a stack. As far as I understand
it, that way is incompatible with Sestofts trees, as they can "skip"
steps that are known to be irrefutable in context. As such, I have
chosen to augment the `Access` type with some additional information,
such that the value of a sub-matchee can simply be generated from the
Access-path as needed, with memoization in the Selections module. See
`genSelect`.
Impl pattern matching w decision trees & check for redundancy

TODO: Check for exhaustiveness. TODO: Use the stratergy in that paper
on "good decision trees" for picking columns instead of just building
the tree left-to-right.

Sorry for the big commit. This wasn't the easiest thing to
implement. Took a while to understand how the whole thing would work,
and had lots of small problems along the way. However, I'm mostly
satistied with the result.
Impl genMatchPattern>PConstruction, genCtion
Fix re-parsing bugs in TypeErr
Improve what data about ctors&tdefs are passed from Check to Codegen

Codegen should have to do as little environment lookups and stuff as
possible, if it can be done earlier in Check and Mono. Now Check
manages to simplify what data is passed along for constructors. One
thing that is gone is the constructor name--only the index (which is
what matters) is preserved.
`printErr : ... -> IO ()` to `prettyErr : ... -> Source -> String`

Instead of reading the source file (for the second time) via IO, pass
along the source we got in Main
Mark offending section of offending line in type errors

by applying the parser at the sourcepos of the item, and counting how
long the consumed input was to get the span of the item in the source.
Put SourcePos in newtype SrcPos
Next