Difference between an AST and ASR¶
Let us take a simple Fortran code:
integer function f(a, b) result(r)
integer, intent(in) :: a, b
integer :: c, d
c = a + b - d
r = c * a
end function
and look at what the AST and ASR look like.
AST¶
[1]:
%%showast
integer function f(a, b) result(r)
integer, intent(in) :: a, b
integer :: c, d
c = a + b - d
r = c * a
end function
(TranslationUnit
[(Function
f
[(a)
(b)]
[(AttrType
TypeInteger
[]
()
()
None
)]
r
()
()
[]
[]
[]
[(Declaration
(AttrType
TypeInteger
[]
()
()
None
)
[(AttrIntent
In
)]
[(a
[]
[]
()
()
None
())
(b
[]
[]
()
()
None
())]
()
)
(Declaration
(AttrType
TypeInteger
[]
()
()
None
)
[]
[(c
[]
[]
()
()
None
())
(d
[]
[]
()
()
None
())]
()
)]
[(Assignment
0
c
(- (+ a b) d)
()
)
(Assignment
0
r
(* c a)
()
)]
[]
[]
)]
)
The AST does not have any semantic information, but has nodes to represent declarations such as integer, intent(in) :: a. Variables such as a are represented by a Name node, and are not connected to their declarations yet.
The AST can also be exported in JSON, including source file name, line and column information: lfortran example.f90 --show-ast --json
ASR¶
[2]:
%%showasr
integer function f(a, b) result(r)
integer, intent(in) :: a, b
integer :: c, d
c = a + b - d
r = c * a
end function
(TranslationUnit
(SymbolTable
1
{
_lcompilers_len_trim_str:
(Function
(SymbolTable
18
{
result:
(Variable
18
result
[]
ReturnVar
()
()
Default
(Integer 4)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
18
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_len_trim_str
(FunctionType
[(String 1 () AssumedLength DescriptorString)]
(Integer 4)
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[]
[(Var 18 str)]
[(Assignment
(Var 18 result)
(Cast
(StringLen
(Var 18 str)
(Integer 4)
()
)
IntegerToInteger
(Integer 4)
()
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 18 result)
NotEq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(WhileLoop
()
(StringCompare
(StringItem
(Var 18 str)
(Var 18 result)
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
()
)
Eq
(StringConstant
" "
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
)
(Logical 4)
()
)
[(Assignment
(Var 18 result)
(IntegerBinOp
(Var 18 result)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 18 result)
Eq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(Exit
()
)]
[]
)]
[]
)]
[]
)]
(Var 18 result)
Public
.false.
.false.
()
),
_lcompilers_len_trim_str1:
(Function
(SymbolTable
20
{
result:
(Variable
20
result
[]
ReturnVar
()
()
Default
(Integer 4)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
20
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_len_trim_str1
(FunctionType
[(String 1 () AssumedLength DescriptorString)]
(Integer 4)
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[]
[(Var 20 str)]
[(Assignment
(Var 20 result)
(Cast
(StringLen
(Var 20 str)
(Integer 4)
()
)
IntegerToInteger
(Integer 4)
()
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 20 result)
NotEq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(WhileLoop
()
(StringCompare
(StringItem
(Var 20 str)
(Var 20 result)
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
()
)
Eq
(StringConstant
" "
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
)
(Logical 4)
()
)
[(Assignment
(Var 20 result)
(IntegerBinOp
(Var 20 result)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 20 result)
Eq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(Exit
()
)]
[]
)]
[]
)]
[]
)]
(Var 20 result)
Public
.false.
.false.
()
),
_lcompilers_len_trim_str2:
(Function
(SymbolTable
22
{
result:
(Variable
22
result
[]
ReturnVar
()
()
Default
(Integer 4)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
22
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_len_trim_str2
(FunctionType
[(String 1 () AssumedLength DescriptorString)]
(Integer 4)
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[]
[(Var 22 str)]
[(Assignment
(Var 22 result)
(Cast
(StringLen
(Var 22 str)
(Integer 4)
()
)
IntegerToInteger
(Integer 4)
()
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 22 result)
NotEq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(WhileLoop
()
(StringCompare
(StringItem
(Var 22 str)
(Var 22 result)
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
()
)
Eq
(StringConstant
" "
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
)
(Logical 4)
()
)
[(Assignment
(Var 22 result)
(IntegerBinOp
(Var 22 result)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 22 result)
Eq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(Exit
()
)]
[]
)]
[]
)]
[]
)]
(Var 22 result)
Public
.false.
.false.
()
),
_lcompilers_len_trim_str3:
(Function
(SymbolTable
24
{
result:
(Variable
24
result
[]
ReturnVar
()
()
Default
(Integer 4)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
24
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_len_trim_str3
(FunctionType
[(String 1 () AssumedLength DescriptorString)]
(Integer 4)
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[]
[(Var 24 str)]
[(Assignment
(Var 24 result)
(Cast
(StringLen
(Var 24 str)
(Integer 4)
()
)
IntegerToInteger
(Integer 4)
()
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 24 result)
NotEq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(WhileLoop
()
(StringCompare
(StringItem
(Var 24 str)
(Var 24 result)
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
()
)
Eq
(StringConstant
" "
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
)
(Logical 4)
()
)
[(Assignment
(Var 24 result)
(IntegerBinOp
(Var 24 result)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 24 result)
Eq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(Exit
()
)]
[]
)]
[]
)]
[]
)]
(Var 24 result)
Public
.false.
.false.
()
),
_lcompilers_len_trim_str4:
(Function
(SymbolTable
28
{
result:
(Variable
28
result
[]
ReturnVar
()
()
Default
(Integer 4)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
28
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_len_trim_str4
(FunctionType
[(String 1 () AssumedLength DescriptorString)]
(Integer 4)
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[]
[(Var 28 str)]
[(Assignment
(Var 28 result)
(Cast
(StringLen
(Var 28 str)
(Integer 4)
()
)
IntegerToInteger
(Integer 4)
()
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 28 result)
NotEq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(WhileLoop
()
(StringCompare
(StringItem
(Var 28 str)
(Var 28 result)
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
()
)
Eq
(StringConstant
" "
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
)
(Logical 4)
()
)
[(Assignment
(Var 28 result)
(IntegerBinOp
(Var 28 result)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 28 result)
Eq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(Exit
()
)]
[]
)]
[]
)]
[]
)]
(Var 28 result)
Public
.false.
.false.
()
),
_lcompilers_len_trim_str5:
(Function
(SymbolTable
30
{
result:
(Variable
30
result
[]
ReturnVar
()
()
Default
(Integer 4)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
30
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_len_trim_str5
(FunctionType
[(String 1 () AssumedLength DescriptorString)]
(Integer 4)
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[]
[(Var 30 str)]
[(Assignment
(Var 30 result)
(Cast
(StringLen
(Var 30 str)
(Integer 4)
()
)
IntegerToInteger
(Integer 4)
()
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 30 result)
NotEq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(WhileLoop
()
(StringCompare
(StringItem
(Var 30 str)
(Var 30 result)
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
()
)
Eq
(StringConstant
" "
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
)
(Logical 4)
()
)
[(Assignment
(Var 30 result)
(IntegerBinOp
(Var 30 result)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 30 result)
Eq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(Exit
()
)]
[]
)]
[]
)]
[]
)]
(Var 30 result)
Public
.false.
.false.
()
),
_lcompilers_len_trim_str6:
(Function
(SymbolTable
32
{
result:
(Variable
32
result
[]
ReturnVar
()
()
Default
(Integer 4)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
32
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_len_trim_str6
(FunctionType
[(String 1 () AssumedLength DescriptorString)]
(Integer 4)
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[]
[(Var 32 str)]
[(Assignment
(Var 32 result)
(Cast
(StringLen
(Var 32 str)
(Integer 4)
()
)
IntegerToInteger
(Integer 4)
()
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 32 result)
NotEq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(WhileLoop
()
(StringCompare
(StringItem
(Var 32 str)
(Var 32 result)
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
()
)
Eq
(StringConstant
" "
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
)
(Logical 4)
()
)
[(Assignment
(Var 32 result)
(IntegerBinOp
(Var 32 result)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 32 result)
Eq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(Exit
()
)]
[]
)]
[]
)]
[]
)]
(Var 32 result)
Public
.false.
.false.
()
),
_lcompilers_len_trim_str7:
(Function
(SymbolTable
34
{
result:
(Variable
34
result
[]
ReturnVar
()
()
Default
(Integer 4)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
34
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_len_trim_str7
(FunctionType
[(String 1 () AssumedLength DescriptorString)]
(Integer 4)
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[]
[(Var 34 str)]
[(Assignment
(Var 34 result)
(Cast
(StringLen
(Var 34 str)
(Integer 4)
()
)
IntegerToInteger
(Integer 4)
()
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 34 result)
NotEq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(WhileLoop
()
(StringCompare
(StringItem
(Var 34 str)
(Var 34 result)
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
()
)
Eq
(StringConstant
" "
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
)
(Logical 4)
()
)
[(Assignment
(Var 34 result)
(IntegerBinOp
(Var 34 result)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
()
.false.
.false.
)
(If
()
(IntegerCompare
(Var 34 result)
Eq
(IntegerConstant 0 (Integer 4) Decimal)
(Logical 4)
()
)
[(Exit
()
)]
[]
)]
[]
)]
[]
)]
(Var 34 result)
Public
.false.
.false.
()
),
_lcompilers_stringconcat:
(Function
(SymbolTable
15
{
concat_result:
(Variable
15
concat_result
[]
Out
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
s1:
(Variable
15
s1
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
s1_len:
(Variable
15
s1_len
[]
In
()
()
Default
(Integer 4)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
s2:
(Variable
15
s2
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
s2_len:
(Variable
15
s2_len
[]
In
()
()
Default
(Integer 4)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_stringconcat
(FunctionType
[(String 1 () AssumedLength DescriptorString)
(String 1 () AssumedLength DescriptorString)
(Integer 4)
(Integer 4)
(Allocatable
(String 1 () DeferredLength DescriptorString)
)]
()
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[]
[(Var 15 s1)
(Var 15 s2)
(Var 15 s1_len)
(Var 15 s2_len)
(Var 15 concat_result)]
[(Allocate
[((Var 15 concat_result)
[]
(IntegerBinOp
(Var 15 s1_len)
Add
(Var 15 s2_len)
(Integer 4)
()
)
()
())]
()
()
()
)
(Assignment
(StringSection
(Var 15 concat_result)
(IntegerConstant 1 (Integer 4) Decimal)
(Var 15 s1_len)
(IntegerConstant 1 (Integer 4) Decimal)
(String 1 (IntegerBinOp
(IntegerBinOp
(Var 15 s1_len)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
Add
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
) ExpressionLength DescriptorString)
()
)
(Var 15 s1)
()
.false.
.false.
)
(Assignment
(StringSection
(Var 15 concat_result)
(IntegerBinOp
(Var 15 s1_len)
Add
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
(StringLen
(Var 15 concat_result)
(Integer 4)
()
)
(IntegerConstant 1 (Integer 4) Decimal)
(String 1 (IntegerBinOp
(IntegerBinOp
(StringLen
(Var 15 concat_result)
(Integer 4)
()
)
Sub
(IntegerBinOp
(Var 15 s1_len)
Add
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
(Integer 4)
()
)
Add
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
) ExpressionLength DescriptorString)
()
)
(Var 15 s2)
()
.false.
.false.
)]
()
Public
.false.
.false.
()
),
_lcompilers_trim_str:
(Function
(SymbolTable
17
{
result:
(Variable
17
result
[_lcompilers_len_trim_str
str]
Out
()
()
Default
(String 1 (FunctionCall
1 _lcompilers_len_trim_str
1 _lcompilers_len_trim_str
[((Var 17 str))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
17
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_trim_str
(FunctionType
[(String 1 () AssumedLength DescriptorString)
(String 1 (FunctionCall
1 _lcompilers_len_trim_str
1 _lcompilers_len_trim_str
[((FunctionParam
0
(String 1 () AssumedLength DescriptorString)
()
))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)]
()
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[_lcompilers_len_trim_str]
[(Var 17 str)
(Var 17 result)]
[(Assignment
(Var 17 result)
(StringSection
(Var 17 str)
(IntegerConstant 1 (Integer 4) Decimal)
(FunctionCall
1 _lcompilers_len_trim_str
1 _lcompilers_len_trim_str
[((Var 17 str))]
(Integer 4)
()
()
)
(IntegerConstant 1 (Integer 4) Decimal)
(String 1 (IntegerBinOp
(IntegerBinOp
(FunctionCall
1 _lcompilers_len_trim_str
1 _lcompilers_len_trim_str
[((Var 17 str))]
(Integer 4)
()
()
)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
Add
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
) ExpressionLength DescriptorString)
()
)
()
.false.
.false.
)]
()
Public
.false.
.false.
()
),
_lcompilers_trim_str1:
(Function
(SymbolTable
19
{
result:
(Variable
19
result
[_lcompilers_len_trim_str1
str]
Out
()
()
Default
(String 1 (FunctionCall
1 _lcompilers_len_trim_str1
1 _lcompilers_len_trim_str1
[((Var 19 str))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
19
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_trim_str1
(FunctionType
[(String 1 () AssumedLength DescriptorString)
(String 1 (FunctionCall
1 _lcompilers_len_trim_str1
1 _lcompilers_len_trim_str1
[((FunctionParam
0
(String 1 () AssumedLength DescriptorString)
()
))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)]
()
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[_lcompilers_len_trim_str1]
[(Var 19 str)
(Var 19 result)]
[(Assignment
(Var 19 result)
(StringSection
(Var 19 str)
(IntegerConstant 1 (Integer 4) Decimal)
(FunctionCall
1 _lcompilers_len_trim_str1
1 _lcompilers_len_trim_str1
[((Var 19 str))]
(Integer 4)
()
()
)
(IntegerConstant 1 (Integer 4) Decimal)
(String 1 (IntegerBinOp
(IntegerBinOp
(FunctionCall
1 _lcompilers_len_trim_str1
1 _lcompilers_len_trim_str1
[((Var 19 str))]
(Integer 4)
()
()
)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
Add
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
) ExpressionLength DescriptorString)
()
)
()
.false.
.false.
)]
()
Public
.false.
.false.
()
),
_lcompilers_trim_str2:
(Function
(SymbolTable
21
{
result:
(Variable
21
result
[_lcompilers_len_trim_str2
str]
Out
()
()
Default
(String 1 (FunctionCall
1 _lcompilers_len_trim_str2
1 _lcompilers_len_trim_str2
[((Var 21 str))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
21
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_trim_str2
(FunctionType
[(String 1 () AssumedLength DescriptorString)
(String 1 (FunctionCall
1 _lcompilers_len_trim_str2
1 _lcompilers_len_trim_str2
[((FunctionParam
0
(String 1 () AssumedLength DescriptorString)
()
))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)]
()
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[_lcompilers_len_trim_str2]
[(Var 21 str)
(Var 21 result)]
[(Assignment
(Var 21 result)
(StringSection
(Var 21 str)
(IntegerConstant 1 (Integer 4) Decimal)
(FunctionCall
1 _lcompilers_len_trim_str2
1 _lcompilers_len_trim_str2
[((Var 21 str))]
(Integer 4)
()
()
)
(IntegerConstant 1 (Integer 4) Decimal)
(String 1 (IntegerBinOp
(IntegerBinOp
(FunctionCall
1 _lcompilers_len_trim_str2
1 _lcompilers_len_trim_str2
[((Var 21 str))]
(Integer 4)
()
()
)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
Add
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
) ExpressionLength DescriptorString)
()
)
()
.false.
.false.
)]
()
Public
.false.
.false.
()
),
_lcompilers_trim_str3:
(Function
(SymbolTable
23
{
result:
(Variable
23
result
[_lcompilers_len_trim_str3
str]
Out
()
()
Default
(String 1 (FunctionCall
1 _lcompilers_len_trim_str3
1 _lcompilers_len_trim_str3
[((Var 23 str))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
23
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_trim_str3
(FunctionType
[(String 1 () AssumedLength DescriptorString)
(String 1 (FunctionCall
1 _lcompilers_len_trim_str3
1 _lcompilers_len_trim_str3
[((FunctionParam
0
(String 1 () AssumedLength DescriptorString)
()
))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)]
()
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[_lcompilers_len_trim_str3]
[(Var 23 str)
(Var 23 result)]
[(Assignment
(Var 23 result)
(StringSection
(Var 23 str)
(IntegerConstant 1 (Integer 4) Decimal)
(FunctionCall
1 _lcompilers_len_trim_str3
1 _lcompilers_len_trim_str3
[((Var 23 str))]
(Integer 4)
()
()
)
(IntegerConstant 1 (Integer 4) Decimal)
(String 1 (IntegerBinOp
(IntegerBinOp
(FunctionCall
1 _lcompilers_len_trim_str3
1 _lcompilers_len_trim_str3
[((Var 23 str))]
(Integer 4)
()
()
)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
Add
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
) ExpressionLength DescriptorString)
()
)
()
.false.
.false.
)]
()
Public
.false.
.false.
()
),
_lcompilers_trim_str4:
(Function
(SymbolTable
27
{
result:
(Variable
27
result
[_lcompilers_len_trim_str4
str]
Out
()
()
Default
(String 1 (FunctionCall
1 _lcompilers_len_trim_str4
1 _lcompilers_len_trim_str4
[((Var 27 str))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
27
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_trim_str4
(FunctionType
[(String 1 () AssumedLength DescriptorString)
(String 1 (FunctionCall
1 _lcompilers_len_trim_str4
1 _lcompilers_len_trim_str4
[((FunctionParam
0
(String 1 () AssumedLength DescriptorString)
()
))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)]
()
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[_lcompilers_len_trim_str4]
[(Var 27 str)
(Var 27 result)]
[(Assignment
(Var 27 result)
(StringSection
(Var 27 str)
(IntegerConstant 1 (Integer 4) Decimal)
(FunctionCall
1 _lcompilers_len_trim_str4
1 _lcompilers_len_trim_str4
[((Var 27 str))]
(Integer 4)
()
()
)
(IntegerConstant 1 (Integer 4) Decimal)
(String 1 (IntegerBinOp
(IntegerBinOp
(FunctionCall
1 _lcompilers_len_trim_str4
1 _lcompilers_len_trim_str4
[((Var 27 str))]
(Integer 4)
()
()
)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
Add
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
) ExpressionLength DescriptorString)
()
)
()
.false.
.false.
)]
()
Public
.false.
.false.
()
),
_lcompilers_trim_str5:
(Function
(SymbolTable
29
{
result:
(Variable
29
result
[_lcompilers_len_trim_str5
str]
Out
()
()
Default
(String 1 (FunctionCall
1 _lcompilers_len_trim_str5
1 _lcompilers_len_trim_str5
[((Var 29 str))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
29
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_trim_str5
(FunctionType
[(String 1 () AssumedLength DescriptorString)
(String 1 (FunctionCall
1 _lcompilers_len_trim_str5
1 _lcompilers_len_trim_str5
[((FunctionParam
0
(String 1 () AssumedLength DescriptorString)
()
))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)]
()
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[_lcompilers_len_trim_str5]
[(Var 29 str)
(Var 29 result)]
[(Assignment
(Var 29 result)
(StringSection
(Var 29 str)
(IntegerConstant 1 (Integer 4) Decimal)
(FunctionCall
1 _lcompilers_len_trim_str5
1 _lcompilers_len_trim_str5
[((Var 29 str))]
(Integer 4)
()
()
)
(IntegerConstant 1 (Integer 4) Decimal)
(String 1 (IntegerBinOp
(IntegerBinOp
(FunctionCall
1 _lcompilers_len_trim_str5
1 _lcompilers_len_trim_str5
[((Var 29 str))]
(Integer 4)
()
()
)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
Add
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
) ExpressionLength DescriptorString)
()
)
()
.false.
.false.
)]
()
Public
.false.
.false.
()
),
_lcompilers_trim_str6:
(Function
(SymbolTable
31
{
result:
(Variable
31
result
[_lcompilers_len_trim_str6
str]
Out
()
()
Default
(String 1 (FunctionCall
1 _lcompilers_len_trim_str6
1 _lcompilers_len_trim_str6
[((Var 31 str))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
31
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_trim_str6
(FunctionType
[(String 1 () AssumedLength DescriptorString)
(String 1 (FunctionCall
1 _lcompilers_len_trim_str6
1 _lcompilers_len_trim_str6
[((FunctionParam
0
(String 1 () AssumedLength DescriptorString)
()
))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)]
()
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[_lcompilers_len_trim_str6]
[(Var 31 str)
(Var 31 result)]
[(Assignment
(Var 31 result)
(StringSection
(Var 31 str)
(IntegerConstant 1 (Integer 4) Decimal)
(FunctionCall
1 _lcompilers_len_trim_str6
1 _lcompilers_len_trim_str6
[((Var 31 str))]
(Integer 4)
()
()
)
(IntegerConstant 1 (Integer 4) Decimal)
(String 1 (IntegerBinOp
(IntegerBinOp
(FunctionCall
1 _lcompilers_len_trim_str6
1 _lcompilers_len_trim_str6
[((Var 31 str))]
(Integer 4)
()
()
)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
Add
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
) ExpressionLength DescriptorString)
()
)
()
.false.
.false.
)]
()
Public
.false.
.false.
()
),
_lcompilers_trim_str7:
(Function
(SymbolTable
33
{
result:
(Variable
33
result
[_lcompilers_len_trim_str7
str]
Out
()
()
Default
(String 1 (FunctionCall
1 _lcompilers_len_trim_str7
1 _lcompilers_len_trim_str7
[((Var 33 str))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
str:
(Variable
33
str
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
_lcompilers_trim_str7
(FunctionType
[(String 1 () AssumedLength DescriptorString)
(String 1 (FunctionCall
1 _lcompilers_len_trim_str7
1 _lcompilers_len_trim_str7
[((FunctionParam
0
(String 1 () AssumedLength DescriptorString)
()
))]
(Integer 4)
()
()
) ExpressionLength DescriptorString)]
()
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[_lcompilers_len_trim_str7]
[(Var 33 str)
(Var 33 result)]
[(Assignment
(Var 33 result)
(StringSection
(Var 33 str)
(IntegerConstant 1 (Integer 4) Decimal)
(FunctionCall
1 _lcompilers_len_trim_str7
1 _lcompilers_len_trim_str7
[((Var 33 str))]
(Integer 4)
()
()
)
(IntegerConstant 1 (Integer 4) Decimal)
(String 1 (IntegerBinOp
(IntegerBinOp
(FunctionCall
1 _lcompilers_len_trim_str7
1 _lcompilers_len_trim_str7
[((Var 33 str))]
(Integer 4)
()
()
)
Sub
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
)
Add
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
) ExpressionLength DescriptorString)
()
)
()
.false.
.false.
)]
()
Public
.false.
.false.
()
),
f:
(Function
(SymbolTable
35
{
a:
(Variable
35
a
[]
In
()
()
Default
(Integer 4)
()
Source
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
b:
(Variable
35
b
[]
In
()
()
Default
(Integer 4)
()
Source
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
c:
(Variable
35
c
[]
Local
()
()
Default
(Integer 4)
()
Source
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
d:
(Variable
35
d
[]
Local
()
()
Default
(Integer 4)
()
Source
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
r:
(Variable
35
r
[]
ReturnVar
()
()
Default
(Integer 4)
()
Source
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
f
(FunctionType
[(Integer 4)
(Integer 4)]
(Integer 4)
Source
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[]
[(Var 35 a)
(Var 35 b)]
[(Assignment
(Var 35 c)
(IntegerBinOp
(IntegerBinOp
(Var 35 a)
Add
(Var 35 b)
(Integer 4)
()
)
Sub
(Var 35 d)
(Integer 4)
()
)
()
.false.
.false.
)
(Assignment
(Var 35 r)
(IntegerBinOp
(Var 35 c)
Mul
(Var 35 a)
(Integer 4)
()
)
()
.false.
.false.
)]
(Var 35 r)
Public
.true.
.true.
()
),
iso_c_binding:
(IntrinsicModule lfortran_intrinsic_iso_c_binding),
lfortran_display:
(Module
(SymbolTable
2
{
c_char:
(ExternalSymbol
2
c_char
4 c_char
lfortran_intrinsic_iso_c_binding
[]
c_char
Public
),
c_null_char:
(ExternalSymbol
2
c_null_char
4 c_null_char
lfortran_intrinsic_iso_c_binding
[]
c_null_char
Public
),
display_data:
(Function
(SymbolTable
14
{
__libasr__created__var__0_return_slot:
(Variable
14
__libasr__created__var__0_return_slot
[]
Local
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
__libasr__created__var__10_return_slot:
(Variable
14
__libasr__created__var__10_return_slot
[]
Local
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
__libasr__created__var__11_return_slot:
(Variable
14
__libasr__created__var__11_return_slot
[]
Local
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
__libasr__created__var__1_return_slot:
(Variable
14
__libasr__created__var__1_return_slot
[]
Local
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
__libasr__created__var__2_return_slot:
(Variable
14
__libasr__created__var__2_return_slot
[]
Local
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
__libasr__created__var__3_return_slot:
(Variable
14
__libasr__created__var__3_return_slot
[]
Local
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
__libasr__created__var__4_return_slot:
(Variable
14
__libasr__created__var__4_return_slot
[]
Local
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
__libasr__created__var__5_return_slot:
(Variable
14
__libasr__created__var__5_return_slot
[]
Local
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
__libasr__created__var__6_return_slot:
(Variable
14
__libasr__created__var__6_return_slot
[]
Local
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
__libasr__created__var__7_return_slot:
(Variable
14
__libasr__created__var__7_return_slot
[]
Local
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
__libasr__created__var__8_return_slot:
(Variable
14
__libasr__created__var__8_return_slot
[]
Local
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
__libasr__created__var__9_return_slot:
(Variable
14
__libasr__created__var__9_return_slot
[]
Local
()
()
Default
(Allocatable
(String 1 () DeferredLength DescriptorString)
)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
data:
(Variable
14
data
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
mime_type:
(Variable
14
mime_type
[]
In
()
()
Default
(String 1 () AssumedLength DescriptorString)
()
ExternalUndefined
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
display_data
(FunctionType
[(String 1 () AssumedLength DescriptorString)
(String 1 () AssumedLength DescriptorString)]
()
ExternalUndefined
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[_lcompilers_len_trim_str
_lcompilers_trim_str
_lcompilers_len_trim_str1
_lcompilers_trim_str1
_lcompilers_stringconcat
_lcompilers_len_trim_str2
_lcompilers_trim_str2
_lcompilers_len_trim_str3
_lcompilers_trim_str3
_lcompilers_len_trim_str4
_lcompilers_trim_str4
_lcompilers_len_trim_str5
_lcompilers_trim_str5
_lcompilers_len_trim_str6
_lcompilers_trim_str6
_lcompilers_len_trim_str7
_lcompilers_trim_str7
lf_display_data]
[(Var 14 mime_type)
(Var 14 data)]
[(ExplicitDeallocate
[(Var 14 __libasr__created__var__0_return_slot)]
)
(Allocate
[((Var 14 __libasr__created__var__0_return_slot)
[]
(FunctionCall
1 _lcompilers_len_trim_str
1 _lcompilers_len_trim_str
[((Var 14 mime_type))]
(Integer 4)
()
()
)
()
())]
()
()
()
)
(SubroutineCall
1 _lcompilers_trim_str
()
[((Var 14 mime_type))
((Var 14 __libasr__created__var__0_return_slot))]
()
.true.
)
(ExplicitDeallocate
[(Var 14 __libasr__created__var__1_return_slot)]
)
(Allocate
[((Var 14 __libasr__created__var__1_return_slot)
[]
(FunctionCall
1 _lcompilers_len_trim_str1
1 _lcompilers_len_trim_str1
[((Var 14 mime_type))]
(Integer 4)
()
()
)
()
())]
()
()
()
)
(SubroutineCall
1 _lcompilers_trim_str1
()
[((Var 14 mime_type))
((Var 14 __libasr__created__var__1_return_slot))]
()
.true.
)
(ExplicitDeallocate
[(Var 14 __libasr__created__var__2_return_slot)]
)
(SubroutineCall
1 _lcompilers_stringconcat
()
[((Var 14 __libasr__created__var__0_return_slot))
((StringConstant
""
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
))
((StringLen
(Var 14 __libasr__created__var__1_return_slot)
(Integer 4)
()
))
((Cast
(IntegerConstant 1 (Integer 4) Decimal)
IntegerToInteger
(Integer 4)
(IntegerConstant 1 (Integer 4) Decimal)
()
))
((Var 14 __libasr__created__var__2_return_slot))]
()
.true.
)
(ExplicitDeallocate
[(Var 14 __libasr__created__var__3_return_slot)]
)
(Allocate
[((Var 14 __libasr__created__var__3_return_slot)
[]
(FunctionCall
1 _lcompilers_len_trim_str2
1 _lcompilers_len_trim_str2
[((Var 14 mime_type))]
(Integer 4)
()
()
)
()
())]
()
()
()
)
(SubroutineCall
1 _lcompilers_trim_str2
()
[((Var 14 mime_type))
((Var 14 __libasr__created__var__3_return_slot))]
()
.true.
)
(ExplicitDeallocate
[(Var 14 __libasr__created__var__4_return_slot)]
)
(Allocate
[((Var 14 __libasr__created__var__4_return_slot)
[]
(FunctionCall
1 _lcompilers_len_trim_str3
1 _lcompilers_len_trim_str3
[((Var 14 mime_type))]
(Integer 4)
()
()
)
()
())]
()
()
()
)
(SubroutineCall
1 _lcompilers_trim_str3
()
[((Var 14 mime_type))
((Var 14 __libasr__created__var__4_return_slot))]
()
.true.
)
(ExplicitDeallocate
[(Var 14 __libasr__created__var__5_return_slot)]
)
(SubroutineCall
1 _lcompilers_stringconcat
()
[((Var 14 __libasr__created__var__3_return_slot))
((StringConstant
""
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
))
((StringLen
(Var 14 __libasr__created__var__4_return_slot)
(Integer 4)
()
))
((Cast
(IntegerConstant 1 (Integer 4) Decimal)
IntegerToInteger
(Integer 4)
(IntegerConstant 1 (Integer 4) Decimal)
()
))
((Var 14 __libasr__created__var__5_return_slot))]
()
.true.
)
(ExplicitDeallocate
[(Var 14 __libasr__created__var__6_return_slot)]
)
(Allocate
[((Var 14 __libasr__created__var__6_return_slot)
[]
(FunctionCall
1 _lcompilers_len_trim_str4
1 _lcompilers_len_trim_str4
[((Var 14 data))]
(Integer 4)
()
()
)
()
())]
()
()
()
)
(SubroutineCall
1 _lcompilers_trim_str4
()
[((Var 14 data))
((Var 14 __libasr__created__var__6_return_slot))]
()
.true.
)
(ExplicitDeallocate
[(Var 14 __libasr__created__var__7_return_slot)]
)
(Allocate
[((Var 14 __libasr__created__var__7_return_slot)
[]
(FunctionCall
1 _lcompilers_len_trim_str5
1 _lcompilers_len_trim_str5
[((Var 14 data))]
(Integer 4)
()
()
)
()
())]
()
()
()
)
(SubroutineCall
1 _lcompilers_trim_str5
()
[((Var 14 data))
((Var 14 __libasr__created__var__7_return_slot))]
()
.true.
)
(ExplicitDeallocate
[(Var 14 __libasr__created__var__8_return_slot)]
)
(SubroutineCall
1 _lcompilers_stringconcat
()
[((Var 14 __libasr__created__var__6_return_slot))
((StringConstant
""
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
))
((StringLen
(Var 14 __libasr__created__var__7_return_slot)
(Integer 4)
()
))
((Cast
(IntegerConstant 1 (Integer 4) Decimal)
IntegerToInteger
(Integer 4)
(IntegerConstant 1 (Integer 4) Decimal)
()
))
((Var 14 __libasr__created__var__8_return_slot))]
()
.true.
)
(ExplicitDeallocate
[(Var 14 __libasr__created__var__9_return_slot)]
)
(Allocate
[((Var 14 __libasr__created__var__9_return_slot)
[]
(FunctionCall
1 _lcompilers_len_trim_str6
1 _lcompilers_len_trim_str6
[((Var 14 data))]
(Integer 4)
()
()
)
()
())]
()
()
()
)
(SubroutineCall
1 _lcompilers_trim_str6
()
[((Var 14 data))
((Var 14 __libasr__created__var__9_return_slot))]
()
.true.
)
(ExplicitDeallocate
[(Var 14 __libasr__created__var__10_return_slot)]
)
(Allocate
[((Var 14 __libasr__created__var__10_return_slot)
[]
(FunctionCall
1 _lcompilers_len_trim_str7
1 _lcompilers_len_trim_str7
[((Var 14 data))]
(Integer 4)
()
()
)
()
())]
()
()
()
)
(SubroutineCall
1 _lcompilers_trim_str7
()
[((Var 14 data))
((Var 14 __libasr__created__var__10_return_slot))]
()
.true.
)
(ExplicitDeallocate
[(Var 14 __libasr__created__var__11_return_slot)]
)
(SubroutineCall
1 _lcompilers_stringconcat
()
[((Var 14 __libasr__created__var__9_return_slot))
((StringConstant
""
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)
))
((StringLen
(Var 14 __libasr__created__var__10_return_slot)
(Integer 4)
()
))
((Cast
(IntegerConstant 1 (Integer 4) Decimal)
IntegerToInteger
(Integer 4)
(IntegerConstant 1 (Integer 4) Decimal)
()
))
((Var 14 __libasr__created__var__11_return_slot))]
()
.true.
)
(SubroutineCall
2 lf_display_data
()
[((Cast
(Var 14 __libasr__created__var__2_return_slot)
StringToArray
(Array
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength CChar)
[((IntegerConstant 1 (Integer 4) Decimal)
(IntegerBinOp
(StringLen
(Var 14 __libasr__created__var__5_return_slot)
(Integer 4)
()
)
Div
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
))]
StringArraySinglePointer
)
()
()
))
((Cast
(Var 14 __libasr__created__var__8_return_slot)
StringToArray
(Array
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength CChar)
[((IntegerConstant 1 (Integer 4) Decimal)
(IntegerBinOp
(StringLen
(Var 14 __libasr__created__var__11_return_slot)
(Integer 4)
()
)
Div
(IntegerConstant 1 (Integer 4) Decimal)
(Integer 4)
()
))]
StringArraySinglePointer
)
()
()
))]
()
.false.
)]
()
Public
.false.
.false.
()
),
lf_display_data:
(Function
(SymbolTable
13
{
mime:
(Variable
13
mime
[]
In
()
()
Default
(Array
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength CChar)
[(()
())]
StringArraySinglePointer
)
()
BindC
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
),
payload:
(Variable
13
payload
[]
In
()
()
Default
(Array
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength CChar)
[(()
())]
StringArraySinglePointer
)
()
BindC
Public
Required
.false.
.false.
.false.
()
.false.
.false.
NotMethod
()
[]
)
})
lf_display_data
(FunctionType
[(Array
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength CChar)
[(()
())]
StringArraySinglePointer
)
(Array
(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength CChar)
[(()
())]
StringArraySinglePointer
)]
()
BindC
Interface
"lfortran_display_data"
.false.
.false.
.false.
.false.
.false.
[]
.false.
)
[]
[(Var 13 mime)
(Var 13 payload)]
[]
()
Public
.false.
.false.
()
)
})
lfortran_display
()
[iso_c_binding]
.false.
.false.
.false.
)
})
[]
)
The ASR has all the semantic information (types, etc.), nodes like Function have a symbol table and do not have any declaration nodes. Variables are simply pointers to the symbol table.
The ASR can also be exported in JSON, including source file name, line and column information: lfortran example.f90 --show-asr --json
Discussion¶
The above was a simple example. Things get more apparent for more complicated examples, such as:
integer function f2b(a) result(r)
use gfort_interop, only: c_desc1_int32
integer, intent(in) :: a(:)
interface
integer function f2b_c_wrapper(a) bind(c, name="__mod1_MOD_f2b")
use gfort_interop, only: c_desc1_t
type(c_desc1_t), intent(in) :: a
end function
end interface
r = f2b_c_wrapper(c_desc1_int32(a))
end function
AST must represent all the use statements and the interface block, and keep things semantically consistent.
ASR, on the other hand, keeps track of the c_desc1_int32, c_desc1_t and f2b_c_wrapper in the symbol table and it knows they are defined in the gfort_interop module, and so ASR does not have any of these declaration nodes.
When converting from ASR to AST, LFortran will create all the appropriate AST declaration nodes automatically and correctly.