aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/cgram/StdCParser.g
diff options
context:
space:
mode:
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')
;