[antlr-interest] how to know the position

Yixun Liu enjoywm at cs.wm.edu
Mon Sep 22 17:36:59 PDT 2008


Hi,
I want to comment out the code beginning with "cuda", but ignore the 
"cuda" appearing in the middle.
For example ,comment out:
cudaType c = new cudaType();
but enable
function(cudaType c);
What I do is like,
CUDAComment
        :
                ("cuda" ( ~('\n') )* 
{setPreprocessingDirective(getText(),Pragma.comment);})
                        {
 
                        _ttype = Token.SKIP;
                        }
        ;

But it will comment the code with "cuda" in the middle. How to know the 
positon of "cuda"?

Best,

Yixun


More information about the antlr-interest mailing list