Lex

  • Program that generates lexical analyzer.
  • Used with [[YACC]] Parser
  • A Lex program is separated into three sections by \%\% delimiters
    1. { definitions }   
    2. %%  
    3.  { rules }   
    4. %%   
    5. { user subroutines }
    
  • Definitions -> Declaration of constants, variable and regular definitions
  • Rules -> Statement of form p1 {action1} ...
  • User subroutines -> auxillary procedures needed by actions. Subroutine can be loaded by lexical analyzer and compiled separately.

REGEX - You specify the patterns you are interested in with a notation called a regular expression. - The + operator means one or more occurrences of the preceding expression - m+ means m,mm,mmmmmm.... - The ? means 0 or 1 occurrences of the preceding expression - m? means m or null - The * means 0 or more occurrences of the preceding expression. - m? means null,m,mm,mmmmmm.... -