Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

What are the various LEX actions that are used in LEX programming ?

  1. BEGIN: Think of this as the starting point. It tells the lexical analyzer (lexer) to start at a specific state, usually state 0.
  2. ECHO: This action simply repeats or “echoes” the input as it is. It’s like a mirror reflecting the input back.
  3. 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.
  4. 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.
  5. 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.
  6. yyin: This is where the input source program is stored. It’s like the source document that the lexer reads from.
  7. yyleng: This simply keeps track of how many characters are in the current input string being processed.

Leave a Comment