October 2022
Week of 2022-10-31
-
Revised
returnhandling so that a return statement with no expression is syntax sugar forreturn None. This enables early exits in functions that implicitly returnNoneto be cleaner:def just_return():
return -
Added support for parsing more expressions: if-else, bitwise operators, shift operators, comparisons, floor division, remainder, and matmul.
-
📢 The type of the
selfargument can now be omitted on member methods.
Week of 2022-10-24
-
Added parser support for right-associativity and unary ops, like the power operator
a ** b ** cand negation operator-a. -
Add support for
&exprin Mojo, which allows denoting a by-ref argument in functions. This is required because theselftype of a struct method is implicitly a pointer. -
Implemented support for parametric function declarations, such as:
struct SIMD[dt: DType, width: index]:
fn struct_method(self: &SIMD[dt, width]):
pass
def fancy_add[dt: DType, width: index](
lhs: SIMD[dt, width], rhs: SIMD[dt, width]) -> index:
return width
Week of 2022-10-17
-
Added explicit variable declarations with
var, for declaring variables both inside functions and structs, with support for type references. Addedindexas a temporary built-in type.def foo(lhs: index, rhs: index) -> index:
var result: index = lhs + rhs
return result -
Implemented support for parsing struct declarations and references to type declarations in functions! In
def, the type can be omitted to signal an object type.struct Foo:
var member: index
def bar(x: Foo, obj) -> index:
return x.member -
Implemented parser support for
ifstatements andwhileloops!def if_stmt(c: index, a: index, b: index) -> index:
var result: index = 0
if c:
result = a
else:
result = b
return result
def while_stmt(init: index):
while init > 1:
init = init - 1 -
Significantly improved error emission and handling, allowing the parser to emit multiple errors while parsing a file.
Week of 2022-10-10
-
Added support for parsing integer, float, and string literals.
-
Implemented parser support for function input parameters and results. You can now write parametric functions like,
def foo[param: Int](arg: Int) -> Int:
result = param + arg
return result
Week of 2022-10-03
-
Added some basic parser scaffolding and initial parser productions, including trivial expressions and assignment parser productions.
-
Implemented basic scope handling and function IR generation, with support for forward declarations. Simple functions like,
def foo(x: Int):Now parse! But all argument types are hard-coded to the MLIR
indextype. -
Added IR emission for simple arithmetic expressions on builtin types, like
x + y.