summaryrefslogtreecommitdiffstats
path: root/src/antlr/com/jogamp/gluegen
diff options
context:
space:
mode:
Diffstat (limited to 'src/antlr/com/jogamp/gluegen')
-rw-r--r--src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g3
-rw-r--r--src/antlr/com/jogamp/gluegen/cgram/StdCParser.g15
2 files changed, 12 insertions, 6 deletions
diff --git a/src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g b/src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g
index e8ca8c5..bf01b12 100644
--- a/src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g
+++ b/src/antlr/com/jogamp/gluegen/cgram/GnuCParser.g
@@ -23,6 +23,7 @@ header {
import antlr.CommonAST;
import antlr.DumpASTVisitor;
+ import com.jogamp.gluegen.ASTLocusTag;
}
@@ -715,7 +716,7 @@ tokens {
public void addDefine(String name, String value)
{
- defines.add(new Define(name, value));
+ defines.add(new Define(name, value, new ASTLocusTag(lineObject.getSource(), lineObject.getLine()+deferredLineCount, -1, name)));
}
/** Returns a list of Define objects corresponding to the
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*/ }
}