Developer Tutorial
This is a tutorial for anybody who wants to either develop LFortran or build tools on top.
Introduction
LFortran is structured around two independent modules, AST and ASR, both of which are standalone (completely independent of the rest of LFortran) and users are encouraged to use them independently for other applications and build tools on top:

Abstract Syntax Tree (AST): Represents any Fortran source code, strictly based on syntax, no semantic is included. The AST module can convert itself to Fortran source code.

Abstract Semantic Representation (ASR): Represents a valid Fortran source code, all semantic is included. Invalid Fortran code is not allowed (an error will be given). The ASR module can convert itself to an AST.
Abstract Syntax Tree (AST)
Fortran source code can be parsed into an AST using the src_to_ast()
function:
integer function f(a, b) result(r)
integer, intent(in) :: a, b
r = a + b
end function
We can pretty print it using the %%showast
magic:
%%showast
integer function f(a, b) result(r)
integer, intent(in) :: a, b
r = a + b
end function
We can convert AST to Fortran source code using %%showfmt
:
%%showfmt
integer function f(a, b) result(r)
integer, intent(in) :: a, b
r = a + b
end function
All AST nodes and their arguments are described in AST.asdl.
Abstract Semantic Representation (ASR)
We can pretty print using the %%showasr
magic:
%%showasr
integer function f(a, b) result(r)
integer, intent(in) :: a, b
r = a + b
end function
All ASR nodes and their arguments are described in ASR.asdl.