summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/cgram/StdCParser.g
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-10-08 18:44:55 +0200
committerMichael Bien <[email protected]>2009-10-08 18:44:55 +0200
commit03bf321dc0aac6a2bc635093d634e1c8e67f8d43 (patch)
treee0dddfc255553c39fd9744f79fc1834b338f1555 /src/java/com/sun/gluegen/cgram/StdCParser.g
parentce3fceeb101835866224988918b89098157d6e34 (diff)
defines with constant but more complex expressions are now no longer ignored (e.g #define CL_FP_FMA (1 << 5)).
Diffstat (limited to 'src/java/com/sun/gluegen/cgram/StdCParser.g')
-rw-r--r--src/java/com/sun/gluegen/cgram/StdCParser.g21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/java/com/sun/gluegen/cgram/StdCParser.g b/src/java/com/sun/gluegen/cgram/StdCParser.g
index e84fbfd..65e7936 100644
--- a/src/java/com/sun/gluegen/cgram/StdCParser.g
+++ b/src/java/com/sun/gluegen/cgram/StdCParser.g
@@ -1112,22 +1112,33 @@ options {
:
'#'
( ( "line" || (( ' ' | '\t' | '\014')+ '0'..'9')) => LineDirective
- | ( (Space)* "define" (Space)* i:ID (Space)* (n:Number)?
+ | ( (Space)* "define" (Space)* i:ID (Space)* (n:DefineExpr)?
nw:NonWhitespace
- ("\r\n" | "\r" | "\n") ) { if (n != null) {
+ ("\r\n" | "\r" | "\n") ) {
+ if (n != null) {
+ //System.out.println("addDefine: #define " + i.getText() + " " + n.getText());
addDefine(i.getText(), n.getText());
} else {
- setPreprocessingDirective("#define " + i.getText() + " " +
- nw.getText());
+ setPreprocessingDirective("#define " + i.getText() + " " + nw.getText());
}
}
| (~'\n')* { setPreprocessingDirective(getText()); }
)
- {
+ {
_ttype = Token.SKIP;
}
;
+DefineExpr:
+ ((LPAREN) (Space)* (DefineExpr2) (Space)* (RPAREN)) | (DefineExpr2)
+;
+
+DefineExpr2:
+ (Number)
+ ((Space)* (LSHIFT | RSHIFT | PLUS | MINUS | STAR | DIV | MOD) (Space)* (DefineExpr))?
+;
+
+
protected Space:
( ' ' | '\t' | '\014')
;