BEGIN: Think of this as the starting point. It tells the lexical analyzer (lexer) to start at a specific state, usually state 0.
ECHO: This action simply repeats or “echoes” the input as it is. It’s like a mirror reflecting the input back.
yytext():
yytext holds the characters that form a token (like a word or number) when the lexer recognizes it.
Whenever a new token is found, yytext gets updated with that token’s content.
yylex(): This function is crucial. It’s called when the lexer begins scanning the source program. Essentially, it’s the main action that drives the lexing process.
yywrap():
yywrap() is triggered when the lexer reaches the end of the file.
If yywrap() returns 0, the lexer keeps scanning.
If yywrap() returns 1, it indicates that the end of the file has been reached.
yyin: This is where the input source program is stored. It’s like the source document that the lexer reads from.
yyleng: This simply keeps track of how many characters are in the current input string being processed.