Hi Vijay,

You could grab all matched text in the `@after` block using the `getText()`
method:

COMMENT
@init{
  boolean isJavaDoc = false;
  System.out.println("Entering comment");
}
@after {
  System.out.println("Leaving comment, matched: " + getText());
}
  :  '/*'
     {
       if((char)input.LA(1) == '*') {
         isJavaDoc = true;
       }
     }
     (options {greedy=false;} : . )*
     '*/'
  ;


Regards,

Bart Kiers.



On Mon, May 30, 2011 at 8:08 PM, Vijay Raj <call.vijay...@yahoo.com> wrote:

> Hi -
>    I am trying to parse a given java file, with a code fragment that
> consumes comments as below: ( Code fragment got from Java.g , pasted in the
> antlr site, to give credit where it is due).
>
>
> COMMENT
>          @init{
>             boolean isJavaDoc = false;
>             System.out.println("Entering comment");
>         }
>     :   '/*'
>             {
>                 if((char)input.LA(1) == '*'){
>                     isJavaDoc = true;
>                 }
>             }
>         (options {greedy=false;} : . )*
>         '*/'
>   ...
>      ;
>
>
> I am trying to get all the characters mapped by the wildcard regex , as in
> 'options greedy' line in the grammar file and get the string into the Java
> world for further processing.   What hidden system variables/ grammar should
> I use to take care of the same ?
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to