First pass has been committed as
I added 'constructor functions', so `#word16 12` is how you get a word16 instance.
Currently `Nat` is the default parsed integer, I would like to change that to Int so that we can support negative numbers, this would make it
-6 : Int
#nat 14 : nat
#word8 43 : word8
In Shimmer the literals are constructed like #nat’5, #word16’12, #int’-5 and so on. This is consistent with the naming for primitive operators like #nat’add, and using the prime means that the whole value is defined in a single lexeme. We can have multiple lexemes for the same value: eg #word8’13, #word8’0b1101, #word8’0xd would all be the same value. Out of range values like #word8’300 would be caught in the lexer.
With the space syntax like “#nat 14”, the “#nat” is an odd thing. The # in its name would indicate it’s a primitive of some sort, but it can’t be assigned a type. Detection of out of range values like #word8’300 would need to go somewhere between the lexer and the type checker, but it’s not really type checking as neither #word8 or 300 has a type by itself (?). Also consider floating point values, where #float32’-0.5 would make sense but #word8 -0.5 would not.
I’m fine with having the default number format to be #Int if that seems more useful, provided the form with the explicit type also works. The default number is #Nat now only because that was the easiest to implement at the time.