How difference of implement pragma handler in lexer and parser

I notice that clang can implement the pragma handler in both lexer (Lex/Pragma.cpp) and parser (Parse/ParsePragma.cpp). How difference of they?

If my pragma directive has an expression. How can I parse and check expression syntax in pragma?
I think I should implement pragma handler in parser for parse the expression but I don’t know how can I do.

Thanks in advance.

If you want to parse an expression in your pragma, you'll need to implement your pragma's parsing logic within the parser itself, which knows how to parse an expression.

  - Doug

Thank you.

Can I build and add node to AST in pragma’s parsing?

Yes. The parser can make calls through the Action interface to Sema, which constructs the AST.

  - Doug