How difference of implement pragma handler in lexer and parser

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How difference of implement pragma handler in lexer and parser

Pisit Makpaisit
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. 
--
Remixman (Pisit Makpaisit)

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: How difference of implement pragma handler in lexer and parser

Douglas Gregor

On Jun 28, 2010, at 6:46 PM, Pisit Makpaisit wrote:

> 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.

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
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: How difference of implement pragma handler in lexer and parser

Pisit Makpaisit
Thank you.

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

--
Remixman (Pisit Makpaisit)

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: How difference of implement pragma handler in lexer and parser

Douglas Gregor

On Jun 29, 2010, at 6:09 PM, Pisit Makpaisit wrote:

> 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


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev