Calt lookup simple scripting question

I came a cross one Arabic font, trying to analyze how it’s programmed,
below is a piece of the code:

script arab;
lookup calt0 {
lookupflag RightToLeft IgnoreMarks;
sub [a b c d e f]' [etc1 etc2] lookup lookup_0 ;
} calt0;

lookup calt1 {
lookupflag RightToLeft IgnoreMarks;
sub [w x y z]' [etc3 etc4] lookup lookup_1 ;
} calt1;

lookup calt2 {
lookupflag RightToLeft IgnoreMarks;
sub [h j k l]' [etc5 etc6] lookup lookup_0 ;
} calt2;

what I know that the below is a function to be called

lookup calt0 {
} calt0;

and I know that sub is used to substitute the “tick marked’”, but I can’t see the “by”

my questions are:
1 - what’s going on inside these functions (knowing that [a b c etc1 …] are just random glyphs names
2 - the relationship between these function because it appears to me that one is calling another, (calt2 is calling calt0 or what?)


This is a chaining contextual rule: