diff options
author | Sven Gothel <[email protected]> | 2015-03-06 07:28:35 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-03-06 07:28:35 +0100 |
commit | 8eb9e27bccca4a0cd6a0b1b15bee76576ce030c3 (patch) | |
tree | 27dc3f766a4c5085325fd6a019bd92b9c99f46ee /src/java/com/jogamp/gluegen/cgram/TNode.java | |
parent | ea6df88075c44f6b6317920119d6b33d5d97b362 (diff) |
Bug 1134 - Add ASTLocationTag, locating source of [semantic] errors while parsing / analyzing
New GlueGenException supports ASTLocationTag,
which will be throws in case of semantic and/or parsing errors.
Diffstat (limited to 'src/java/com/jogamp/gluegen/cgram/TNode.java')
-rw-r--r-- | src/java/com/jogamp/gluegen/cgram/TNode.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/java/com/jogamp/gluegen/cgram/TNode.java b/src/java/com/jogamp/gluegen/cgram/TNode.java index a564c54..70dc2c4 100644 --- a/src/java/com/jogamp/gluegen/cgram/TNode.java +++ b/src/java/com/jogamp/gluegen/cgram/TNode.java @@ -3,10 +3,14 @@ package com.jogamp.gluegen.cgram; import antlr.collections.AST; import antlr.CommonAST; import antlr.Token; + import java.lang.reflect.*; import java.util.Hashtable; import java.util.Enumeration; +import com.jogamp.gluegen.ASTLocusTag; +import com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider; + /** Class TNode is an implementation of the AST interface and adds many useful features: @@ -29,7 +33,8 @@ import java.util.Enumeration; */ -public class TNode extends CommonAST { +@SuppressWarnings("serial") +public class TNode extends CommonAST implements ASTLocusTagProvider { protected int ttype; protected String text; protected int lineNum = 0; @@ -40,7 +45,22 @@ public class TNode extends CommonAST { protected Hashtable<String, Object> attributes = null; static String tokenVocabulary; - + /** + * {@inheritDoc} + * <p> + * If <i>source</i> is not available, + * implementation returns {@code null}. + * </p> + */ + @Override + public ASTLocusTag getASTLocusTag() { + final Object s = getAttribute("source"); + if( null != s ) { + return new ASTLocusTag(s, getLineNum(), -1, getText()); + } else { + return null; + } + } /** Set the token vocabulary to a tokentypes class |