From 03bf321dc0aac6a2bc635093d634e1c8e67f8d43 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Thu, 8 Oct 2009 18:44:55 +0200 Subject: defines with constant but more complex expressions are now no longer ignored (e.g #define CL_FP_FMA (1 << 5)). --- src/java/com/sun/gluegen/cgram/StdCParser.g | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/java/com/sun/gluegen/cgram') 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') ; -- cgit v1.2.3