summaryrefslogtreecommitdiffstats
path: root/src/antlr/com/jogamp/gluegen/cgram/StdCParser.g
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-03-09 07:02:43 +0100
committerSven Gothel <[email protected]>2015-03-09 07:02:43 +0100
commit5dd12c17bf5037c7ac6a2ac73caf4d61443c4749 (patch)
treec7d236cfbf44544852fcdab31ad44130471032f0 /src/antlr/com/jogamp/gluegen/cgram/StdCParser.g
parent8efdf71e2de6392344326ba6a28e8f8fa7e3e8e5 (diff)
Bug 1134 - Add ASTLocusTagProvider for Define and fix newline in c-parser (Expose source location for log/error messages)
Diffstat (limited to 'src/antlr/com/jogamp/gluegen/cgram/StdCParser.g')
-rw-r--r--src/antlr/com/jogamp/gluegen/cgram/StdCParser.g15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/antlr/com/jogamp/gluegen/cgram/StdCParser.g b/src/antlr/com/jogamp/gluegen/cgram/StdCParser.g
index 7b34656..26da996 100644
--- a/src/antlr/com/jogamp/gluegen/cgram/StdCParser.g
+++ b/src/antlr/com/jogamp/gluegen/cgram/StdCParser.g
@@ -1131,11 +1131,12 @@ options {
nw:NonWhitespace
("\r\n" | "\r" | "\n") ) {
if (n != null) {
- //System.out.println("addDefine: #define " + i.getText() + " " + n.getText());
+ // System.out.println("addDefine: #define " + i.getText() + " " + n.getText()+" @ "+lineObject.getSource()+":"+(lineObject.line+deferredLineCount));
addDefine(i.getText(), n.getText());
} else {
setPreprocessingDirective("#define " + i.getText() + " " + nw.getText());
}
+ deferredNewline();
}
| (~'\n')* { setPreprocessingDirective(getText()); }
)
@@ -1165,15 +1166,19 @@ protected LineDirective
}
:
{
- lineObject = new LineObject();
- deferredLineCount = 0;
+ lineObject = new LineObject();
+ deferredLineCount = 0;
}
("line")? //this would be for if the directive started "#line", but not there for GNU directives
(Space)+
- n:Number { lineObject.setLine(Integer.parseInt(n.getText())); }
+ n:Number {
+ lineObject.setLine(Integer.parseInt(n.getText()));
+ }
(Space)+
( fn:StringLiteral { try {
- lineObject.setSource(fn.getText().substring(1,fn.getText().length()-1));
+ final String newSource = fn.getText().substring(1,fn.getText().length()-1);
+ // System.out.println("line: "+lineObject.getSource()+" -> "+newSource+", line "+(lineObject.line+deferredLineCount));
+ lineObject.setSource(newSource);
}
catch (StringIndexOutOfBoundsException e) { /*not possible*/ }
}