first we have patterns for every tokens in the language.
identifiers = (letter).(letter+digit+underscore)*
numbers = (digit).(digit)*
comment start = " \* "
each keyword is a separate pattern
now, let take the source code :-
int a,b = 50 ;
lexeme :- find the consecutive words until match with a pattern
scans whitespace ===> when it is find a white space then make "int" as a lexeme.
check for pattern which it is matched, then declare it as keyword
scans comma(,) ===> when it is find a comma then make "a" as a lexeme.
check for pattern which it is matched, then declare it as identifier
continue this process....