Work Plan - aabounegm/banana GitHub Wiki

Work on this compiler will be split into 3 stages, implementing the language incrementally so that a full compilation chain (tokenization -> parsing -> semantic analysis -> code generation) can be achieved early in the development cycle. It is planned to be worked on as follows:

Stage 1

  • VarDecl
  • VarAssign
  • Print
  • Expression (Factor, Term, Relational)
  • Type (num)

Example

var x: num
x := 5*(3 + 2) - 6/3
print(x+42)

Stage 2

  • IfStatement
  • Expression (Relation, Expression)

Example

var x: num
if 5 > 3 then
    x := 4
else
    x := 5
end

if x = 5 then
    print(42)
end

Stage 3

  • WhileLoop
  • Type (array)

Example

var arr: array 10 num
var i: num
i := 0
while i < 10 loop
    arr[i] := i
end

Stage 4

  • Functions

Example

def add (var x: num, var y: num): num do
    return x + y
end

def printArr (var arr: array 10 num) do
    var i: num
    i := 0
    while i < 10 loop
        print(arr[i])
    end
end

Stage 5

If enough time remains in the course, an attempt will be made at integrating LSP into the compiler.