I explain the way to read Perl core source codes. Perl 5.36.0 is used in this description.
Where is main function?
main function is the entry point of
It is written in
perlmain.c, but Perl has no C source code that name is
Where is processing perl command line arguments?
Processing perl command line arguments are started from perl_parse function.
perl_parse is defined in perl.c.
Go forward to parse_body function.
parse_body is defined in perl.c
You can see the processing logic of command line arguments.
Where is tokenizer?
Next is the tokenizer. The parts of Perl syntax are converted to tokens.
Tokenizing is started from lex_start function.
lex_start is defined in toke.c.
Where is parser?
Next is the parser. The parser converts tokens to AST(abstruct syntax tree).
Parsing is started from yyparse function.
yyparse is defined in perly.c.
Where is Perl data structure?
Where does Perl run?
After AST is optimized, Perl run from perl_run function.
perl_run is defined in perl.c.
Go forward to run_body function.
run_body is defined in perl.c.
Go forward to CALLRUNOPS.
CALLRUNOPS is defined as
PL_runops in perl.h
Furthermore, macros are defined as follows.
perl.h:#define CALLRUNOPS PL_runops embedvar.h:#define PL_runops (vTHX->Irunops) intrpvar.h:PERLVARI(I, runops, runops_proc_t, RUNOPS_DEFAULT) perl.h:# define RUNOPS_DEFAULT Perl_runops_standard
Go forward to
Perl_runops_standard is defined in run.c.
The member op_ppaddr of
OP structure is called.
op_ppaddr is a function pointer to perlform an operation.
Where are operators defined?
Operators are defined in the following sources.