Hi all,

I am new to antlr and I am trying use it to gather metrics about code
starting with the low hanging fruit I wanted to count slocs so I made the
following grammar but it doesn't seem to work correctly any advice would be
appreciated. Also can I use the just a lexer by itself or do I absolutely
need a Parser as well ?

lexer grammar Slocs;

options {
  language = Java;
  filter=true;
}

@lexer::header {
package code.metrics;
}

@lexer::members {
    public int slocs = 0;
}


COMMENT:
    ('/*' .* '*/' | '//' ~('\r' | '\n')* ) {$channel=HIDDEN;}
    ;


SLOC:
    .* ';' {slocs++;}
    ;


LINE:
    .* NEWLINE {$channel=HIDDEN;}
    ;

fragment NEWLINE:
    '\r'? '\n'
    ;

Thanks

Troy

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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to