Hi All,
I have a simple grammar to collapse white-spaces and comment from a c source
code input. Also I would like to filter out some variables with a specific
name. These have a strict format, so no "real" C parsing needed.
Works fine but for example a line "#define PC_HASH_VALUE 1" is not
recognized. As far I remember from previous ANTLR usage, this was working
straight away. Any suggestions? Thanks!
/* **** [ CODE ] **** */
lexer grammar Collapse;
options {
language = Java;
filter = true;
}
@header {
package rewriter;
import java.util.*;
import java.io.*;
}
@members {
PrintStream out;
public Collapse(CharStream input, PrintStream out) {
this(input);
this.out = out;
}
}
PC: 'PC_HASH_VALUE' text=DIGIT {$channel=HIDDEN;};
fragment
DIGIT: '0'..'9';
COMMENT
: '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
| '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
;
WS : ( ' '
| '\t'
| '\r'
| '\n'
) {$channel=HIDDEN;}
;
ELSE : c=. {out.print((char)$c);} ; // match any char and emit
/* **** [ END ] **** */
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.