Quick Short Answer
Yes, its the standard practice, to detect comments in the "lexer" or the "parser"
Sometimes, the "parser" has a built-in "lexer" or is mixed with the "parser" as a single tool ("lexer-parser").
Extended Answer
I just working in that case.
Most "scanners" ( also know as "tokenizers" or "lexers" ), detect comments, but, removed when returning tokens to the "parser".
Sometimes, a programming language, uses some comments with a special meaning, like "compiler directives" or "documentation".
Standard Comment Example:
/*
This function does something cool.
*/
int doSomething()
{
return 0;
}
Directive Comment Example:
/*
##override
*/
int doSomething()
{
return 0;
}
Comment for documentation generator Example:
/*
@description: This Function text will be turn,
into an external pdf file, togheter with other
similar comments.
*/
int doSomething()
{
return 0;
}
Most compiler-related tools, detect this special comments, with an analyzer or preprocessor, that is not the main lezxer or parser, and, even has a small lexer of its own.
Cheers.